Skip to content

Instantly share code, notes, and snippets.

import socket
sock = socket.socket(socket.AF_INET, socket.TCP_NODELAY)
sock.connect(('irc.synirc.net', 6667))
sock.setblocking(0)
def irc_connect():
buff = ''
while 1:
try:
import math
import random
import functools
import sys
# an inefficient ga for the travelling salesman problem
# stuff to think about:
# chromosomes can't be repeated, so crossover and mutation have to be changed
# mutation: swap two elements
# crossover: use ordered crossover
import json
import urllib2
import time
import sys
import lxml.html
from datetime import datetime, timedelta
# get viewers
j = json.load(urllib2.urlopen('https://api.twitch.tv/kraken/streams/speeddemosarchivesda'))
import ctypes, ctypes.wintypes
xinputDLL = ctypes.windll.xinput9_1_0
class XINPUT_VIBRATE(ctypes.Structure):
_fields_ = [
('left_motor', ctypes.wintypes.WORD),
('right_motor', ctypes.wintypes.WORD),
]
class IRCStats(object):
def __init__(self, path):
self.path = path
try:
self.users = json.loads(open(self.path, 'r').read())
except Exception, e:
self.users = {}
# JSON makes defaultdict weird, roll yer own
def add(self, nick):
@Alligator
Alligator / gist:3960707
Created October 26, 2012 18:56
jsweekly bingo
JSWEEKLY BINGO
+-------------------------------+-------------------------------+-------------------------------+
| An atricle from someone who | | |
| just figured out | Baby's first functional | How to do this one very |
| prototype-based OO and thinks | programming | specific thing in Node.js |
| everyone else needs telling | | |
+-------------------------------+-------------------------------+-------------------------------+
| | | |
| A new jQuery release | A job in San Francisco | An introduction to an MVC |
| | | framework |
import webapp2
import jinja2
import os
import random
import pprint
import math
from google.appengine.ext import db
jinja = jinja2.Environment(
PFont font;
int drawn;
PVector pos, dir, plane;
boolean DEBUG;
float moveSpeed = 0.1;
float rotSpeed = 0.07;
int scale = 4;
final int m_WIDTH = 24;
final int m_HEIGHT = 24;
int m_map[][] = {
@Alligator
Alligator / index.html
Created September 2, 2012 18:55
angular dot js
<!DOCTYPE HTML>
<html lang="en" ng-app="notes">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="static/reset.css" />
<style type="text/css">
html, body, .content {
height: 100%;
@Alligator
Alligator / really.cs
Created May 27, 2012 11:13 — forked from anonymous/really.cs
really?
if(i==1)
return 4;
if(i==2)
return 4;
if(i==3)
return 4;
if(i==4)
return 4;
if(i==5)
return 4;