Skip to content

Instantly share code, notes, and snippets.

@prashcr
prashcr / gist:5a5a4dad654ad16adb63
Created May 15, 2015 14:50
Inheritance in JavaScript
var d1, d2, d3, d4
function Base() {this.foo = 'foo'}
Base.prototype.bar = 'bar'
// Superconstructor
function D1() {Base.call(this)}
// Set prototype to instance
function D2() { }
D2.prototype = new Base()
// Set prototype to Base.prototype
@prashcr
prashcr / github-init.sh
Created October 16, 2015 12:28
bash script to create a new GitHub repo
# Creates a new GitHub repo
# Save your token in a file called gh-token in current dir
printf "Repo name: "
read repoName
curl -H "Authorization: token $(cat gh-token)" -d "{ \"name\": \"$repoName\" }" https://api.github.com/user/repos
var helloWorld = function () {
return [][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])
@prashcr
prashcr / index.jade
Created October 28, 2015 08:13
Difference between absolute and relative path
// Absolute path
script(src='/scripts/app.js')
// Relative path
script(src='scripts/app.js')
@prashcr
prashcr / hello.js
Last active October 30, 2015 12:53
Hello World HTTP server written in Node.js
var http = require('http');
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
}).listen(8080, 127.0.0.1);
// https://github.com/bjoerge/promise-latest
window.latest = latest;
function latest(fn) {
let lastAdded
let pending
let resolve
let reject
return function (...args) {
// in the future if/when promises gets cancellable, we could abort the previous here like this
// lastAdded.cancel()
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }

Keybase proof

I hereby claim:

  • I am prashcr on github.
  • I am prashcr (https://keybase.io/prashcr) on keybase.
  • I have a public key whose fingerprint is 5178 8B38 1576 F0C7 68B0 9DE5 B17F 509B 9A45 4FD3

To claim this, I am signing this object:

@prashcr
prashcr / Vagrantfile
Last active October 13, 2017 14:25
Node.js starter kit for Ubuntu 14.04 Vagrant box on DigitalOcean
Vagrant.configure('2') do |config|
config.vm.hostname = 'vagrant-example'
config.vm.provider :digital_ocean do |provider, override|
override.ssh.username = 'vagrant'
override.ssh.private_key_path = '~/.ssh/id_rsa'
override.vm.box = 'digital_ocean'
override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
provider.token = ENV['DIGITAL_OCEAN_TOKEN']
@prashcr
prashcr / logcat.txt
Created February 13, 2016 01:54
Logcat output from crashing Udemy app
02-13 09:49:55.510: D/Webtrends(1300): Received battery event
02-13 09:49:56.010: D/audio_hw_primary(240): out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
02-13 09:49:56.010: V/listen_hw(240): listen_hw_set_parameters: Enter
02-13 09:49:56.010: V/listen_hw(240): handle_set_parameters: Enter kvpairs=routing=2 capture=0
02-13 09:49:56.010: V/listen_hw(240): handle_set_parameters: Exit
02-13 09:49:56.010: V/listen_hw(240): listen_hw_set_parameters: Exit, ret=0
02-13 09:49:56.021: D/audio_hw_primary(240): start_output_stream: enter: stream(0xb5880740)usecase(1: low-latency-playback) devices(0x2)
02-13 09:49:56.021: D/audio_hw_primary(240): start_output_stream: enter: usecase(1: low-latency-playback) devices(0x2)
02-13 09:49:56.021: D/audio_hw_primary(240): select_devices: out_snd_device(2: speaker) in_snd_device(0: )
02-13 09:49:56.021: W/msm8974_platform(240): Codec backend bitwidth 16, samplerate 48000