Skip to content

Instantly share code, notes, and snippets.

@avinasha
avinasha / song_to_hue.rb
Created March 6, 2014 10:21
hue_expts.rb
require 'hue'
require 'waveform'
audio = RubyAudio::Sound.open(source)
length = audio.info.length.to_i
frames = audio.info.frames
sample_period = 1
frames_per_sample = frames / sample_period
1 static.33.170.9.5.clients.your-server.de (5.9.170.33) 3.140 ms 3.237 ms 3.234 ms
2 hos-tr3.juniper2.rz16.hetzner.de (213.239.223.193) 0.148 ms hos-tr1.juniper1.rz16.hetzner.de (213.239.222.65) 0.154 ms 0.152 ms
3 core21.hetzner.de (213.239.245.93) 0.247 ms core22.hetzner.de (213.239.245.133) 0.252 ms 0.242 ms
4 core11.hetzner.de (213.239.245.221) 2.783 ms core12.hetzner.de (213.239.245.29) 2.768 ms core11.hetzner.de (213.239.245.221) 2.777 ms
5 juniper4.rz2.hetzner.de (213.239.245.26) 2.817 ms 2.853 ms 2.796 ms
6 r1nue1.core.init7.net (77.109.135.101) 10.427 ms 6.478 ms 6.969 ms
7 r1lon1.core.init7.net (77.109.140.253) 22.656 ms 22.620 ms 22.612 ms
8 * * *
9 * * *
10 * * *
@avinasha
avinasha / soulmate.rb
Last active August 29, 2015 14:17
Soulmate Loader
require 'soulmate'
module Soulmate
class Loader < Base
def load_without_reset(items)
items.each_with_index do |item, i|
puts item["id"]
add(item, :skip_duplicate_check => true)
end
end

If you dont have a python env setup yet, follow the instructions in python_env.md.

Installing django

Setting up django for a new project

Installing django

Once your python env is setup: pip install Django==1.8.2

Create a new porject

django-admin.py startproject <name> This creates the following file structure

@avinasha
avinasha / about.md
Created August 16, 2011 07:20 — forked from blaix/about.md
Programming Achievements: How to Level Up as a Developer

Programming Achievements: How to Level Up as a Developer

  1. Select a particular experience to pursue.
  2. Pursue that experience to completion. (Achievement unlocked!)
  3. Reflect on that experience. Really soak it in. Maybe a blog post would be in order?
  4. Return to Step 1, this time selecting a new experience.

This gist is a fork of the gist from this blog post.

class CucumberExternalResqueWorker
DEFAULT_STARTUP_TIMEOUT = 1.minute
COUNTER_KEY = "cucumber:counter"
class << self
attr_accessor :pid, :startup_timeout
def start
# Call from a Cucumber support file so it is run on startup
return unless Rails.env.cucumber?
@avinasha
avinasha / supportbee_form.html
Created December 5, 2011 20:39
Embed SupportBee Form
Add the following code block with the correct options to embed SupportBee in any website
<script src="https://sbassets.s3.amazonaws.com/widget/script.js" type="text/javascript"></script>
<script>
var sb_form = SupportBee.Form.initialize({
company: 'techfolder',
height: '400px',
base_domain: 'supportbee.com',
position: 'bottom'
});
@avinasha
avinasha / Gemfile
Created July 18, 2012 10:08
Platform dependent gems
group :production, :test, :cucumber, :staging do
gem 'rb-inotify', :require => false
end
group :test, :development, :cucumber do
gem 'rb-fsevent', :require => false
end
@avinasha
avinasha / simple_billing_methods.rb
Created August 24, 2012 10:09
Integrating Stripe
def active?
not (expired? or exceeds_ticket_volume?)
end
def expired?
expiry < Time.now
end
@avinasha
avinasha / _config.yml
Created August 29, 2012 01:47
Deploying Jekyll Bootstrap using Capistrano
host:
development:
production: https://supportbee.com/devblog
JB :
version : 0.2.13
setup:
provider: custom