Skip to content

Instantly share code, notes, and snippets.

View dekz's full-sized avatar
🐢
⠚⠁⠉⠕⠃

Jacob Evans dekz

🐢
⠚⠁⠉⠕⠃
View GitHub Profile
def pos_tracker(self, t_speed, r_speed):
delta_th = r_speed*12
self.theta = self.theta + delta_th
theta_rad = (self.theta * math.pi)/180 #convert to radians
delta_r = t_speed*math.cos(delta_th) #change in rotation
delta_x = delta_r * math.cos(theta_rad) #change in x
delta_y = delta_r * math.sin(theta_rad) #change in y
private void setPropertyOfObject(Object obj, String propname, String text)
{
if (obj == null) return;
Class<?> cl = obj.getClass();
try {
BeanInfo info = Introspector.getBeanInfo(cl);
for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
if (pd.getName().equals(propname))
{
//Medium files - write 9000000 bytes
bm.bench(new Runnable() {
public void run() {
try {
InputStream in = new BufferedInputStream(new FileInputStream("test"));
OutputStream out = new BufferedOutputStream(new FileOutputStream("out"));
int i;
byte[] buffer = new byte[1024];
while ((i = in.read(buffer, 0, 1024)) != -1) {
@dekz
dekz / weirdcrypto.js
Created February 10, 2011 11:25
weird output of crypto module in node
var fs=require('fs'), c=require('crypto'), assert=require('assert');
var h = c.createHash('SHA256');
h.update('12345');
h.update('54321');
var key=h.digest('base64');
var enc = c.createCipher('AES-128-CBC', key);
var a=enc.update('12345678901234567890', 'utf8', 'base64');
var cipherText = enc.final('base64');
@dekz
dekz / google api
Created May 12, 2011 04:16
google api
clientID = ''
clientSecret = ''
redirectURI = 'urn:ietf:wg:oauth:2.0:oob'
code = ''
https = require 'https'
http = require 'http'
querystring = require 'querystring'
getRefreshToken = ->
@dekz
dekz / google auth
Created May 12, 2011 08:09
google auth
https = require 'https'
http = require 'http'
querystring = require 'querystring'
fs = require 'fs'
settings = {
clientID : '.apps.googleusercontent.com',
clientSecret : '',
redirectURI : 'urn:ietf:wg:oauth:2.0:oob',
code : '',
@dekz
dekz / osx-spaces-anim
Created June 8, 2011 22:58
OSX Spaces Animation
#Off
defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES && killall Dock
#on
defaults write com.apple.dock workspaces-swoosh-animation-off && killall Dock
@dekz
dekz / RamFS
Created June 8, 2011 23:00
RamFS for /private/tmp
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
RAMDisk() {
mntpt=$1
rdsize=$(($2*1024*1024/512))
echo "Creating RamFS for $mntpt"
# Create the RAM disk.
dev=`hdik -drivekey system-image=yes -nomount ram://$rdsize`
# Successfull creation…
@dekz
dekz / ichat-growl.scpt
Created February 18, 2012 02:14 — forked from markkendall/ichat-growl.scpt
iChat / Messages integration for Growl 1.3
-- growl notifications for iChat, based on
-- http://scriptingosx.com/2010/11/ichat-notification-with-growl/
property growlAppName : "Growl iChat"
property notificationNames : {"Buddy Became Available", ¬
"Buddy Became Unavailable", ¬
"Message Received", ¬
"Completed File Transfer"}
property defaultNotificationNames : {"Buddy Became Available", ¬
@dekz
dekz / jruby-1.6.7 1.8
Created June 5, 2012 23:20 — forked from kouno/gist:2878246
Inheritance of BigDecimal breaks is_a? function in JRuby
~/tmp % jruby -v
jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [darwin-x86_64-java]
~/tmp % jruby zz.rb
Decimal.new is a Decimal object?: false
SubString.new is a SubString object?: true