Skip to content

Instantly share code, notes, and snippets.

View miceno's full-sized avatar

Orestes Sanchez miceno

  • Barcelona, Spain
View GitHub Profile
@miceno
miceno / disable-zoom-gmaps.css
Created August 29, 2015 11:14
Disable scroll wheel zoom on Google Maps iframes.
.google-maps-responsive {
position: relative;
padding-bottom: 75%; // This is the aspect ratio
height: 0;
overflow: hidden;
}
.google-maps-responsive iframe {
position: absolute;
top: 0;
@miceno
miceno / fiddle.response.json
Last active August 29, 2015 14:22
JSON taxonomy
[
{
"name": "SERES VIVOS",
"id": "192",
"photo": "http://www.antcontroldeplagas.es/wp-content/uploads/2013/02/hormigas-head.jpg",
"d": "Las hormigas son bonitas",
"children": [
{
"name": "ANIMALES",
"id": "193",
@miceno
miceno / webserver.sh
Last active August 29, 2015 14:21
Python’s built-in web server
#For example, you can run Python’s built-in server:
python -m SimpleHTTPServer 8888 &
@miceno
miceno / enum-sample.py
Last active August 29, 2015 14:10
Enumeration in python
>>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
>>> Status.open, Status.pending, Status.closed
(0, 1, 2)
>>> class Status:
open, pending, closed = range(3)
>>> Status.open, Status.pending, Status.closed
(0, 1, 2)
@miceno
miceno / return-dictionary-aggregated-query
Created September 12, 2014 00:18
A dictionary from a list of tuples
# List of selected categories
selected_categories = [Category.objects.get(name="TERRESTRE"), Category.objects.get(name="MOLUSCOS")]
# Products we want to filter based on the list of selected categories
products = Product.objects.filter(category__in = selected_categories)
# list is a tuple of tuples like ((id1, product_count1), (id2, product_count2), ... , (idn, product_countn))
qs_count = Category.objects.values(‘id’).filter(product__in=products).annotate(Count('product'))
# Get the values
@miceno
miceno / gist:1542202
Created December 31, 2011 00:31
How to create a project in GitHub
Global setup:
Set up git
git config --global user.name "Orestes Sanchez"
git config --global user.email orestes@acm.org
Next steps:
mkdir Drupal7-for-Arxiu-Hist-ric-del-Poblenou
cd Drupal7-for-Arxiu-Hist-ric-del-Poblenou
git init
touch README
@miceno
miceno / ellipsis.js
Created September 3, 2011 01:12
Ellipsis mediante JavaScript
var ellipsisId= 'ellipsis_test_element';
var ellipsisElement= null;
function insertEllipsisElement(){
if( !ellipsisElement){
ellipsisElement= document.createElement( 'div');
ellipsisElement.id= ellipsisId;
document.body.appendChild( ellipsisElement);
}
}
@miceno
miceno / gist:841964
Created February 24, 2011 09:32
Crawl with wget
wget --spider -r -l0 -np -k http://www.yoursite.com/
@miceno
miceno / gist:838854
Created February 22, 2011 15:43
convert String to List
data= '[ "mykey": "myValue" ]'
map = Eval.me( data )
// map= {myKey=myValue}
@miceno
miceno / gist:824596
Created February 13, 2011 11:12
Groovy testing
class MyClass{
def myname
}
class TestCase{
TestCase(){ }
def testNonEmptyTask(){
def f = new MyClass()