Skip to content

Instantly share code, notes, and snippets.

View davidnuon's full-sized avatar
🥙

David Nuon davidnuon

🥙
View GitHub Profile
<?php
$json_content = json_encode(array('content' => 'The post content');
echo '<script> var postObject = "' . $json_content .'"; console.log(postObject); ';
@davidnuon
davidnuon / 1970.html
Created September 15, 2018 05:00
A very serious gist
html
head
title= title
body
h1= 1970
p Music was awful.

Keybase proof

I hereby claim:

  • I am davidnuon on github.
  • I am davidnuon (https://keybase.io/davidnuon) on keybase.
  • I have a public key ASCxHN1spYUEzao6lQ3OYUSsLLJhtk92MfCGN8Gr3bWNRwo

To claim this, I am signing this object:

@davidnuon
davidnuon / example.java
Last active September 29, 2016 05:40
Segment Loop
PolylineOptions lineOptions = new PolylineOptions();
for(/* loop to get points */) {
lineOptions.add(new LatLng(obj.lat, obj.long));
}
lineOptions.add(new LatLng(33.927065258415212, -118.3913193654964))
lineOptions.width(20)
lineOptions.color(Color.RED);
line = mMap.addPolyline(lineOptions);
target = [1,2,3,4,5,6,7,8]
reverse_bits = lambda POW: lambda n: int(bin(n)[2:].zfill(POW)[::-1], 2)
new_array = []
power = 3
for idx in map(reverse_bits(power), range(0, 1 << power)):
new_array.append(target[idx])
print new_array
0 1 2 3 4 5 6 7
0 1 2 3
4 5 6 7
0 1
4 5
2 3
6 7
@davidnuon
davidnuon / overflow.rs
Created September 19, 2016 23:32
Handling overflows in rust
use std::num::Wrapping;
fn main() {
let a: u8 = 0xFF;
// a an unsigned 8-bit integer 0xFF
// 0xFF + 0x01 = 0x00 (Overflow)
println!("{}", (Wrapping(a) + Wrapping(0x01)).0);
}
@davidnuon
davidnuon / basic
Last active July 19, 2016 17:57
Shebangs in Action
#!/usr/bin/env python
import sys
print('Arguments')
print(sys.argv)
print('File content')
with open(sys.argv[-1]) as f:
print f.read()
@davidnuon
davidnuon / Vagrantfile
Created May 2, 2016 18:54
Multiple Machine configuration in Vagrant
Vagrant.configure("2") do |config|
(0..10).each do |idx|
config.vm.define ("node-#{idx}") do |web|
web.vm.box = "ubuntu/trusty64"
web.vm.hostname = "node-#{idx}"
web.vm.box_url = "ubuntu/precise64"
web.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 1024]
end
div #branding a {
display:none !important;
}