Skip to content

Instantly share code, notes, and snippets.

@smcl
smcl / donut.cs
Created October 3, 2012 18:47
Donut.c in c# (sorry)
using System;namespace
donut.net{class Program{static
void Main(string[] args){double A=0
,B=0,i,j;var z=new double[7040];var b=
new char[1760];while(true){memset(b,' ',1760);
memset(z,0.0f, 7040);for(j=0;6.28>j;j+=0.07)for(
i=0;6.28>i;i+=0.02){double c = Math.Sin(i);double d
=Math.Cos(j);double e=Math.Sin(A);double f=Math.Sin(j);
double g=Math.Cos(A); double h=d+2;double D=1
/(c*h*e+f*g+5);double l=Math.Cos(i);double m=
@smcl
smcl / awkward.py
Created October 13, 2012 11:01
Share your private SMS messages with your friends/colleagues/family!
import android
import time
import random
droid = android.Android()
random.seed()
randSMS = random.choice(droid.smsGetMessages(False, 'inbox').result)
randContact = random.choice(droid.contactsGet().result)
@smcl
smcl / heyresh.c
Created January 1, 2013 20:27 — forked from anonymous/heyresh.c
#include<stdio.h>
int main(){
printf("Hello, Sean :)\n");
return 0;
}
@smcl
smcl / dcraw-sean.patch
Last active December 11, 2015 21:09
dcraw (http://www.cybercom.net/~dcoffin/dcraw/) patch to accept files received from stdin. More information at http://blog.mclemon.cz/dcraw-and-stdin
--- dcraw.c 2013-01-29 00:18:05.000000000 +0100
+++ dcraw.c 2013-01-29 00:17:54.000000000 +0100
@@ -9278,7 +9278,7 @@
}
if (use_camera_matrix < 0)
use_camera_matrix = use_camera_wb;
- if (arg == argc) {
+ if (arg == argc && !read_from_stdin) {
fprintf (stderr,_("No files to process.\n"));
return 1;
@smcl
smcl / earth.pde
Created April 1, 2013 18:05
Plot the earth in Processing.org using data from (http://download.geonames.org/export/dump/). Need to download cities1000.txt from the geonames.org site and add to the sketch.
class City {
String name;
int population;
color col;
float x;
float y;
float z;
City(String cityname, int pop, float lat, float lon) {
name = cityname;
@smcl
smcl / gpsspeedo.py
Created July 10, 2013 20:45
GPS Speedometer for Python/SL4A
import android
import math
import time
droid = android.Android()
droid.startLocating(5000, 30)
interval = 10
# earth radius = 6371km
rad = 6371
@smcl
smcl / gist:7387473
Last active December 27, 2015 20:49
xkcd 1287 page substitution bookmarklet
javascript:(function(){function replaceTextInPage(oldText,newText,node){replaceTextInPage2(combo1(oldText),combo1(newText));replaceTextInPage2(combo2(oldText),combo2(newText));replaceTextInPage2(combo3(oldText),combo3(newText));}function replaceTextInPage2(oldText,newText,node){node=node||document.body;var childs=node.childNodes,i=0;while(node=childs[i]){if(node.nodeType==3){if(node.textContent){node.textContent=node.textContent.replace(oldText,newText);}else{node.nodeValue=node.nodeValue.replace(oldText,newText);}}else{replaceTextInPage2(oldText,newText,node);}i++;}}function combo1(str){return str.toLowerCase();}function combo2(str){words=str.split(" ");for(var i=words.length-1;i>=0;i--){words[i][0]=words[i][0].toUpperCase();};return words.join(" ");}function combo3(str){return str.toUpperCase();}replaceTextInPage("witnesses","these dudes I know");replaceTextInPage("allegedly","kinda probably");replaceTextInPage("new study","tumblr post");replaceTextInPage("rebuild","avenge");replaceTextInPage("space","spaaa
$ cd path/to/openbsd/image
$ sudo diskutil list
<other hard drives, not important>
/dev/disk2 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *63.9 GB disk2
$ sudo diskutil unmountDisk /dev/rdisk2
Unmount of all volumes on disk2 was successful
$ sudo dd if=./miniroot-am335x-58.fs of=/dev/rdisk2 bs=1m
18+0 records in
$ ls /dev/tty.usbserial*
/dev/tty.usbserial-A402O00H
$ screen /dev/tty.usbserial-A402O00H 115200
$ su
Password:
# cd /usr/src
# ftp http://ftp.openbsd.org/pub/OpenBSD/5.8/ports.tar.gz
# tar -xzf /tmp/ports.tar.gz # this could take a wee while
# cd ports