Skip to content

Instantly share code, notes, and snippets.

@amit
amit / backup.rake
Last active August 29, 2015 14:13 — forked from abhishek77in/backup.rake
namespace :db do desc "Backup database to AWS-S3"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
backup_filename = "#{Rails.root.basename}-#{datestamp}.sql"
db_config = ActiveRecord::Base.configurations[Rails.env]
# process backup
`mysqldump -u #{db_config['username']} -p#{db_config['password']} -i -c -q #{db_config['database']} > tmp/#{backup_filename}`
`gzip -9 tmp/#{backup_filename}`
puts "Created backup: #{backup_filename}"
@amit
amit / saavn.js
Last active August 29, 2015 14:15 — forked from vtomiris/saavn.js
/**
* Chrome-Last.fm-Scrobbler - Saavn.com Connector
*
* Author: Vikas Kumar [vikas@cs.umn.edu]
* Derived from Sitesh Shrivastava code on gaana.js
*/
// DOM Nodes to keep track for song details
var SONG_TRACK_DOM = '#player-track-name';
var SONG_ALBUM_DOM = '#player-album-name';
require 'rubygems'
require 'mash'
require 'httparty'
class CharityNavigator
include HTTParty
format :xml
base_uri "www.charitynavigator.org/feeds/search4"
def initialize(appid)
# = Icebox : Caching for HTTParty
#
# First stab at implementing caching for HTTParty (http://github.com/jnunemaker/httparty/)
# Modeled after Martyn Loughran's APICache (http://github.com/newbamboo/api_cache/)
#
# = Usage
# 1. <tt>include Icebox</tt> in YourPartyAnimalClass
# 2. Use <tt>YourPartyAnimalClass.get_cached()</tt> instead of simple <tt>get()</tt>
require 'logger'
diff --git a/git-wiki.rb b/git-wiki.rb
index 9f36624..337a5f6 100755
--- a/git-wiki.rb
+++ b/git-wiki.rb
@@ -20,7 +20,7 @@ end
get '/:page/append' do
@page = Page.new(params[:page])
- @page.body = @page.raw_body + "\n\n" + params[:text]
+ @page.append params[:text]
@amit
amit / Quic bookmarklet.js
Created March 22, 2011 23:47
Expanded Quix bookmarklet
javascript:Quix();function Quix() {
var e=encodeURIComponent; // shortcut for the function name
var t=window.getSelection ? window.getSelection():
(document.getSelection? document.getSelection(): (document.selection ? document.selection.createRange().text:'')); // Get selection or empty string
var c=window.prompt('Quix: Type `help` for a list of commands:');
if(t!='') {
if(c) {
c+=' '+t; // append selection to typed text
}
else {
@amit
amit / patchfile.txt
Created January 13, 2012 20:00
weekly-class-schedule support for upcoming classes.
--git a/css/wcs_style.css b/css/wcs_style.css
index ad4c85f..ec2d248 100644
--- a/css/wcs_style.css
+++ b/css/wcs_style.css
@@ -1,6 +1,21 @@
#content .wcs-schedule-table {
font-size: 12px;
}
+
+#content .wcs-upcoming-schedule-table {
कहाँ से तू आती है
कहाँ को तू जाती है
सपनों को सजाती है
अपनों को ले जाती है
बाग़ों में जब बहती है
कानों में कुछ कहती है
आती है नज़र नहीं
साँसों में पर रहती है
हवा है पवन है
वायु है , पुरवाई है
@amit
amit / adremover.user.js
Last active December 16, 2015 02:49
Ad remover
// ==UserScript==
// @name HQLive ad remover
// @description Version 1.2 - Remove annoying chat and ad iframes from hqlive
// @namespace http://hqlive.net/
// @include http://*hqlive.net/*
// @include http://*cricket-365.tv/*
// @include http://*cricvid.com/*
// @include http://*cricvip.com/*
// @include http://*live365.tv/*
@amit
amit / serializer.rb
Last active August 25, 2016 17:34
Activerecord test of simulteneous access serialization
threads = []
(0..4).each do
threads << Thread.new {
row = XAuth::Variable.where(name: "current_member_id").first_or_create
row.with_lock do
sleep(2)
oldvalue = row.value.to_i
newvalue = oldvalue + 1
row.value = newvalue
row.save!