As configured in my dotfiles.
start new:
tmux
start new with session name:
| from django.core.cache import cache | |
| from django.http import HttpResponseForbidden | |
| from functools import wraps | |
| from django.utils.decorators import available_attrs | |
| def ratelimit(limit=10,length=86400): | |
| """ The length is in seconds and defaults to a day""" | |
| def decorator(func): | |
| def inner(request, *args, **kwargs): | |
| ip_hash = str(hash(request.META['REMOTE_ADDR'])) |
As configured in my dotfiles.
start new:
tmux
start new with session name:
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Leaflet</title> | |
| <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.css" /> | |
| <script src="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.js"></script> | |
| <script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script> | |
| <script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script> | |
| </head> | |
| <body> |
| # -*- coding: utf-8 -*- | |
| """ | |
| Go to Google Bookmarks: https://www.google.com/bookmarks/ | |
| On the bottom left, click "Export bookmarks": https://www.google.com/bookmarks/bookmarks.html?hl=en | |
| After downloading the html file, run this script on it to generate a KML. | |
| """ |
| function computeSunrise(day, sunrise) { | |
| /*Sunrise/Sunset Algorithm taken from | |
| http://williams.best.vwh.net/sunrise_sunset_algorithm.htm | |
| inputs: | |
| day = day of the year | |
| sunrise = true for sunrise, false for sunset | |
| output: | |
| time of sunrise/sunset in hours */ |
| #!/usr/bin/env python | |
| import os, sys | |
| sys.path.append(os.getcwd()) | |
| import logging | |
| import rq | |
| MAX_FAILURES = 3 |
| // (…) | |
| var childProcess; | |
| try { | |
| childProcess = require("child_process"); | |
| } catch (e) { | |
| this.log(e, "error"); | |
| } | |
| if (childProcess) { | |
| childProcess.execFile("/bin/bash", ["mycommand.sh", args1, args2, args3], null, function (err, stdout, stderr) { | |
| this.log("execFileSTDOUT:", JSON.stringify(stdout), 'debug'); |
There are a bunch of reasons why this is convoluted, mostly in building the URL to make the request:
info_format parameter in the request. We don't know a priori which will be supported by a WMS that we might make a request to. See Geoserver's docs for what formats are available from Geoserver. That won't be the same from WMS to WMS, however.| # http://ruby-doc.org/stdlib-2.0.0/libdoc/open-uri/rdoc/OpenURI.html | |
| require 'open-uri' | |
| # https://github.com/flori/json | |
| require 'json' | |
| # http://stackoverflow.com/questions/9008847/what-is-difference-between-p-and-pp | |
| require 'pp' | |
| # Construct the URL we'll be calling | |
| request_uri = 'http://localhost:3000/users.json' | |
| request_query = '' |