Skip to content

Instantly share code, notes, and snippets.

@allanortiz
allanortiz / LICENCE SUBLIME TEXT
Created September 27, 2018 15:11
Sublime Text 3 Serial key build is 3176
## Sublime Text 3 Serial key build is 3176
> * Added these lines into /etc/hosts
127.0.0.1 www.sublimetext.com
127.0.0.1 license.sublimehq.com
> * Used the license key
----- BEGIN LICENSE -----
@allanortiz
allanortiz / git-tag-delete-local-and-remote.sh
Created July 19, 2017 17:32 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
En Linux, es necesario instalar la libreria pybarcode desde pip:
pip install pyBarcode
En este código se muestra como crear codigo de barras ean13, isbn13 y code39
"""
@allanortiz
allanortiz / decorating-git-log.txt
Created January 9, 2017 17:08
Decorating git log
git config --global alias.superlog "log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
@allanortiz
allanortiz / number-with-comma-separator.txt
Last active June 24, 2016 04:27
number-with-comma-separator
var numberWithCommas = function(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
//setup before functions
var typingTimer; //timer identifier
var doneTypingInterval = 5000; //time in ms, 5 second for example
var $input = $('#myInput');
//on keyup, start the countdown
$input.on('keyup', function () {
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
@allanortiz
allanortiz / ajax-download-file.js
Created April 11, 2016 20:43
Download file (PDF) with AJAX.
function downloadFile() {
var blob = "";
var xhr = new XMLHttpRequest();
xhr.onload = function(){
if (this.status == 200) {
blob = new Blob([xhr.response], { type: 'application/pdf' });
var link = document.createElement('a');
@allanortiz
allanortiz / apache-modrewrite-active.php
Last active December 30, 2015 18:33
Verify if apache mod_rewrite is active.
<?php
if( ! function_exists('apache_get_modules')){
phpinfo();
exit;
}
$res = 'Module Unavailable';
if(in_array('mod_rewrite',apache_get_modules())){
$res = 'Module Available';
<?php
/**
* Sanitiza los HTML retirando script tags del codigo
* @param $html string cadena HTML a sanitizar
* @return string retorna cadena sanitizada
*/
public static function sanitize_html($html){
$dom = new DOMDocument();
$dom->loadHTML($html);
$script = $dom->getElementsByTagName('script');
@allanortiz
allanortiz / header-cross-origin.php
Last active December 30, 2015 18:34
Header cross origin.
<?php
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
?>