Skip to content

Instantly share code, notes, and snippets.

View amalagaura's full-sized avatar

Ankur Sethi amalagaura

View GitHub Profile
@amalagaura
amalagaura / edit.html.slim
Created April 16, 2012 16:45
complicated slim template
- content_for :sidebar do
= render_widget :contract_summary, :display, @contract, true
- content_for :extra_header_row do
- unless @hide_edit_link
.price-offset.breadcrumb
span = "Go to "
= link_to *@link_to
- content_for :content do
- Contract.filtered_categories.each do |category|
- config_set = @category_details[category.name][:config_set]
@amalagaura
amalagaura / runme.sh
Created December 15, 2011 04:29
Commands to fix damn CRLF with rubymine saving in windows
# Remove everything from the index
git rm --cached -r .
# Re-add all the deleted files to the index
# You should get lots of messages like: "warning: CRLF will be replaced by LF in <file>."
git diff --cached --name-only -z | xargs -0 git add
# Commit
git commit -m "Fix CRLF"
@amalagaura
amalagaura / ability.rb
Created December 13, 2011 20:23 — forked from watson/ability.rb
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
@amalagaura
amalagaura / arrays.py
Created May 4, 2011 15:05
time to sort arrays
#!/usr/bin/python
from numpy import *
import sys
from datetime import datetime
my_array = []
array_size = 640*480*3*3
a = datetime.now()
@amalagaura
amalagaura / carrier_wave_monkey_patch.rb
Created April 24, 2011 19:16
Monkey patch idea to get streaming uploads for carrierwave
module CarrierWave
module Storage
class S3
class File
def store(file)
content_type ||= file.content_type # this might cause problems if content type changes between read and upload (unlikely)
connection.put_object(bucket, path, file.open,
{
'x-amz-acl' => access_policy.to_s.gsub('_', '-'),