This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clientID = '' | |
| clientSecret = '' | |
| redirectURI = 'urn:ietf:wg:oauth:2.0:oob' | |
| code = '' | |
| https = require 'https' | |
| http = require 'http' | |
| querystring = require 'querystring' | |
| getRefreshToken = -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 : '', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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", ¬ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ~/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 |