Skip to content

Instantly share code, notes, and snippets.

View amitpatelx's full-sized avatar

Amit Patel amitpatelx

View GitHub Profile
@ParthBarot-BoTreeConsulting
ParthBarot-BoTreeConsulting / baruco.org -notes
Created October 29, 2014 06:17
Fast Ruby - Barcelona ruby conference video notes
=================================
def slow(&block)
block.call
end
def slow
Proc.new.call
end
- The below one is 5 times faster then above, in execution
@marcinb
marcinb / bbc_recipes.coffee
Created October 7, 2011 11:23
Chicken soup recipes
page = require('webpage').create()
injectjQuery = ->
# phantom allows to dynamically inject any javascript
# into page context.
# Make sure you add jquery to your script dir.
page.injectJs './jquery.js'
# ALWAYS do that when injecting jQuery into other page
page.evaluate ->
@jrmoran
jrmoran / app.coffee
Created January 16, 2012 20:57
Precompiled Haml templates with CoffeeScript
companies = [{"id":1,"ticker":"AAPL","name":"Apple Inc"},
{"id":2,"ticker":"ABC","name":"Amerisourcebergen Corp"},
{"id":3,"ticker":"ABT","name":"Abbott Labs"},
{"id":4,"ticker":"ACE","name":"Ace Ltd"},
{"id":5,"ticker":"ADBE","name":"Adobe Sys Inc"}]
_.templateSettings = interpolate :/\{\{(.+?)\}\}/g
$ ->
@guzart
guzart / download
Created March 21, 2012 17:14
bash: Download and Compress Rails API
#!/bin/bash
rm -rf api.rubyonrails.org/
wget -r -k -p http://api.rubyonrails.org/
rm rails_api.rar
rar a -r rails_api.rar api.rubyonrails.org/
@paulirish
paulirish / gist:366184
Created April 14, 2010 18:59
html5 geolocation with fallback.
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
// doublecheck the ClientLocation results because it may returning null results
;(function(geolocation){
if (geolocation) return;
@martindemello
martindemello / chain-of-responsibility.rb
Created February 20, 2015 21:30
chain of responsibility example in ruby
class PurchaseApprover
# Implements the chain of responsibility pattern. Does not know anything
# about the approval process, merely whether the current handler can approve
# the request, or must pass it to a successor.
attr_reader :successor
def initialize successor
@successor = successor
end
@amitpatelx
amitpatelx / README.md
Last active September 23, 2018 20:30
Development and Deployment Processes

This page outlines about practices we are following related to development and deployment

Branches

  1. Unless mentioned in issue or verbally, create all branches from develop branch.
  2. Pull latest changes from the parent branch before creating a branch from it.
  3. Branch name should be self-explanatory about the issue you are working on(Trello Card). It is highly discouraged to use an abbreviation, issue number etc in branch names.
  4. Avoid creating nested branches from working branches. Do proper planning before start coding.

Naming the branch

  1. All enhacements and feature branches should start with feature/ eg. feature/google-oauth-integration which will be created from develop only.
@aliang
aliang / mymodel.rb
Created June 13, 2011 06:25
render from model in Rails 3
# yes, sometimes you need to do this. you get pilloried in a forum if you
# ask about it, though!
# this code taken from
# http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/
class MyModel < ActiveRecord::Base
# Use the my_models/_my_model.txt.erb view to render this object as a string
def to_s
ActionView::Base.new(Rails.configuration.paths.app.views.first).render(
@jcowhigjr
jcowhigjr / spree-api-rest-examples.md
Created November 5, 2012 23:58
Spree API REST Examples

Products

index of products 25 first

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products.json

Show a product

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products/706676762.json

Modify a product

curl -i -X PUT -H "X-Spree-Token: YOUR_TOKEN_ID" -d "product[name]=Headphones" http://0.0.0.0:3000/api/products/706676762.json

@bxt
bxt / xml-to-csv.rb
Created April 26, 2017 22:53
Convert XML to CSV file using Ruby (nokogiri)
require 'csv'
require 'nokogiri'
filename = "timeentries"
doc = File.open("#{filename}.xml") { |f| Nokogiri::XML(f) }
entries = doc.css('time-entry')
CSV.open("#{filename}.csv", "wb") do |csv|