Skip to content

Instantly share code, notes, and snippets.

View yonran's full-sized avatar

Yonathan Randolph yonran

View GitHub Profile
@yonran
yonran / pulse.txt
Created March 17, 2014 16:51
lsusb -v for Livescribe Pulse
Bus 004 Device 043: ID 1cfb:1010
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 2 Communications
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 16
@yonran
yonran / TestPeripheral.m
Created December 19, 2013 00:35
Bluetooth LE Peripheral Role hello world based on [Performing Common Peripheral Role Tasks](https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/PerformingCommonPeripheralRoleTasks/PerformingCommonPeripheralRoleTasks.html). When I run this program on a Mac Mini, the peripheral is advertisi…
#import <Foundation/Foundation.h>
#import <IOBluetooth/IOBluetooth.h>
enum HandlerState {
HandlerStateStarting,
HandlerStateWaitingForServiceToAdd,
HandlerStateWaitingForAdvertisingToStart,
HandlerStateAdvertising,
HandlerStateError,
};
@yonran
yonran / test.rs
Created October 1, 2013 00:10
Rust: can a struct hold a borrowed reference to its owner?
struct Foo {
bar: ~Bar
// ^~~ error: Illegal anonymous lifetime: anonymous lifetimes are not permitted here
}
struct Bar<'self> {
owner: &'self Foo
// ^~~ error: Illegal anonymous lifetime: anonymous lifetimes are not permitted here
}
// Note that if Bar has _any_ borrowed reference (not just to a Foo),
@yonran
yonran / test.rs
Last active December 24, 2015 02:29
Rust: cannot assign to `(*self).count` because it is borrowed
use std::util;
struct Bar;
struct Foo {
test: bool,
count: int,
bar: Bar,
}
impl Foo {
import static org.junit.Assert.assertEquals;
import java.io.BufferedReader;
import java.io.StringReader;
import java.util.Collection;
import org.junit.Test;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@yonran
yonran / content_script.js
Created April 21, 2011 18:06 — forked from anonymous/background.html
Message Passing attempt
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
console.log(sender.tab ?
"from a content script:" + sender.tab.url :
"from the extension");
if (request.greeting == "hello")
sendResponse({farewell: "goodbye"});
else
sendResponse({}); // snub them.
});