Skip to content

Instantly share code, notes, and snippets.

View saucecode's full-sized avatar

Julian saucecode

  • New Zealand
View GitHub Profile
sleep 0.2;
scrot -q 90 -s /home/saucecode/tmp/shot.jpg
SHOT=/home/saucecode/tmp/shot.jpg
OUTPUT=$(curl --silent -sf -F "files[]=@$SHOT" "http://pomf.se/upload.php" | grep -Eo '"url":"[A-Za-z0-9]+.*",' | sed 's/"url":"//;s/",//')
echo http://a.pomf.se/$OUTPUT | xclip -selection "clipboard"
mplayer /home/saucecode/tmp/confirm.wav
# fourthgrademaths.py
import random, time
def start(question_count):
rightAnswers = 0
wrongAnswers = 0
startTime = time.time()
for i in range(question_count):
qtype = random.randint(0,3)
if qtype == 0: # addition
private boolean canSee(float x, float y) {
float delta = 0.1f;
float targetDistance = (float) Math.hypot(x-this.x, y-this.y);
float angle = (float) (game.calcAngle(this.x, this.y, x, y) - Math.PI/2f);
float dx = (float) Math.sin(angle) * delta;
float dy = (float) -Math.cos(angle) * delta;
float mx = this.x, my = this.y;
for(float distance=0; distance < targetDistance; distance+=delta){
var vapor = require('vapor');
var request = require('request');
var username = "[REDACTED]";
var password = "[REDACTED]";
var config = {
username: username,
password: password,
displayName: "[REDACTED]",
import urllib2, json, os, time
albumurl = raw_input('imgur album url: ')
foldername = albumurl.split('/')[-1].split('#')[0]
if not os.path.exists(foldername+'/'): os.mkdir(foldername+'/')
print 'downloading html...'
albumhtml = urllib2.urlopen(albumurl).read()
jdata = '{"count":'+albumhtml.split("{\"count\":")[1].split('\n')[0][:-1]
data = json.loads(jdata)
print 'going to download',len(data['items']),'images into folder:',foldername
@saucecode
saucecode / challenger_server.py
Created January 24, 2015 07:57
A proof of work challenge server that issues and checks POW challenges, keeping score
import socket, random, string, hashlib
'''
challenge request packet format
\x08[HASH] [START] [SEED]
sends a hash algorithm (SHA1, MD5, etc), what the hash must start with, and what the prehashed string must start with
challenge response packet format
\x09[FULL PRE-HASH]
The [FULL PRE-HASH] must start with [SEED] and when hashed with [HASH] algorithm, the result starts with [START]
0 0 7 0 0 0 2 2 2 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 2 2 2
0 0 7 0 0 0 2 2 2 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 2 2 2 0 0 0
2 2 2 0 0 0 0 0 0 0 0 0 2 2 2
@saucecode
saucecode / challenge248.c
Last active January 5, 2016 20:24
first working version
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define PI 3.14159265
// https://www.reddit.com/r/dailyprogrammer/comments/3zfajl/20160104_challenge_248_easy_draw_me_like_one_of/
struct rgb_t {
unsigned char r;
@saucecode
saucecode / challenge277.c
Created July 29, 2016 17:31
julia set generator for /r/dailyprogramming challenge 277 https://redd.it/4v5h3u
// challenge 277 hard 2016-07-29 /r/dailyprogrammer https://redd.it/4v5h3u
// compile: $ gcc -std=c99 challenge277.c -lm
// outputs to: fractal.tga
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <complex.h>
std::vector<projectile_t*> projectiles;
// ...
projectiles.erase(
std::remove_if(projectiles.begin(), projectiles.end(),
[](projectile_t *p){ return p->life <= 0.0; }),
projectiles.end()
);