Skip to content

Instantly share code, notes, and snippets.

View allanesquina's full-sized avatar
💭
New horizon!

Allan Esquina allanesquina

💭
New horizon!
View GitHub Profile
<div class="row">
<div class="col-4"><p>col-4</p></div>
<div class="col-4"><p>col-4</p></div>
<div class="col-4">
<div class="row">
<div class="col-4"><p>A</p></div>
<div class="col-4"><p>B</p></div>
<div class="col-4"><p>C</p></div>
</div>
</div>
@allanesquina
allanesquina / xRandom.js
Last active August 29, 2015 13:56
JavaScript function that returns an array of random numbers without repetition
/*
* xRandom
* Returns an array of random numbers without repetition
* array range, int limit
*/
function xRandom( range, limit ) {
if( --limit >= range[1] || limit < 0 ) return;
return (function _xr( i, r, result ) {
var max = range[1], min = range[0], j = r.length, c=0,
rand = Math.floor(Math.random() * (max - min + 1) + min);
@allanesquina
allanesquina / render.js
Last active August 29, 2015 14:01
Render function
function render( tplName, data ) {
try {
var tpl = $( '#' + tplName )[0].innerHTML || {},
k, rx = /{\|\|.*?\|\|}/g, tmp ;
for( k in data ) {
tmp = new RegExp( '{\\|\\|data\\.'+ k +'\\|\\|}', 'g' );
tpl = tpl.replace( tmp, data[ k ] );
}
@allanesquina
allanesquina / onpopstateeq.js
Last active August 29, 2015 14:06
onpopstate equivalent
// dep: jQuery
//armazena state
var __old = history.state;
// checa state
setInterval( function() {
if( history.state !== __old ) {
//triga o evento
$( window ).trigger( 'meuevento', [1,3,2] );
// cacheia state atual
@allanesquina
allanesquina / convertvideo.sh
Last active August 29, 2015 14:13 — forked from franklinjavier/convertvideo.sh
Convert video using avconv
#!/bin/bash
# ./convertvideo.sh Directory filetype
#
# Ex:
# ./convertvideo.sh /videos mp4
ls *$1 \
| while read f
#!/bin/bash
# ./renamefiles.sh directory
#
ls *$1 | egrep 'regex here+' \
| while read f
do
# if you need remove some character
tna=$(echo $f | sed 's/regex here//')
@allanesquina
allanesquina / sshfs.sh
Created January 30, 2015 16:33
Mount Remote File Systems Over SSH
mkdir /home/mount
sudo sshfs -o allow_other root@myipaddress:/ /home/mount -p 21
@allanesquina
allanesquina / scp.sh
Created February 5, 2015 15:18
Example syntax for Secure Copy (scp)
# Single file (-P = ssh port)
sudo scp -P 21 root@server:/var/log/nginx/access.log /home/Downloads/
# Recursive
sudo scp -r -P 21 root@server:/var/log/nginx/ /home/Downloads/
@allanesquina
allanesquina / curlftpfs.sh
Created February 21, 2015 19:48
Mount ftp as a drive
mkdir fromftp
sudo curlftpfs -o allow_other ftp://user:pass@hostname /home/fromftp
// Object construcion exemple
function MyClass() {
this.myProperty = 'foo';
}
// Whitout new
var myInstance = {};
MyClass.call( myInstance );
console.log( 'without ' + myInstance.myProperty );