Skip to content

Instantly share code, notes, and snippets.

Avatar

Andres Hermosilla rezen

View GitHub Profile
@rezen
rezen / cf7.html
Created Apr 4, 2014
Contact form 7 text
View cf7.html
<div class="col-half">
<div class="input-block">
<label>Subject*</label>
[text* c_subject]
</div>
<div class="input-block">
<label>Company</label>
[text c_company]
</div>
<div class="input-block">
@rezen
rezen / json.php
Created Apr 21, 2014
Json maybe?
View json.php
<?php
/**
* Converts string to JSON, if not actually JSON,
* return just the stringi
* @param [type] $string [description]
* @return [type] [description]
*/
function getJsonOrString($string)
{
@rezen
rezen / find-dups.sql
Created May 1, 2014
mysql find duplicates of column value
View find-dups.sql
SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )
@rezen
rezen / TraceLoggable.php
Last active Aug 29, 2015
L4 Use logging in your classes and automatically get the function name
View TraceLoggable.php
<?php
/**
* Log inside object methods and automatically pass
* in the classname and function that the log
* is being executed under
*/
trait TraceLoggable{
/**
View series-nt-cb.js
var series = [
function( callback ){
callback( 'bob', 12);
return 1;
},
function ( callback, person, age ) {
console.log( person,age);
callback( 'moew' );
return 12;
@rezen
rezen / datamap.js
Last active Aug 29, 2015
datamapping with js
View datamap.js
'use strict';
/**
* Yay person!
* @class
* @dependancies a, b, c
* @param {string} name
* @param {[type]} address
@rezen
rezen / backup-mysql.sh
Last active Aug 29, 2015
improve mysqldump
View backup-mysql.sh
#!/bin/sh
# @notes
#
# If you have a moderately sized database ( 2gb dumps)
# make sure to update your mysql conf to allow larger packets
# for dump. Below are some suggested my.cnf settings
#
# If you have a fairly large db, mysqldump is not
# recommended. Instead try something like
@rezen
rezen / install-monit.sh
Last active Aug 29, 2015
install-monit.sh
View install-monit.sh
#!/bin/sh
# https://www.digitalocean.com/community/tutorials/lemp-stack-monitoring-with-monit-on-ubuntu-14-04
sudo yum install -y pam-devel openssl-devel
cd /usr/local/src
wget http://mmonit.com/monit/dist/monit-5.11.tar.gz
sudo wget http://mmonit.com/monit/dist/monit-5.11.tar.gz
sudo tar -zxvf monit-5.11.tar.gz
cd monit-5.11
@rezen
rezen / get-numbering.txt
Last active Aug 29, 2015
Understanding computer numbering systems
View get-numbering.txt
Binary number system
https://www.youtube.com/watch?v=ry1hpm1GXVI
Why binary?
https://www.youtube.com/watch?v=1sWCBgGALXE
8-bits = 1 byte
8-bits (aka 1 bytes) is amount needed for 1 of the 255 asci charactors
2^7 | 2^6|2^5 |2^4 |2^3|2^2|2^1|2^0
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 (max number = 255)
@rezen
rezen / input-mask.js
Created Feb 28, 2012
JS: input[type=File upload mask input[type="file"]!
View input-mask.js
// File upload mask
$('.upload-masked').each(function(){
var $this = $(this)
, $mask = $('<input type="text" class="upload-mask" value="" />');
$this.wrap('<div class="input-wrap" style="position:relative;"></div>');
$this.css({opacity:0,position:'absolute'});
$this.after('<span class="upload-mask-button">BROWSE</span>');
$this.after($mask);