Skip to content

Instantly share code, notes, and snippets.

View mishudark's full-sized avatar
:octocat:
Rocking

mishudark mishudark

:octocat:
Rocking
View GitHub Profile
<?php
function laboral_days($start, $end, $nowork = array('sun', 'sat'), $festives = array()){
$days = array('sat' => 5, 'sun' => 6);
$time_start = strtotime($start);
$time_end = strtotime($end);
$day_init = date('w', $time_start);
$day_end = date('w', $time_end);
$total_days = ($time_end - $time_start) / (60 * 60 * 24) + 1;
$weeks = floor($total_days / 7);
@mishudark
mishudark / size.sql
Created April 3, 2013 16:37
tamaño tablas
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema =
TIME=10
for ID in $( mysql information_schema -e "SELECT ID FROM processlist WHERE INFO REGEXP '^[Ss][Ee][Ll][Ee][Cc][Tt]' AND TIME >= ${TIME};" )
do
echo -n "Killing thread ${ID}..."
mysqladmin kill ${ID}
echo " Done"
done
# Where to put virtualenvs?
virtualenv_basedir="/home/vagrant/sites/virtualenvs"
# Where to put project dirs?
project_basedir="/home/vagrant/sites/projects"
# Comma seperated list of dirs where Chuck should look for modules.
# . will be replaced with the Django Chuck modules dir
module_basedirs = ["."]
@mishudark
mishudark / django_url.py
Created October 6, 2012 17:54
Django Dynamic Urls
# urls.py
urlpatterns += patterns('',
(r'^(?P<page_alias>.+?)/$', 'views.static_page'),
)
# views.py
def static_page(request, page_alias): # page_alias holds the part of the url
try:
active = Page.objects.get(page_alias=page_alias)
except Page.DoesNotExist:
@mishudark
mishudark / php_64.sh
Created August 27, 2012 04:13
PHP under 64 bits
--with-libdir=/lib/x86_64-linux-gnu
@mishudark
mishudark / elastic_php_api.php
Created August 18, 2012 17:53
elasticSearch PHP
<?php
// http://www.elasticsearch.com/docs/elasticsearch/rest_api/
class ElasticSearch {
public $index;
function __construct($server = 'http://localhost:9200'){
$this->server = $server;
}
@mishudark
mishudark / jcarrucellite.js
Created July 23, 2012 18:21
jcarrucellite FIXED
(function($) {
$.fn.jCarouselLite = function(o) {
o = $.extend({
btnPrev: null,
btnNext: null,
btnGo: null,
mouseWheel: false,
auto: null,
speed: 200,
@mishudark
mishudark / indextank_compile.sh
Created July 21, 2012 06:11
IndexTank mvn line compile
mvn -Dmaven.test.skip=true compile package assembly:single
@mishudark
mishudark / shortener.js
Created July 20, 2012 03:06
Shortener
var letras = [0,1,2,3,4,5,6,7,8,9,'A','a','B','b','C','c','D','d','E','e','F','f','G','g','H','h','I','i','J','j','K','k','L','l','M','m','N','n','O','o','P','p','Q','q','R','r','S','s','T','t','U','u','V','v','W','w','X','x','Y','y','Z','z'];
function encode_shortener(num){
var t = letras.length;
var shorten = '';
while(num > 0){
var div = Math.floor(num / t);
var res = num - div * t;