Skip to content

Instantly share code, notes, and snippets.

View ikarius6's full-sized avatar

Mr.Jack ikarius6

  • México
View GitHub Profile
@ikarius6
ikarius6 / entuhogar.dev.conf
Created February 12, 2016 19:35
Vhost example Nginx, CI on subfolder and pretty URLs
################################################################################
####################
### Virtual Host for entuhogar.dev subdomain
################################################################################
####################
server {
listen *:80;
server_name entuhogar.dev
### Front public folder
@ikarius6
ikarius6 / colors.html
Last active February 11, 2016 17:57
Color percentage-based generator
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>
/*
Color percentage-based generator - by Jack
https://jsfiddle.net/xjmjjvdf/1/
*/
function percentage_to_color( perc ){ //0 = red, 100 = green
var mod = perc%101; // 0 > perc <= 100
var v = Math.floor( mod * 5.1 );
var r = ("00"+(v>255? 255-(v%256): 255).toString(16)).slice(-2);
@ikarius6
ikarius6 / rfc.php
Last active February 5, 2016 20:27
Registro Federal de Contribuyentes (RFC) regex PHP
<?php
/*
RFC Regex by Jack
Valid:
JACK880229AA1
JACK880229
Invalid:
JACK880230AA1
JACK890229AA1
@ikarius6
ikarius6 / Test.php
Created February 2, 2016 23:46
CI Auth Basic
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//application/controllers/Test.php
class Test extends MY_Controller {
private $username = 'admin';
private $salt = 'immaveryveryveryverylongsalt';
private $password = 'c25c068f620bae40f6de49aa32bc7a036989baae382f64d7cc41f89a741ff6ae'; //supersecret
function __construct(){
parent::__construct();
<?php
/* PHP Headers for CSV File with UTF-8 - By MrJack*/
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=reporte_ganadores_".date("d-m-Y").".csv");
header("Pragma: no-cache");
header("Expires: 0");
echo "\xEF\xBB\xBF"; //<--- here is the magic
echo "WHATÉVER";
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
<?php
/* Regex generator for valid TLDs - By MrJack*/
$txt = file_get_contents('http://data.iana.org/TLD/tlds-alpha-by-domain.txt');
$tlds = preg_split('/\s+/', $txt);
$valid_tld = array();
foreach($tlds as $tld){
if (! preg_match('/[^a-z]+/i', $tld, $matches)){
if(strlen($tld) > 3){
array_push($valid_tld, strtolower($tld));
}
<?php
/*
AES256 v1.0 MrJack
https://gist.github.com/1077723/0a9a7c5299a7fb4340e4b2064fd383ef236a5aa5
https://gist.github.com/RiANOl/1077723
*/
function aes256Encrypt($key, $data, $mode = MCRYPT_MODE_CBC) {
if(32 !== strlen($key)) $key = hash('SHA256', $key, true);
$padding = 16 - (strlen($data) % 16);