Skip to content

Instantly share code, notes, and snippets.

View maxicecilia's full-sized avatar

Maximiliano Cecilia maxicecilia

  • Argentina, Tucuman, San Miguel de Tucuman
View GitHub Profile
@maxicecilia
maxicecilia / autocomplete_extra_query.js
Created April 4, 2014 01:48
Add an extra query string to Django Grappelli's autolookup fields.
// Add this file to your admin class throught class Media.
(function($) {
// Add the extra querystring to the autolookup field.
function update_lookup_querystring(obj_id) {
id = $("#" + obj_id).val();
$("[id^=lookup_id_linea_set-]").each(function( index ) {
var original_href = $(this).attr('href').split('&')[0];
$(this).attr('href', original_href + '&' + obj_id + '=' + id);
});
}
@maxicecilia
maxicecilia / urlParam.js
Created April 25, 2014 01:02
Simple method to recover parameter values from a URL
$.urlParam = function(href, name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(href);
return results[1] || 0;
};
@maxicecilia
maxicecilia / paginate.js
Created June 25, 2014 00:20
Quick and simple pagination script. I stole this somewhere... I don't remember where or to whom, so all the credit goes to Chuck Norris.
$.fn.pageMe = function (opts) {
var $this = this,
defaults = {
perPage: 7,
showPrevNext: false,
hidePageNumbers: false
},
settings = $.extend(defaults, opts);
var listElement = $this;
@maxicecilia
maxicecilia / bustcache.html
Created September 6, 2014 01:22
Simply script to avoid cache in js/css files using javascript only.
<script type="text/javascript" src="whatever.js"></script>
<script type="text/javascript">
(function(s){
s = s[s.length - 2];
s.src = s.src + '?bustcache=' + new Date().getTime();
})(document.getElementsByTagName('script'));
</script>
@maxicecilia
maxicecilia / memcached.txt
Created November 7, 2014 14:05
How to flush memcache & redis
$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
flush_all
OK
quit
Connection to localhost closed by foreign host.
@maxicecilia
maxicecilia / query.sql
Created December 19, 2014 20:56
Some Neo4j queries
-- Create a simple node
MERGE (actor:test_article { aid:"112"})
ON CREATE SET actor.created = timestamp(), actor.api = "api", actor.type = "test_article"
-- Create activities
MERGE (actor:test_user { aid:"110"})
ON CREATE SET actor.created = timestamp(), actor.api = "api", actor.type = "test_user"
ON MATCH SET actor.updated = timestamp()
# This was modified from the original version posted here:
#
# http://www.carthage.edu/webdev/?p=12
#
# ... retrieved around 1/12/2008.
#
# Modifications include:
#
# 1. Using a simple bind for auth instead of a search
# 2. Upping the default privileges for users
@maxicecilia
maxicecilia / login_ok
Last active August 29, 2015 14:27
Successful login using TLSv1
➜ ~ curl -X POST -d '{"username":"J5ycMY.4cDL7O@fakeuser.com", "password":"password1" }' -H 'Content-Type: application/json' https://mmdb-staging.nationalgeographic.com/api/v1/auth/login/ -i -c mmdbsessionid -v -1
* About to connect() to mmdb-staging.nationalgeographic.com port 443 (#0)
* Trying 74.217.81.189... connected
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
@maxicecilia
maxicecilia / 0_reuse_code.js
Created October 8, 2013 02:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@maxicecilia
maxicecilia / ipythonrc
Created April 22, 2014 18:38
default ipythonrc example
# -*- Mode: Shell-Script -*- Not really, but shows comments correctly
# $Id: ipythonrc,v 1.4 2003/05/16 06:53:42 fperez Exp $
#***************************************************************************
#
# Configuration file for IPython -- ipythonrc format
#
# The format of this file is simply one of 'key value' lines.
# Lines containing only whitespace at the beginning and then a # are ignored
# as comments. But comments can NOT be put on lines with data.