Skip to content

Instantly share code, notes, and snippets.

View akagr's full-sized avatar

Akash Agrawal akagr

View GitHub Profile
@akagr
akagr / file_commands.sh
Last active August 29, 2015 14:03
File commands
# Find all files less than 2kb
find /path/to/directory -type f -size -2k
# Find all text files less than 2kb
find /path/to/directory -type f -name '*.txt' -size -2k
# Find all files with given pattern and count them
find -type f -name '*.jpg' | wc -l
find -type f -name 'e_*' | wc -l
@akagr
akagr / closures.js
Created February 20, 2014 12:44
Borrowed from john resig's tutorial. A very nice example to test one's grasp on closures.
var a = 5;
function runMe(a){
assert( a == ___, "Check the value of a." );
function innerRun(){
assert( b == ___, "Check the value of b." );
assert( c == ___, "Check the value of c." );
}
var b = 7;
@akagr
akagr / cache_expiry_extesion_for_apache
Last active February 17, 2017 07:08
Serve gzipped version of rails assets from apache server and set their expiry headers to 1 year
# The Expires* directives requires the Apache module `mod_expires` to be enabled.
<Location /assets/>
# Use of ETag is discouraged when Last-Modified is present
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</Location>
@akagr
akagr / optparse_example.rb
Created May 20, 2013 17:06
The best example of Optparse available on Internet Taken from official ruby docs.
require 'optparse'
require 'optparse/time'
require 'ostruct'
require 'pp'
class OptparseExample
CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }