Skip to content

Instantly share code, notes, and snippets.

View nrrb's full-sized avatar
💗

Nicholas Bennett nrrb

💗
View GitHub Profile
@nrrb
nrrb / mandelbrot.py
Last active June 3, 2024 17:28
Render the Mandelbrot Set in text mode! O frabjous day!
def draw_fractal(n_columns=40, n_rows=20,
min_real=-1.5, min_imag=-1.0, max_real=1.0, max_imag=1.0,
max_iterations=200, render_chars = 'abcdefghijklmnopqrstuvw '):
'''
This renders a Mandelbrot set fractal in text mode.
http://en.wikipedia.org/wiki/Mandelbrot_set
Defaults:
def draw_fractal(n_columns=80, n_rows=40,
@nrrb
nrrb / kjobmatcher.py
Created September 13, 2012 19:50
Uses Munkres algorithm to create teams of students in a class with optimal satisfaction of students
#!/usr/bin/env python
#
import os
import urllib
import csv
import sys
import re
from google.appengine.ext import blobstore
@nrrb
nrrb / sirdspos.asm
Created September 13, 2012 23:37
A SIRDS (think Magic Eye) depicting the characters " #asm" diagonally from top-left to bottom-right, using random color pixels in 320x200 resolution
; SIRDS Piece Of Shiite
; by danslemur (nick@jtan.com)
; 5/18/2003
; for EFnet #asm compo 7 - Make a 256 byte intro for 386/486 class PC's
;
; I got bored and didn't fill in the whole 256 bytes. It's 185 bytes now. Eh!
;
; Thanks to:
; - Razzia for his helpful size optimization post on www.movnet.org/forum,
; - matja for showing me a better way to write a 4x4 block to the buffer,
@nrrb
nrrb / index.html
Created September 16, 2012 01:46 — forked from MoritzStefaner/.block
Force-based label placement
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta charset="utf-8">
<title>Force based label placement</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.6.0"></script>
</head>
<body>
This file has been truncated, but you can view the full file.
{
"nodes": [
{
"name": "http://vivo.cornell.edu/individual/AI-ICAR-0203DF692AC00007436"
},
{
"name": "http://vivo.cornell.edu/individual/AI-ICAR-0203DF692AC000088DF"
},
{
"name": "http://vivo.cornell.edu/individual/AI-ICAR-0203DF692AC000050FB"
@nrrb
nrrb / gist:4056175
Created November 11, 2012 20:31
Variable Speed Stopwatch
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
// How often the stopwatch is actually updated
Stopwatch.interval_ms = 200;
function Stopwatch(time_offset, ratio_to_realtime, display_increment_ms, display_function) {
this.start_time = (new Date()).getTime();
if(time_offset) {
this.start_time -= time_offset;
@nrrb
nrrb / gist:4069099
Created November 13, 2012 23:21
Deduplicating Skype Chat Logs
import csv
import os
import glob
import re
from collections import defaultdict as dd
src_path = "C:\\Users\\Nick\\Dropbox\\MTS Relational Event Network Modeling\\MTS Data\\NU Newest Chatlogs"
# Read in all data from all the files and index it in a data structure by session,
# sender, receiver, and the message. This will aid in finding the duplicates later.
@nrrb
nrrb / gist:4084590
Created November 16, 2012 05:56
counting unique timestamps in skype chatlogs
import csv
import os
import glob
src_path = 'C:\\Users\\Nick\\Dropbox\\MTS Relational Event Network Modeling\\MTS Data\\NU Newest Chatlogs\\Deduplicated Logs By Phase'
for filename in glob.glob(os.path.join(src_path, "*.txt")):
with open(filename, 'rb') as f:
rows = list(csv.reader(f, delimiter='\t'))
event_count = len(rows)
@nrrb
nrrb / index.html
Created November 25, 2012 05:54 — forked from MoritzStefaner/.block
Force-based label placement
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta charset="utf-8">
<title>Force based label placement</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.6.0"></script>
</head>
<body>
@nrrb
nrrb / reformat_qualtrics.py
Created November 26, 2012 20:32
Reformat Qualtrics output to an edgelist suitable for use with UCINET
import csv
with open('c:/users/nick/downloads/Shalinee_Survey_for_Kineo.csv', 'rb') as f:
rows = list(csv.DictReader(f))
responses = []
# Skipping the first row, it's effectively the key from column headers to
# question text
for row in rows[1:]:
# V5 is the heading for the column containing the email address