Skip to content

Instantly share code, notes, and snippets.

View jorgechavz's full-sized avatar

Jorge Chavez jorgechavz

View GitHub Profile
func encode<T>(var value: T) -> NSData {
return withUnsafePointer(&value) { p in
NSData(bytes: p, length: sizeofValue(value))
}
}
func decode<T>(data: NSData) -> T {
let pointer = UnsafeMutablePointer<T>.alloc(sizeof(T.Type))
data.getBytes(pointer)
@jorgechavz
jorgechavz / gist:1015467773de5e008bbf
Created June 19, 2015 23:50
Scrolling to HTML element
<a href="#" data-go="#node-element" class="go">Go to</a>
<script type="text/javascript">
$(".go").click(function(e){
//We prevent the default scroll
e.preventDefault();
var $this = $(this),
to = $this.attr("data-go"),