Skip to content

Instantly share code, notes, and snippets.

View TheAshwanik's full-sized avatar
💭
Hi.. Don't hesitate to ping me.. I would love an interesting chat about tech.

Ashwani Kumar TheAshwanik

💭
Hi.. Don't hesitate to ping me.. I would love an interesting chat about tech.
View GitHub Profile
@TheAshwanik
TheAshwanik / JAVA-OutOfMemoryErrorDiagnostic
Last active December 16, 2015 19:50 — forked from rednaxelafx/command_prompt
JAVA-OutOfMemoryErrorDiagnostic
$ cat > OOM.java
import java.util.*;
public class OOM {
public static void main(String[] args) throws Exception {
ArrayList list = new ArrayList();
while (true) { list.add(new byte[20000]); }
}
}
# A small DSL for helping parsing documents using Nokogiri::XML::Reader. The
# XML Reader is a good way to move a cursor through a (large) XML document fast,
# but is not as cumbersome as writing a full SAX document handler. Read about
# it here: http://nokogiri.org/Nokogiri/XML/Reader.html
#
# Just pass the reader in this parser and specificy the nodes that you are interested
# in in a block. You can just parse every node or only look inside certain nodes.
#
# A small example:
#
@TheAshwanik
TheAshwanik / HAR-Related-Stuff
Last active December 19, 2015 16:39 — forked from igrigorik/links.md
Web Performance Power Tool: HTTP Archive (HAR)
computer = #path to movies directory
hd = #path to movies directory
def get_movies(path_comp, path_hd)
# Return ana rray with only the new movies. I exclude the directory Series in the search
return `ls #{path_comp} | grep -v Series`.split(/\n/) - `ls #{path_hd} | grep -v Series`.split(/\n/)
end
new_movies_list = get_movies(computer, hd)
#!/usr/bin/env python
"""MailBox class for processing IMAP email.
(To use with Gmail: enable IMAP access in your Google account settings)
usage with GMail:
import mailbox
#!/usr/bin/env ruby
#
# linux-meminfo
#
# by Eric Lindvall <eric@5stops.com>
#
# Gather more useful memory statistics for SNMP
#
# To see the example output, run:
# linux-meminfo.rb -g .1.3.6.1.4.1.2021.4.6.0
require 'roo'
# Spreadsheet courtesy of the A List Apart 2010 Web Design Survey:
# http://www.alistapart.com/articles/survey2010
workbook = Excel.new('a-list-apart-web-design-survey-sample.xls')
# Set the worksheet you want to work with as the default worksheet. You could
# also iterate over all the worksheets in the workbook.
workbook.default_sheet = workbook.sheets[0]
@TheAshwanik
TheAshwanik / Rails-SSL-Cert Related.md
Last active December 21, 2015 14:28 — forked from fnichol/README.md
Rails-SSL Cert Related
class ApplicationController < ActionController::Base
...
#Problem:
#In rails 3.0.1+ it is no longer possible to do this anymore;
# rescue_from ActionController::RoutingError, :with => :render_not_found
#
#The ActionController::RoutingError thrown is not caught by rescue_from.
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
# For all responses in this controller, return the CORS access control headers.
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'