Skip to content

Instantly share code, notes, and snippets.

@paulusm
paulusm / ipython.conf
Created January 19, 2013 21:22
Upstart conf for iPython web
start on runlevel [2345]
stop on runlevel [016]
respawn
setuid <user>
chdir /home/<user>/ipython_notebooks
exec ipython notebook --pylab --profile=nbserver --ipython-dir=/home/<user>/.ipython --log-level=DEBUG
@paulusm
paulusm / client.html
Last active December 14, 2015 04:59
JSON demo
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML5 Template</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<style>
#output div{display:none;}
</style>
</head>
@paulusm
paulusm / batman.xml
Last active December 28, 2015 14:29
Batman XML
<Movies>
<Movie><Title>Batman</Title><Year>1966</Year></Movie>
<Movie><Title>Batman</Title><Year>1989</Year></Movie>
<Movie><Title>Batman Returns</Title><Year>1992</Year></Movie>
<Movie><Title>Batman Forever</Title><Year>1995</Year></Movie>
<Movie><Title>Batman &amp;amp; Robin</Title><Year>1997</Year></Movie>
<Movie><Title>Batman Begins</Title><Year>2005</Year></Movie>
<Movie><Title>Batman: The Dark Knight</Title><Year>2008</Year></Movie>
<Movie><Title>Batman: The Dark Knight Rises</Title><Year>2012</Year></Movie>
</Movies>
@paulusm
paulusm / gist:7913949
Created December 11, 2013 16:42
VimRC on Windows 8
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set keymodel-=stopsel
set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
@paulusm
paulusm / gist:8578438
Last active January 4, 2016 05:59
Fusion table layer maps example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<!--Calling in the api code with your own key -->
body{
font-family:helvetica;
}
<?php
// Read in the existing comments
$contents = utf8_encode(file_get_contents("comments.json"));
// Convert from JSON format to an Array
$commentrecords = json_decode($contents, true);
//Add a new array item for the newly posted comment
$commentrecords[] = array("name" => strip_tags($_POST["name"]), "comment" => strip_tags($_POST["comment"]));
<?php
//open the file and decode the JSON into an Array
$contents = utf8_encode(file_get_contents("comments.json"));
$commentrecords = json_decode($contents, true);
//If we have comments, loop trhough them and create HTML list items for each
if($commentrecords){
foreach($commentrecords as $commentrecord){
echo "<li>" .$commentrecord["comment"] ;
echo "<br><strong>" . $commentrecord["name"] . "</strong></li>";
@paulusm
paulusm / widgets.html
Last active August 29, 2015 13:57
Twitter widget + external feed
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Widget Demos</title>
<style>
.twitter-timeline{float:left;}
#feed{float:left;margin-left:20px;width:45%;}
li, h2{font-family:helvetica;}
</style>
@paulusm
paulusm / bufferpost.py
Last active August 29, 2015 14:14
Post output from Crowdcrafting to Buffer App
###
# Function to post a single tweet to Buffer as a scheduled post
###
import requests
import iso8601
from dateutil.relativedelta import relativedelta
def bufferpost(tweetText, tweetDate):