Skip to content

Instantly share code, notes, and snippets.

@avinasha
avinasha / about.md
Created August 16, 2011 07:31 — forked from catwell/about.md
Programming Achievements: How to Level Up as a Developer
@avinasha
avinasha / css_transformer.rb
Created July 29, 2011 06:40
A Sanitize gem transformer which sanitizes any CSS in a HTML document.
check_css = lambda { |env|
node = env[:node]
node_name = env[:node_name]
# Don't continue if this node is already whitelisted or is not an element.
return if env[:is_whitelisted] || !node.element?
parent = node.parent
return unless node_name == 'style' || node['style']
if node_name == 'style'
unless good_css? node.content
node.unlink

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/)

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 August 13, 2013 07:10
Learning Functional Programming; How can I use in ruby?

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

# 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 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
@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 / 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 / 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'
});