Skip to content

Instantly share code, notes, and snippets.

View topicus's full-sized avatar

Mariano Carballal topicus

View GitHub Profile
@topicus
topicus / gist:b2e0139454f585ac6d75
Created December 14, 2014 00:23
IIFE Under de hood
function hola(){
console.log('hola');
}
hola();
// mycoolscript.js
var hola = 'hola';
console.log(window.hola); //prints 'hola'
// myapp.js
var hola = 'mundo';
console.log(window.hola); //prints 'mundo'
//mycoolscript.js line:655
console.log(hola.split('')); //prints ["m", "u", "n", "d", "o"] instead ["h", "o", "l", "a"]
console.log(hola());
function hola(){
return 'hola';
}
function hola(){
return 'hola';
}
console.log(hola());
console.log(hola);
var hola = 'hola';
var hola;
console.log(hola) // prints 'undefined'
hola = 'hola';
function hola(){
var myvar = 'hola';
console.log('1.' + myvar); //prints '1. hola'
function mundo(){
console.log('2.' + myvar); //prints '2. hola'
}
mundo();
}
hola()
// throws an error: Uncaught ReferenceError: myvar is not defined
{id: 0, date: '2011-01-01', x: 1, y: 2, z: 1, country: 'DE', title: 'first', lat:52.56, lon:13.40},
{id: 1, date: '2011-02-02', x: 2, y: 4, z: 1, country: 'UK', title: 'second', lat:54.97, lon:-1.60},
{id: 2, date: '2011-03-03', x: 3, y: 6, z: 1, country: 'US', title: 'third', lat:40.00, lon:-75.5},
{id: 3, date: '2011-04-04', x: 4, y: 8, z: 2, country: 'DE', title: 'fourth', lat:57.27, lon:-6.20},
{id: 4, date: '2011-05-04', x: 5, y: 10, z: 2, country: 'UK', title: 'fifth', lat:51.58, lon:0},
{id: 6, date: '2011-06-02', x: 6, y: 24, z: 2, country: 'US', title: 'sixth', lat:51.04, lon:7.9},
{id: 6, date: '2011-06-02', x: 6, y: 24, z: 2, country: 'UB', title: 'sixth', lat:51.04, lon:7.9},
{id: 6, date: '2011-06-02', x: 6, y: 24, z: 2, country: 'UC', title: 'sixth', lat:51.04, lon:7.9},
{id: 6, date: '2011-06-02', x: 6, y: 24, z: 2, country: 'UD', title: 'sixth', lat:51.04, lon:7.9},
{id: 6, date: '2011-06-02', x: 6, y: 24, z: 2, country: 'UE', title: 'sixth', lat:51.04, lon:7.9},
@topicus
topicus / httpd-vhosts.conf
Created February 16, 2015 15:02
Drupal simple virtual host
<VirtualHost *:80>
DocumentRoot "path_to_drupal"
ServerName dkan
ErrorLog "/private/var/log/apache2/any_log_file_name"
<Directory "path_to_drupalt">
Options Includes FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.1
@topicus
topicus / unify_endings.py
Created March 23, 2015 16:21
Unify line endings
#! /usr/bin/python
import csv
import sys
import re
types = {
'windows': '\r\n',
'mac': '\r',