Skip to content

Instantly share code, notes, and snippets.

View imRohan's full-sized avatar
🎧
Focusing

Rohan Likhite imRohan

🎧
Focusing
View GitHub Profile
@imRohan
imRohan / discoFilter
Created April 1, 2015 14:40
April Fools "Disco" Filter
body{
-webkit-animation: adjustHue 1s alternate infinite;
}
@-webkit-keyframes adjustHue {
0% {
-webkit-filter: hue-rotate(30deg);
}
50% {
-webkit-filter: hue-rotate(60deg);
@imRohan
imRohan / DeviceMotionSnippet
Last active August 29, 2015 14:21
Device Motion
if (window.DeviceMotionEvent == undefined) {
// No Sensor Detected
} else {
window.ondevicemotion = function (event) {
// Grab x/y vals
ax = Math.round(Math.abs(event.accelerationIncludingGravity.x));
ay = Math.round(Math.abs(event.accelerationIncludingGravity.y));
// Check if Device is Tilted
if (ax !== 0 | ay !== 0){
//Device is tilted
@imRohan
imRohan / colour.coffee
Last active September 15, 2015 13:11
Random RGB Colour Generator
generateRandomColor: (mix) ->
red = Math.random() * 256 >> 0
green = Math.random() * 256 >> 0
blue = Math.random() * 256 >> 0
if mix != null
red = (red + mix.red) / 2 >> 0
green = (green + mix.green) / 2 >> 0
blue = (blue + mix.blue) / 2 >> 0
rr = red.toString(16)
@imRohan
imRohan / onename
Created October 22, 2015 16:13
onenameverification
Verifying that +likhite is my blockchain ID. https://onename.com/likhite
@imRohan
imRohan / commands.rb
Created November 11, 2015 14:59
Capybara Commands
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@imRohan
imRohan / keybase.md
Created August 27, 2016 13:29
keybase verify

Keybase proof

I hereby claim:

  • I am imrohan on github.
  • I am rohanlikhite (https://keybase.io/rohanlikhite) on keybase.
  • I have a public key ASArKbJOWKNkeeIBwSWX7hEfT1PES0capni8a8J9LiAdpQo

To claim this, I am signing this object:

@imRohan
imRohan / capybara.txt
Last active January 6, 2017 14:59
Helpful commands to build out integration tests using Capybara
=Create Tests=
rails g integration_test name_of_test
=Running Tests=
rake (all tests)
rake test:[models, integration]
ruby -I"lib:test" path/to/test_file.rb -n "test_name_of_test"
=Debug=
save_and_open_page
@imRohan
imRohan / roundDownToNearestHalf.coffee
Created October 26, 2016 14:22
A simple function which take a value, and rounds it down to the nearest 0.5
formatAllotmentValue = (value) ->
_value = parseFloat(value)
if parseFloat((_value%(Math.floor(_value))).toFixed(1)) >= 0.5
return Math.floor(_value) + 0.5
else
return Math.floor(_value)
@imRohan
imRohan / latency.txt
Created January 31, 2017 15:31 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@imRohan
imRohan / youtubedl.txt
Last active August 11, 2017 15:37
Youtube-DL Helpful Commands
// Download a playlist from index, and skip errors
sudo youtube-dl -i --playlist-start 0 [link]
-i = continue on error (skip song)
--playlist-start [index] = start downloading at a index
// Download a mp3 form youtube
sudo youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" [link]
// Download mp3 from Soundcloud ignore errors
sudo youtube-dl -i -o "%(title)s.%(ext)s" [link]