Skip to content

Instantly share code, notes, and snippets.

@joshmarinacci
joshmarinacci / 1.html
Last active February 20, 2021 14:54 — forked from stephenlb/1.html
Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
Chat Output
<div id=box></div>
<script src=https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.11.min.js></script>
<script>(function(){
var pubnub = new PubNub({ publishKey : 'demo', subscribeKey : 'demo' });
function $(id) { return document.getElementById(id); }
@kleinmatic
kleinmatic / propubnerd-gists.md
Created March 26, 2012 16:03
ProPubNerd Gists

Open Source code doesn’t always come in big complex packages. At ProPublica we sometimes share small, simple snippets of using GitHub "Gists." These Gists range from single-byte file delimiters to an entire JavaScript framework for making stepper graphics. They rarely have documentation and don’t even always have names, but they can be super-useful. Here are some we’ve shared over the past few years:

@jakedobkin
jakedobkin / gist:1482724
Created December 15, 2011 20:26
Euler 54- Poker Hand Grader
# arrays for grading hands
numbers = ["2","3","4","5","6","7","8","9","T","J","Q","K","A"]
plays = ["0P","1P","2P","3K","4$","5F","6F","7F","8F","9F"]
# some functions we'll use- the basic approach for the grade function
# is to give each hand a string grade- when sorted, the better hand should come out on top
def l2n(letter):
index = numbers.index(letter)+2
@jakedobkin
jakedobkin / gist:1453787
Created December 9, 2011 23:21
Euler 47- modified sieve method in python
# set up 2 sieves- one is erastosthenes, the other is to track count
n=200000
myPrimes = [True]*(n+1)
myCount = [0]*(n+1)
# sieve, but count each time each composite number is hit during sieve
for i in range (2,n):
if myPrimes[i] == True:
j = 2*i
while j<=n:
@jakedobkin
jakedobkin / gist:1421545
Created December 2, 2011 03:06
Euler 28
#!/usr/local/bin/node
/* this is the pattern formed by the diagonals
ring 2 -- 2+ ([+1] + 3 + [+2] + 5 + [+2] + 7 + [+2])+ 9
ring 3 -- 10+([+3] + 13 + [+4] + 17 + [+4] + 21 + [+4])+25
where the numbers in brackets increase by 2 each time
how many rings? well ring 1 is a 1x1
and then every ring after adds 2 columns or rows
so by ring 2 you have 3 rows and 3 columns
@jakedobkin
jakedobkin / gist:1380694
Created November 20, 2011 18:55
Euler 18
#!/usr/local/bin/node
// put the text string into an array
triangle = new Array ();
triangle[0] = [75]
triangle[1] = [95,64]
triangle[2] = [17,47,82]
triangle[3] = [18,35,87,10]
triangle[4] = [20,04,82,47,65]
@jakedobkin
jakedobkin / euler2a.html
Created November 10, 2011 19:35
Euler Problem 2a
<html>
<body>
<script type="text/javascript">
a = 1;
b = 1;
c = 0;
d = 0;
for (i=0;i<=30;i++)
# credit: http://news.ycombinator.com/item?id=1543915
# in ipythonrc:
# execfile copy_and_paste.py
def copy(data):
from subprocess import Popen, PIPE
Popen(["xclip", "-selection", "clipboard"], stdin=PIPE).communicate(str(data))
def paste():
@btrott
btrott / gist:362805
Created April 11, 2010 15:14
Sample code for using WWW::TypePad::CmdLine
#!/usr/bin/perl -w
use strict;
use IO::Prompt;
use WWW::TypePad::CmdLine;
my $tp = WWW::TypePad::CmdLine->initialize( requires_auth => 1 );
# Fetch the list of the authenticated user's blogs, then put up a prompt
# asking the user to choose a blog.