Skip to content

Instantly share code, notes, and snippets.

@74togo
74togo / weights.py
Created July 16, 2015 17:45
Solution to weights problem
from math import log
def toList(num):
return toList(num // 3) + [["L"], ["-"], ["R"]][num % 3] if num else []
def solution(n):
return toList(n + sum(3**x for x in range(1 + int(log(n*2, 3)))))
@74togo
74togo / start_recording.sh
Created May 19, 2015 23:25
timelapse recorder
#!/bin/bash
a=1
compile_video()
{
trap exit SIGINT
# modify these as needed
FPS=15
@74togo
74togo / sub.py
Last active August 29, 2015 14:11
Testing listener model that is thread safe
from threading import Thread, Lock, Condition, get_ident, current_thread
from collections import deque, namedtuple
import time
cond = Condition()
lock = Lock()
ThreadSub = namedtuple("ThreadSub", ["queue", "callbacks"])
subscriptions = {"chat":{}, "file":{}}
@74togo
74togo / irc connection trick
Created January 26, 2014 19:49
A trick to autheticate on connection to an IRC server
A trick to autheticate on connection to an IRC server
/connect irc.freenode.net 6667 :<username> <password>
In xchat, this means you put :<username> <password> into the server password box.
@74togo
74togo / FloydSteinberg.html
Last active November 6, 2020 02:51
An example of the Floyd–Steinberg applied to images in Javascript.
<html>
<head>
<title>Dithering Test</title>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.getElementsByTagName("canvas")[0];
@74togo
74togo / 10fast.js
Created August 24, 2013 02:05
A cheat script for 10fastfingers
(function(){
/* Set up */
var input = jQuery("#inputfield");
var space_key = jQuery("#config_input_key").attr("value");
var chars_typed_so_far = 0;
/* Set this as desired */
var desired_WPM = 150;
@74togo
74togo / rainbow.js
Last active November 28, 2018 00:20
This rainbows a page. Use a bookmarklet if you want.
(function(){var m = "@-webkit-keyframes super-rainbow { 0% { -webkit-filter:hue-rotate(1deg); } 100% { -webkit-filter:hue-rotate(360deg); } } html { -webkit-animation: super-rainbow 2s linear infinite normal }";
var styletag = document.createElement("style");
styletag.textContent = m;
document.body.appendChild(styletag);
}());
@74togo
74togo / superselector$$$.js
Last active December 21, 2015 00:58
A super selector for jQuery
/*
Recursively searches the document, and the iframes within it for elements.
Usage: exactly like jQuery() or $()
*/
var $$$ = function(thing, doc) {
var res = $(thing, doc);
$("iframe", doc).each( function(){
res = res.add( $$$(thing, this.contentDocument) );
});
@74togo
74togo / ricerPS1
Last active December 20, 2015 17:28
put this in .bashrc or something
PS1=$'\n\[\e[1;32m\]\xe2\x94\x8c[ \[\e[1;37m\]\u\[\e[32m\]@\[\e[1;37m\]\h\[\e[32m\] ]\xe2\x94\x80\xe2\x94\x80( \[\e[37m\]\w\[\e[32m\] )\n\xe2\x94\x94\xe2\x94\x80[\[\e[0;31m\]>>> \[\e[0m\]'
@74togo
74togo / shooter.py
Created April 7, 2013 06:17
A little example of the aim-bot tracker thing I made. Uses pygame.
import pygame, sys, time, random, math
from pygame.locals import *
# this paragraph is just your standard pygame stuff
pygame.init()
screen_width = 640
screen_height = 480
screen = pygame.display.set_mode((screen_width, screen_height), RESIZABLE, 32)
pygame.display.set_caption("Shooter test")
screen.fill((0, 0, 0))