Skip to content

Instantly share code, notes, and snippets.

Avatar

Avinasha Shastry avinasha

View GitHub Profile
View django.md

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 / soulmate.rb
Last active Aug 29, 2015
Soulmate Loader
View soulmate.rb
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
View trace
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 * * *
View song_to_hue.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
View rails_load_path_tips.md

In Rails 3

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

(e.g. app/models/concerns/, app/models/products/)

View rails_load_path_tips.md

In Rails 3

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

(e.g. app/models/concerns/, app/models/products/)

@avinasha
avinasha / fp.md
Created Aug 13, 2013
Learning Functional Programming; How can I use in ruby?
View fp.md

source

lambda calculus

  • Alonso Church
  • Formalization of computation.
  • Similar to Turing machine

implementation of lambda calculus on von Neumann computer is LISP

FP is a sub set of what lambda calculus says

View elasticsearch.rake
# Run with: rake environment elasticsearch:reindex
# Begins by creating the index using tire:import command
# This will create the "official" index name, e.g. "person" each time.
# Then we rename it to, e.g. "person20121001" and alias "person" to it.
namespace :elasticsearch do
desc "re-index elasticsearch"
task :reindex => :environment do
klasses = [Ticket]
@avinasha
avinasha / _config.yml
Created Aug 29, 2012
Deploying Jekyll Bootstrap using Capistrano
View _config.yml
host:
development:
production: https://supportbee.com/devblog
JB :
version : 0.2.13
setup:
provider: custom
View simple_billing_methods.rb
def active?
not (expired? or exceeds_ticket_volume?)
end
def expired?
expiry < Time.now
end