This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to open a confirm dialog before you leave the page, enter this into the browser console (or the javascript code) | |
window.onbeforeunload = function(e){ var e = e || window.event; var msg ="Don't leave!"; if(e){e.returnvalue = msg;} return msg; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get | |
function yay(a,b,c){ console.log(['yay', a, b, c]); } | |
function nay(a,b,c){ console.log(['nay', a, b, c]); } | |
$.get({url: 'http://foo.bar/spam?eggs=1', dataType:'jsonp'}).done( yay ).fail( nay ); | |
$.post("http://foo.bar/spam", {eggs: 1} ).done( yay ).fail( nay ); | |
var jqxhr = $.ajax( {url:"http://foo.bar/spam", data: {}, method: 'GET', dataType: 'jsonp'}).done( yay ).fail( nay ).always(function() { console.log( "always" ); }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Basic Python Cheat Sheet by Filip Kral on 2015/02/16""" | |
""" | |
Python is a cross-platform, interpreted, object-oriented programming language. | |
That means you can run it on Linux, Windows, Mac, and other platforms, | |
you don't need to compile your code to execute it because it is compiled on | |
the fly, and you can use classes and objects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to convert XML codes for Unicode can be translated to Unicode in Python | |
# This is useful for example when reading/writing from/to attribute tables in ArcGIS | |
import HTMLParser | |
parser = HTMLParser.HTMLParser() | |
unescaped = parser.unescape('Krinelnàch') | |
# To convert from Unicode to xml do: | |
escaped = u'Krineln\xe0ch'.encode('ascii', 'xmlcharrefreplace') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// self-executing oneliner to paste it to console | |
(function load_jQuery(){var jq = document.createElement('script'); jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; document.getElementsByTagName('head')[0].appendChild(jq); setTimeout(function(){ jQuery.noConflict(); console.log('jQuery should be available as jQuery now.'); }, 3000); })(); | |
// the above function in readable form | |
function load_jQuery(){ | |
// Load jQuery | |
// based on http://stackoverflow.com/questions/7474354/include-jquery-in-the-javascript-console | |
var jq = document.createElement('script'); | |
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub InsertSheetForEachSelectedCell() | |
'Insert a sheet for each cell in a selected range | |
'Each new sheet will be called prefix + cell value + suffix | |
'User is prompted to enter prefix and suffix when this macro is run | |
'Will fail miserably if sheet with that name already exists! | |
'Typical use case: select A1:A10 with values 1,2,3,...,10 then run this macro. | |
Dim prefix As String | |
Dim suffix As String | |
prefix = InputBox("Enter Sheet name prefix", "SheetPrefix", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://confluence.atlassian.com/display/STASH/Basic+Git+commands | |
# simplest example | |
git clone https://github.com/some/repo repo | |
cd repo | |
# make changes to files | |
git commit -a -m "Commit message" | |
# you can check status by `git status` | |
git push origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert between geojson and sp spatial objects in R | |
require(rgdal) | |
# https://stat.duke.edu/~cr173/Sta523_Fa14/spatial_data.html | |
s <- '{ "type": "MultiPolygon", "coordinates": [ | |
[ [[40, 40], [20, 45], [45, 30], [40, 40]] ], | |
[ [[20, 35], [10, 30], [10, 10], [30, 5], [45, 20], [20, 35]], | |
[[30, 20], [20, 15], [20, 25], [30, 20]] | |
] | |
]}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A trivial example for parallel computation using R snowfall package | |
require(snowfall) | |
sfInit(paralell=TRUE, cpus=2) | |
fn <- function(x){ | |
return(x*x) | |
} | |
d <- 1:1000 | |
result <- sfLapply(d, fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Minimal Leaflet</title> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> | |
<style> | |
#map{ | |
width: 150px; | |
height:250px; | |
} |
OlderNewer