Skip to content

Instantly share code, notes, and snippets.

View jikkujose's full-sized avatar

Jikku Jose jikkujose

View GitHub Profile
@jikkujose
jikkujose / hk_flights.rb
Created March 21, 2015 19:48
Quick and dirty implementation of HK flight data parsing
#!/usr/bin/env ruby
require 'curb'
require 'nokogiri'
require 'date'
CURRENT_DATE = Date.today.strftime("%Y-%-m-%d")
link = "http://www.hongkongairport.com/flightinfo/eng/real_arrinfo.do?fromDate<wbr>=#{CURRENT_DATE}"
USER_AGENT = "Mac / Firefox 29: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0"
@jikkujose
jikkujose / vim_right_align.txt
Created May 5, 2015 06:29
Test data for Vim right alignment function
Email Email
Land Land
Mobile Mobile
Address Address
FeedBack FeedBack
Enter (case Enter
@jikkujose
jikkujose / xiaomi_wish_list.markdown
Last active August 29, 2015 14:20
Xiaomi products wish list
  • Thermometer
  • Barometer
  • Plug PC: One that has a battery, networking and can be connected to a wall socket. Refer: [Plug computer][1] OR [Intel Compute Stick][2] (but of course with Linux)
  • Water purifier
  • Induction cooker
  • AC
  • Pen drive
  • Hard disk
  • Desktop speakers
  • Car entertainment sets (MP3 player + speakers)
@jikkujose
jikkujose / count_by_genre.rb
Last active August 29, 2015 14:23
Ruby pipeline
# Original
movies.group_by do |movie|
movie.genre
end.map do |month, list|
[month, list.size]
end.sort_by(&:last).reverse
# Alternative
@jikkujose
jikkujose / github.css
Created June 27, 2015 14:38
Github CSS with slight tweaks
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@jikkujose
jikkujose / z_algorithm.rb
Created July 22, 2015 17:35
Implementation of the algorithm described in the lecture: https://www.youtube.com/watch?v=NVJ_ELSbbew
module ZAlgorithm
def z
@z = Array.new(length, 0)
@z[0] = length
left = right = 0
(1...length).each do |k|
if k > right
@z[k] = length_of_longest_prefix(k)
unless @z[k].zero?
javascript:(function()%7Bvar%20el=document.createElement(%22div%22),b=document.getElementsByTagName(%22body%22)%5B0%5D,otherlib=!1,msg=%22%22;el.style.position=%22fixed%22,el.style.height=%2232px%22,el.style.width=%22220px%22,el.style.marginLeft=%22-110px%22,el.style.top=%220%22,el.style.left=%2250%25%22,el.style.padding=%225px%2010px%22,el.style.zIndex=1001,el.style.fontSize=%2212px%22,el.style.color=%22%23222%22,el.style.backgroundColor=%22%23f99%22;function%20showMsg()%7Bvar%20txt=document.createTextNode(msg);el.appendChild(txt),b.appendChild(el),window.setTimeout(function()%7Btxt=null,typeof%20jQuery==%22undefined%22?b.removeChild(el):(jQuery(el).fadeOut(%22slow%22,function()%7BjQuery(this).remove()%7D),otherlib&&(window.$jq=jQuery.noConflict()))%7D,2500)%7Dif(typeof%20jQuery!=%22undefined%22)return%20msg=%22This%20page%20already%20using%20jQuery%20v%22+jQuery.fn.jquery,showMsg();typeof%20$==%22function%22&&(otherlib=!0);function%20getScript(url,success)%7Bvar%20script=document.createElement(%22script%22)
@jikkujose
jikkujose / docker_netstat.markdown
Created November 13, 2015 07:14
Unable to access docker from the host
root@ec077b3b57b7:/app# netstat -ln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:9393            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:2323          0.0.0.0:*               LISTEN
tcp6       0      0 ::1:2323                :::*                    LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
@jikkujose
jikkujose / sequential_array
Created August 30, 2013 18:22
Ruby command to create a sequential array
sequential_array = [*0..23]
@jikkujose
jikkujose / suggest.rb
Created August 31, 2013 08:16
Simple script in Ruby to get Google's suggested search terms
#! /usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
google_query_url = 'http://www.google.co.in/search?&q='
search_query = 'drath note'
if ARGV.length == 0 then
puts "usage: suggest <approx> <wrds> <to> <srch>"