Skip to content

Instantly share code, notes, and snippets.

View jikkujose's full-sized avatar

Jikku Jose jikkujose

View GitHub Profile
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 / 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?
@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 / 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 / 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 / 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 / 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"
class SittingDuck
include Robot
def tick events
turn_radar 5 if time == 0
fire 3 unless events['robot_scanned'].empty?
turn_gun 10
@last_hit = time unless events['got_hit'].empty?
if @last_hit && time - @last_hit < 20
require 'minitest'
# require 'minitest/reporters'
# Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new({color: true})]
class Range
include Comparable
def <=>(other)
self.begin <=> other.begin
end
class Base
def initialize(alphabets)
@alphabets = alphabets
end
def base
@alphabets.length
end
def to_decimal(number)