Skip to content

Instantly share code, notes, and snippets.

View gnrfan's full-sized avatar

Antonio Ognio gnrfan

View GitHub Profile
<?php
function url($name) {
$flipped_urlconf = array_flip($GLOBALS["CONFIG"]["URLCONF"]);
if (array_key_exists($name, $flipped_urlconf)) {
return $flipped_urlconf[$name];
}
}
?>
mysql> SET @checkin = '2013-07-28'; SET @checkout = '2013-08-01'; SELECT IF(DATE(@checkin)<>DATE(@checkout), DATEDIFF(LAST_DAY(@checkin), @checkin), DATEDIFF(@checkout,@checkin)) AS resultado;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
+-----------+
| resultado |
+-----------+
| 3 |
+-----------+
(function($, document) {
$(document).ready(function() {
// Habla chocherita, coloca tu código recién acá :)
});
})(jQuery, document);
@gnrfan
gnrfan / gist:4714963
Created February 5, 2013 14:58
My .gitignore file for Python/Django projects.
# Generic files
*~
*.lock
*.out
# OS specific files
.DS_Store
# Vim
.*.swp
.*.swo
@gnrfan
gnrfan / demos-vhost-example.conf
Created February 16, 2013 02:32
A piece of Apache configuration for creating a virtual host for demos and publishing a Django app in a sub folder.
<VirtualHost *:80>
ServerName demos.mydomain.com
DocumentRoot "/var/vhosts/mydomain.com/demos.mydomain.com/public"
DirectoryIndex index.php index.htm index.html
WSGIPassAuthorization On
<Directory "/var/vhosts/mydomain.com/demos.mydomain.com/public">
AllowOverride All
@gnrfan
gnrfan / django-app-vhost.conf
Created February 19, 2013 03:28
Example of Django app running at to root folder of a FQDN (Fully-Qualified Domain Name)
<VirtualHost *:80>
ServerName myapp.mydomain.com
DocumentRoot "/var/vhosts/mydomain.com/myapp.mydomain.com/public"
DirectoryIndex index.php index.htm index.html
WSGIPassAuthorization On
<Directory "/var/vhosts/mydomain.com/myapp.mydomain.com/public">
AllowOverride All
@gnrfan
gnrfan / vhost-example.conf
Created February 19, 2013 03:31
A simple static website virtual host configuration with Apache.
<VirtualHost *:80>
ServerName myapp.mydomain.com
DocumentRoot "/var/vhosts/mydomain.com/myapp.mydomain.com/public"
DirectoryIndex index.php index.htm index.html
<Directory "/var/vhosts/mydomain.com/myapp.mydomain.com/public">
AllowOverride All
</Directory>
@gnrfan
gnrfan / README.md
Last active December 15, 2015 07:49
A gevent demo making DNS queries both in a blocking and non-blocking way.

gevent demo

Non-blocking IO using co-routines in Python.

Installing gevent under OSX using MacPorts

sudo port install libevent

virtualenv --no-site-packages env

@gnrfan
gnrfan / ws_callback_redirector.php
Created March 27, 2013 00:36
You can upload this simple PHP script to a public server on the Internet and receive there callbacks from webservices like Facebook's Graph API and have it redirect the request to localhost or any other non-public URI.
<?php
define('APP_PREFIX', '/path/to/subfolder/if/any/');
define('REDIRECT_TARGET', 'http://localhost:8000/');
if (array_key_exists('redirect_target', $_REQUEST)) {
$redirect_base = $_REQUEST['redirect_target'];
} else {
$redirect_base = REDIRECT_TARGET;
}
@gnrfan
gnrfan / fsjumps.sh
Created August 19, 2013 08:18
Easily remember a directory and jump back to it from anywhere in the UNIX filesystem. This version is optimized for Mac OS X. Source: http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
### Filesystem jumping
### Usage: Just add a line to your ~/.bashrc or ~/.bash_profile with "source /path/to/fsjumps.sh".
export MARKPATH=$HOME/.marks
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}