Skip to content

Instantly share code, notes, and snippets.

View light9's full-sized avatar

Alexey light9

  • New Delhi, India
View GitHub Profile
Make sure you have set a root password (sudo su passwd) Depending how your ssh is installed, you usually need to edit /etc/ssh/sshd_config and change "PermitRootLogin no" to "PermitRootLogin yes"
@light9
light9 / Uninstall unuserd modules (which not exist)
Created August 31, 2013 13:22
Drupal 7 Uninstall unuserd modules (which not exist)
for FN in `drush --extra=--skip-column-names sql-query "SELECT filename FROM system WHERE status = 1"`; do [ ! -f $FN ] && echo "Missing $FN"; done
@light9
light9 / check&kill node.js
Last active December 22, 2015 01:39
check&kill node.js
ps ax | grep node | grep meteor
netstat -lpn |grep :8090
pkill -9 -f nodejs
sudo kill -15 <PID>
@light9
light9 / create tar
Created September 2, 2013 09:12
create tar
create tar
tar -c public_html > backup.tar
Extract tar
tar -xvf backup.tar
--
$ gunzip file.gz
$ ls file
Using gzip -d command:
$ gzip -d file.gz
@light9
light9 / new_gist_file
Created September 5, 2013 15:51
drush push command without confirmation
drush -y pm-update
drush pm-update --no-core
@light9
light9 / seconds to date
Created September 9, 2013 12:52
This is a simple PHP code that converts a number of seconds into a string according to the following format: M d h m s. Number of months is an approx calculation supposing months are 30 days long.
function seconds2human($ss) {
$s = $ss%60;
$m = floor(($ss%3600)/60);
$h = floor(($ss%86400)/3600);
$d = floor(($ss%2592000)/86400);
$M = floor($ss/2592000);
return "$M months, $d days, $h hours, $m minutes, $s seconds";
}
@light9
light9 / date
Created September 11, 2013 10:07
From http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript // create a new javascript Date object based on the timestamp
var s = 1378897200; // unix timestamp
var theDate = new Date(s*1000);
//dateString = theDate.toLocaleString();
var year = theDate.getFullYear();
var month = theDate.getMonth() + 1;
var day = theDate.getDate();
var hours = theDate.getHours();
var minutes = theDate.getMinutes();
var seconds = theDate.getSeconds();
@light9
light9 / unix time
Created September 11, 2013 13:16
JavaScript works with the number of milliseconds since the epoch whereas most other languages work with the seconds. You could work with milliseconds but as soon as you pass a value to say PHP, the PHP native functions will probably fail. So to be sure I always use the seconds, not milliseconds.
//This will give you a Unix timestamp (in seconds):
var unix = Math.round(+new Date()/1000);
//This will give you the milliseconds since the epoch (not Unix timestamp):
var milliseconds = new Date().getTime();
@light9
light9 / watchdog-delete -y all
Created September 16, 2013 00:12
drush watchdog-delete -y all
drush watchdog-delete -y all
@light9
light9 / sites-aviliable - sites-enables
Created September 16, 2013 00:24
nginx create alias sites-aviliable - sites-enables
sudo ln -s /etc/nginx/sites-available/node1.conf /etc/nginx/sites-enabled/node1.conf