Skip to content

Instantly share code, notes, and snippets.

View tarunc's full-sized avatar

Tarun Chaudhry tarunc

  • San Francisco, CA
View GitHub Profile
@tarunc
tarunc / auth.py
Last active December 25, 2015 07:49 — forked from mjallday/auth_server.py
import SimpleHTTPServer
import SocketServer
PORT = 8000
class Server(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
headers = self.headers.dict
print headers.get('x-original-uri')
#!/usr/bin/env ruby
# Please read http://otobrglez.opalab.com for more information about this code.
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info: http://en.wikipedia.org/wiki/Jaccard_index
class Article < ActiveRecord::Base
def related(limit=10)
Article.find_by_sql(%Q{
SELECT
a.*,
( SELECT array_agg(t.name) FROM taggings tg, tags t
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@tarunc
tarunc / webpack4upgrade.md
Created April 3, 2018 15:33 — forked from gricard/webpack4upgrade.md
Just some notes about my attempt to upgrade to webpack 4

This is not a complaint about Webpack or v4 in any way. This is just a record of my process trying it out so I could provide feedback to the webpack team

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ [email protected]
added 1 package, removed 20 packages and updated 4 packages in 13.081s
@tarunc
tarunc / insert_image_on_pdf.rb
Created August 1, 2021 05:16 — forked from aashish/insert_image_on_pdf.rb
Insert image on a existing PDF having content with hexapdf gem
require 'hexapdf'
doc = HexaPDF::Document.open("/home/xxxx/Downloads/OoPdfFormExample.pdf")
page = doc.pages[0]
canvas = page.canvas(type: :overlay)
canvas.translate(0, 20) do
canvas.fill_color(0.3, 0.7, 0.7)
canvas.rectangle(50, 0, 80, 80, radius: 80)