Skip to content

Instantly share code, notes, and snippets.

@prashcr
prashcr / johnny-joystick.js
Last active April 12, 2016 23:40
Super hacky Node.js script that lets you control your cursor with a joystick connected to an Arduino, using Johnny-Five and RobotJS
'use strict'
const five = require('johnny-five')
const board = new five.Board()
const robot = require('robotjs')
const range = 24
const center = range / 2
const threshold = range / 8
let count = 0
robot.setMouseDelay(1)
@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
@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']

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:

* { 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); }
// 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()
@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);
@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')
var helloWorld = function () {
return [][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])
@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