Skip to content

Instantly share code, notes, and snippets.

View fernandojsg's full-sized avatar

Fernando Serrano fernandojsg

View GitHub Profile
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.
@fernandojsg
fernandojsg / gist:9fcbc50fab7b2f84660d
Last active August 29, 2015 14:21
Available and used space in a folder (Python)
import math
def convertSize(size):
size_name = ("B","KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
i = int(math.floor(math.log(size,1024)))
p = math.pow(1024,i)
s = round(size/p,2)
if (s > 0):
return '%s %s' % (s,size_name[i])
else:
<?
function aes128_cbc_encrypt($key, $data, $iv) {
if(16 !== strlen($key)) $key = hash('MD5', $key, true);
if(16 !== strlen($iv)) $iv = hash('MD5', $iv, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
}
@fernandojsg
fernandojsg / gist:6e09e68f6d2205237316
Created May 21, 2015 06:50
Convert DOS Newlines CR-LF file to Unix/Linux format

#Using dos2unix Replacing the original file:

dos2unix filename

Creating a .bak copy of the original:

dos2unix -b filename

#Using tr command

@fernandojsg
fernandojsg / gist:f4d2d3fa10749a7ee527
Created June 2, 2015 10:15
Encrypt & Decrypt from command line
# Add it to your ~/.zshrc
encrypt () { openssl des3 -in $1 -out $1.encrypted }
decrypt () { FILENAME=$(echo $1|sed -e 's/\.encrypted$//g'); openssl des3 -d -in $1 -out $FILENAME }
@fernandojsg
fernandojsg / gist:9c5858c0c1d399970cc4
Last active August 29, 2015 14:23
XML Utils for php
class XmlUtils
{
function removeChildren(&$node)
{
while ($node->firstChild)
{
while ($node->firstChild->firstChild)
{
XmlUtils::removeChildren($node->firstChild);
}
### Aliases
# Open specified files in Sublime Text
# "s ." will open the current directory in Sublime
alias s='open -a "Sublime Text"'
alias d='cd /Volumes/SECUNDARIO'
alias gd='cd Volumes/SECUNDARIO/MIO/Google\ Drive/'
#alias ogc='open -a Google\ Chrome --args --disable-web-security'
alias ogc='open -a Google\ Chrome'
@fernandojsg
fernandojsg / convertimages.sh
Created July 26, 2015 17:06
Convert all the raw/cr2 images in this folder to .jpg
for i in *.CR2; do sips -s format jpeg $i --out "${i%.*}.jpg"; done
1 - Oculus Rift CV1, Oculus VR
displayId: 1
displayName: Oculus Rift CV1, Oculus VR
isConnected: true
isPresenting: false
capabilities:
hasOrientation: true
hasPosition: true
hasExternalDisplay: true
@fernandojsg
fernandojsg / brush.js
Last active September 20, 2016 13:43
BrushInterface
BrushInterface.prototype = {
addPoint: function (position, orientation, pointerPosition, pressure, timestamp) {},
tick: function (timeoffset, delta) {}
}