Posts

Create a Background Service Using systemd In Linux

First of all, we are going to write a small python script which print "Hello World" every 60 seconds. This is going to be our service script (hello_world.py): 1 2 3 4 5 6 7 8 9 10 #!/usr/bin/python   from time import sleep   try :      while True :          print "Hello World"          sleep ( 60 ) except KeyboardInterrupt , e :      logging . info ( "Stopping..." ) You can execute it by  python hello_world.py . If you get boring reading so many hello worlds, press Ctrl+C (or Cmd+C on OSX) to stop it. Save this file as hello_world.py in your home folder ( home/pi/ ). Now we're going to define the service to run this script: 1 2 cd / lib / systemd / system / sudo nano hello .service The service definition must be on the  /lib/systemd/system  folder. Our service is going to be called "hello.service": 1 2 3 4 5 6 7 8 9 10 11

HTACCESS FOR URL ROUTING FOR ANGULAR 2 APPLICATION

/*HTACCESS FOR URL ROUTING FOR ANGULAR 2 APPLICATION*/ RewriteEngine On # If an existing asset or directory is requested go to it as it is RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d RewriteRule ^ - [L] # If the requested resource doesn't exist, use index.html RewriteRule ^ /index.html

Get the YouTube video ID from YouTube video URL Using Javascript

Use the below function to get the YouTube video ID from YouTube video URL /** * @param video_url String YouTube video link * @return String YouTube video ID */ function getMyYoutubeVideoId(video_url){ var l = document.createElement("a"); l.href = video_url; var frameId=''; var hostname=l.hostname; var path= l.pathname; var query=l.search; if(hostname=='youtu.be' || hostname=='www.youtu.be'){ frameId=path.replace('/',''); }else if(path=='/watch'){ var queryArray=query.split('='); frameId=queryArray[1]; }else if(path.substr(0,7)=='/embed/'){ frameId=path.substr(7); } return frameId; }