Skip to content

Instantly share code, notes, and snippets.

View siruguri's full-sized avatar

Sameer S siruguri

View GitHub Profile
@siruguri
siruguri / gist:3991954
Created November 1, 2012 05:03
Troubleshooting output for Cygwin bundle install problems
> bundle install --verbose
----
Fetching gem metadata from https://rubygems.org/
Query List: ["rails", "sqlite3", "sass-rails", "coffee-rails", "uglifier", "jquery-rails"]
Query Gemcutter Dependency Endpoint API: rails sqlite3 sass-rails coffee-rails uglifier jquery-rails
Fetching from: https://rubygems.org/api/v1/dependencies?gems=rails,sqlite3,sass-rails,coffee-rails,uglifier,jquery-rails
HTTP Success
Query List: ["coffee-script", "railties", "actionpack", "sprockets", "thor", "bundler", "actionmailer", "activeresource", "activerecord", "activesupport", "rake", "actionwebservice", "sass", "tilt", "ffi", "therubyracer", "execjs", "multi_json", "json"]
Query Gemcutter Dependency Endpoint API: coffee-script railties actionpack sprockets thor bundler actionmailer activeresource activerecord activesupport rake actionwebservice sass tilt ffi therubyracer execjs multi_json json
Fetching from: https://rubygems.org/api/v1/dependencies?gems=coffee-script,railties,actionpack,sprockets,thor,bundler,actionmailer,activer
@siruguri
siruguri / gist:6603806
Created September 18, 2013 02:45
Redcarpet test code for footnotes
require 'redcarpet'
def test_that_footnotes_work
markdown = <<MD
This is a footnote.[^1]
[^1]: It provides additional information.
MD
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :footnotes => true)
@siruguri
siruguri / City names Google Auto Suggest
Created January 28, 2014 19:42
Auto suggest from Google for Top 50 US cities (by pop.)
why is New York so expensive
why is New York so popular
why is New York so dirty
why is New York so big
why is Los Angeles so popular
why is Los Angeles so warm
why is Los Angeles so big
why is Los Angeles so smoggy
why is Chicago so windy
why is Chicago so cold
@siruguri
siruguri / gist:66926b42a0c70ef7119e
Created April 14, 2015 18:49
Removing and setting constants in Ruby
# I am doing this because the server admin forgot to
# Renew their certificate!
prev_setting = OpenSSL::SSL.send(:remove_const, :VERIFY_PEER)
OpenSSL::SSL.const_set(:VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE)
# do my connnection thang!
OpenSSL::SSL.send(:remove_const, :VERIFY_PEER)
OpenSSL::SSL.const_set(:VERIFY_PEER, prev_setting)
@siruguri
siruguri / count_dupes.rb
Created May 31, 2015 03:18
Gathering counts of possibly duplicated items in an array
a = [1, 1, 1, 2, 3, 3, 4, 4, 4, 4]
b = a.uniq
counts = b.inject({}) do |memo, key|
memo[key] = a.count(key)
memo
end

Keybase proof

I hereby claim:

  • I am siruguri on github.
  • I am sameers (https://keybase.io/sameers) on keybase.
  • I have a public key ASBQjrgh6zQ2DXwMZ-AuKWH-0WHiVw9V82a0NZEQeQwF4wo

To claim this, I am signing this object:

API workthough

  1. Open a browser

    # start an instance of firefox with selenium-webdriver
    driver = Selenium::WebDriver.for :firefox
    # :chrome -> chrome
    # :ie     -> iexplore
    
  • Go to a specified URL
@siruguri
siruguri / calendar.rb
Last active March 30, 2021 02:52
Calendaring API in Ruby
require 'date'
class Calendar
def initialize
end
# start_t and end_t are Ruby DateTime objects in this and other methods
# event creation shouldn't cause conflicts
# if is_recurring is true, then the event recurs once a day at the given start and end times. In that case, the start and
# end times are only used to extract the hour and minute information and not the day information
(setq byte-compile-warnings '(cl-functions))
(setq package-user-dir "/usr/local/share/emacs/site-lisp/elpa")
(display-time-mode 1)
(require 'rust-mode)
(modify-syntax-entry ?_ "-")
(modify-syntax-entry ?a "w" text-mode-syntax-table)
(let ((default-directory "/usr/local/share/emacs/site-lisp/"))
@siruguri
siruguri / gist:1bdb56c34823efedefa0e3c17fd153a5
Created December 31, 2022 20:28
The Case of the Sorry Musicians
It was a dark and stormy night in the city, and detective Paul Stanley of the Kiss Detective Agency was on the case. He had been hired by a group of women who claimed to have had an unforgettable evening with the members of the famous rock band Kiss, only to wake up the next morning with no memory of what had happened.
Paul had heard rumors of the band's wild parties and was not surprised by the women's request. He knew that if anyone could help solve this mystery, it was him.
As he began his investigation, Paul learned that the women had met the band at a football game and had gone on to spend the evening drinking cognac and discussing literature and music at a nearby library. From there, the trail went cold.
Determined to uncover the truth, Paul decided to pay a visit to the library. As he arrived, he noticed a helicopter parked outside, its rotors still spinning. Without a moment's hesitation, he climbed aboard and took off into the night sky.
As he flew over the city, Paul scanned the streets below fo