Skip to content

Instantly share code, notes, and snippets.

View leosuncin's full-sized avatar

Jaime Leonardo Suncin Cruz leosuncin

View GitHub Profile
@leosuncin
leosuncin / RegEx Datetime
Created December 16, 2014 16:42
RegEx pattern (DateTime php)
/\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{1,2}:\d{1,2}\+\d{4}/
@leosuncin
leosuncin / Enable PHP MCrypt
Created December 25, 2014 18:13
Enable MCrypt PHP extension on Ubuntu
sudo -s
apt-get install php5-mcrypt
php5enmod mcrypt
service apache2 restart
@leosuncin
leosuncin / gist:cb3c8ff33ca5d03ac11a
Created January 25, 2015 18:55
show dd progress
dd if=<origen> of=<destino>
watch -n 10 kill -USR1 $(pgrep -l '^dd$' | tr -d [:alpha:])
pv -ptre <origen> | dd of=<destino>
(pv -n /dev/sda | dd of=/dev/sdb bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0
@leosuncin
leosuncin / development.js
Created January 27, 2015 21:12
Configure livereload support to sails.js
// config/env/development.js
/**
* Development environment settings
*
* This file can include shared settings for a development team,
* such as API keys or remote database passwords. If you're using
* a version control solution for your Sails app, this file will
* be committed to your repository unless you add it to your .gitignore
* file. If your repository will be publicly viewable, don't add
* any private information to this file!
@leosuncin
leosuncin / README.md
Last active October 12, 2023 18:00
Install Powerline on Debian/Ubuntu
  1. Install pip sudo apt-get install python-pip or wget https://bootstrap.pypa.io/get-pip.py && sudo python get-pip.py
  2. Install powerline sudo pip install powerline-status
  3. Download and install fonts git clone https://github.com/powerline/fonts.git && cd fonts && sh ./install.sh
  4. Add this lines to respective file
    .vimrc

set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/
> " Always show statusline

@leosuncin
leosuncin / README.md
Last active August 29, 2015 14:16
Resize automatically images when was uploaded to server

Resize automatically images when was uploaded to server

For watch for changes in a folder, I use incron, what is a equivalent to cronjob
See man incrontab

Prerequisites

You must first install incron and GraphicsMagick
sudo apt-get install incron graphicsmagick
Add your username in /etc/incron.allow before to use incrontab, then execute incrontab -e and add the next lines (<path to watch> <file event> <script>)

/var/www/uploads/covers IN_CLOSE_WRITE,IN_DELETE /usr/local/bin/inotify.sh $@ $# $%

@leosuncin
leosuncin / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
if (!Array.isArray) {
  Array.isArray = function(arg) {
    return Object.prototype.toString.call(arg) === '[object Array]';
  };
}

or obj instanceof Array

@leosuncin
leosuncin / base64.js
Created April 8, 2015 23:01
Node.js Base64 functions
function btoa (str) {
return new Buffer(str).toString('base64');
}
function atob(str) {
return new Buffer(str, 'base64').toString('binary');
}
@leosuncin
leosuncin / Procfile
Last active August 29, 2015 14:20 — forked from facultymatt/Procfile
Deployd on Heroku
web: node server