Skip to content

Instantly share code, notes, and snippets.

Hiten Parmar hrp

Block or report user

Report or block hrp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sort-time.rb
require 'benchmark'
puts "Running Ruby #{RUBY_VERSION}"
ary = []
200.times {
ary << {:bar => *}
View us.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
hrp / kill-postgres
Created Dec 10, 2015
Force kill postgres on OS X El Capitan
View kill-postgres
pg_ctl -D /usr/local/var/postgres -m immediate stop
hrp / stack_qa
Created Feb 10, 2015
Stackosaurus Rex
View stack_qa
# Design a data structure supporing the following:
# 1) Push an element
# 2) Pop an element
# 3) Find Minimum in the data structure
# Push(12)
# 12
# Min() ==> 12
View gist:f9b26f81aab86a291bb2
/* Prototype JavaScript framework, version 1.7
* (c) 2005-2010 Sam Stephenson
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site:
var Prototype = {
View emojibomb.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
# Run `emojibomb` to get three emoji.
# Run `emojibomb N`, where `N` is a positive integer to get N emoji.
doc = Nokogiri::HTML(open(""))
emoji = doc.css('.name')
hrp / acts-as-taggable-speed.rb
Last active Jan 3, 2016
acts-as-taggable-on speed hack
View acts-as-taggable-speed.rb
module ActsAsTaggableOn
mattr_accessor :ignore_case_for_mysql
@@ignore_case_for_mysql = false
class Tag
class << self
def named_any_with_ignore_case(list)
if ActsAsTaggableOn.ignore_case_for_mysql
where( { |tag| sanitize_sql(["name = ?", tag.to_s.mb_chars.downcase]) }.join(" OR "))
hrp / no-ascii.rb
Created Dec 28, 2013
Dump non-ascii benchmark
View no-ascii.rb
# encoding: utf-8
require 'benchmark'
require 'iconv'
class String
def remove_nonascii(replacement='')
hrp / case-insensitive-include.rb
Created Dec 28, 2013
Case insensitive String#include? benchmark
View case-insensitive-include.rb
marking answers to
strings ='sherlock.txt').scan(/\w+/) # 109,222 words
known = do{ |c| rand<0.5 ? c.upcase : c }.join
words = known.flat_map{ |s| [s, s+"-"] } # \w does not include -
You can’t perform that action at this time.