Skip to content

Instantly share code, notes, and snippets.

View engleek's full-sized avatar

Christopher Humphries engleek

View GitHub Profile
@engleek
engleek / gist:1165962
Created August 23, 2011 17:41
Server Viz demo
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1">
</script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?1.29.1">
</script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.29.1">
@engleek
engleek / gist:980461
Created May 19, 2011 09:19
Localstorage snippet
if (typeof(localStorage) == 'undefined' ) {
alert('Your browser does not support HTML5 localStorage. Try upgrading.');
} else {
try {
localStorage.setItem("name", "Hello World!"); //saves to the database, "key", "value"
} catch (e) {
if (e == QUOTA_EXCEEDED_ERR) {
alert('Quota exceeded!'); //data wasn’t successfully saved due to quota exceed so throw an error
}
}
<!DOCTYPE html>
<html>
<head>
<title>${title}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" type="image/png" href="/public/images/favicon.png" />
<link rel="stylesheet" href="http://yui.yahooapis.com/2.8.1/build/reset-fonts-grids/reset-fonts-grids.css" />
ssize_t
DVDDiskNode::ReadAt(off_t pos, void *buffer, size_t size)
{
printf("DVD::ReadAt(%i, %lu)\n", (int)pos, (unsigned long)size);
int blockCount = ceil(size / DVD_VIDEO_LB_LEN);
uint8_t *buf = (uint8_t *) buffer;
buf = new uint8_t[blockCount * DVD_VIDEO_LB_LEN];
KERN: scsi_cd: ioctl(op = 7)
KERN: scsi_cd: update_capacity()
KERN: scsi_cd: cd_set_capacity(info = 0x82354930, capacity = 3713600, blockSize = 2048)
KERN: scsi_cd: scsi_disk: get_geometry(): 2048, 1, 3713600, 1, 5, 1, 1, 0
KERN: scsi_cd: close()
KERN: scsi_cd: free()
KERN: runtime_loader: Cannot open file libdvdcss.so.2: No such file or directory
KERN: scsi_cd: close()
KERN: scsi_cd: free()
KERN: scsi_cd: ioctl(op = 15)
Welcome to the Haiku shell.
~> /system/demos/Cortex
BMediaRoster::InstantiateDormantNode: addon-id 4, flavor_id 0, flags 0x0
### BMediaRosterEx::LoadNodeConfiguration should load addon-id 4, flavor-id 0 config NOW!
DVDDiskNode::LoadDisk()
libdvdnav: Using dvdnav version 4.1.3
libdvdread: Encrypted DVD support unavailable.
libdvdnav: DVD Title: IMMORTEL
libdvdnav: DVD Serial Number: bf14112e
SubDir HAIKU_TOP src add-ons media plugins dvd ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders media ;
SubDirHdrs [ FDirName $(SUBDIR) libdvdvm ] ;
SubDirHdrs [ FDirName $(SUBDIR) libdvdnav ] ;
SubDirHdrs [ FDirName $(SUBDIR) libdvdread ] ;
int evaluate_position(int color){
int result = 0;
if ((get_horizontal_lines(4, color * (-1)) || (get_vertical_lines(4, color * (-1)) || get_diagonal_lines(4, color * (-1))))) {
return (-1) * VALUE_QUAD;
}
if ((get_horizontal_lines(4, color) || (get_vertical_lines(4, color) || get_diagonal_lines(4, color)))) {
return VALUE_QUAD;
}
@engleek
engleek / gist:299808
Created February 9, 2010 23:14
Base 62 String Decode
byte[] strValDecode(String s)
{
final String alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
BigInteger b = BigInteger.ZERO;
BigInteger b62 = new BigInteger("62");
for (int i=0; i<s.length(); i++) {
int idx = alphabet.indexOf(s.codePointAt(i));
b = b.multiply(b62).add(new BigInteger(Integer.toString(idx)));
We couldn’t find that file to show.