Skip to content

Instantly share code, notes, and snippets.

View sairam's full-sized avatar
🏠
Working from home

Sai Ram Kunala sairam

🏠
Working from home
View GitHub Profile
@sairam
sairam / vu-remote.lircd.conf
Last active December 15, 2016 14:02
lirc file generated for Vu remote
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Thu Dec 15 13:56:52 2016
#
# contributed by Sai Ram Kunala
#
# brand: Vu
# model no. of remote control:
# devices being controlled by this remote:
# Vu 40D6575
@sairam
sairam / make-draft.bash
Created November 15, 2016 18:39
Add a new line with string to multiple files
# I needed to not publish posts from past.
# Note: this is slow if you are doing for thousands of files
for file in `ls 200*`; do
echo $file
grep "draft = true" $file # looking for this string if already present.
if [[ $? == 1 ]]; then # if the string is not found. grep returns status 1
echo "string not found"
tempfile=123.txt # creating a temporary file

Keybase proof

I hereby claim:

  • I am sairam on github.
  • I am sairam (https://keybase.io/sairam) on keybase.
  • I have a public key whose fingerprint is 0D09 6928 6276 6935 2A15 18E3 9383 4C93 65E7 B7D9

To claim this, I am signing this object:

@sairam
sairam / README.md
Last active April 30, 2016 18:56
(WIP) script to download Ruby5 Podcasts from https://ruby5.codeschool.com/episodes
  • a typename [ screencast/podcast/sourcecode/gem/documentation/person/basic_text]
  • a source and parser
  • shows output
  • targets to update to # like emails or target widget
  • SourceCode: instance has attributes like source link
  • SourceCode: Diff between versions (of the same base link)
  • PodCast has a source
  • Gem has a source code and a version
  • Person has a name, website, other links
@sairam
sairam / webkit2png.py
Created April 30, 2016 17:55
Webkit 2 PNG python file
#!/usr/bin/env python
#
# webkit2png.py
#
# Creates screenshots of webpages using by QtWebkit.
#
# Copyright (c) 2008 Roland Tapken <roland@dau-sicher.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@sairam
sairam / mysql-import-wordpress-to-octopress.rb
Created April 24, 2016 11:48
Restore Old Wordpress Posts to Octopress
# gem install mysql2
# import mysqldump to database
# fix database name
require 'mysql2'
client = Mysql2::Client.new(:host => "localhost", :username => "root", database: "wp")
results = client.query(%Q{select post_modified, POST_NAME, POST_TITLE, post_content from wordpress_posts})
results.entries.each do |e|
file_to_touch = e["post_modified"].to_s.split(" ")[0] + "-"+ e["POST_NAME"]+".html"
@sairam
sairam / download-camera-prices-flipkart-india.rb
Last active April 24, 2016 06:37
Ruby Scripts for Camera Price Crawlers 2011
# Download all Camera Prices from Flipkart Website
# Code from the year 2011
require 'rubygems'
require 'mechanize'
require 'nokogiri'
require 'open-uri'
sitemapurl = 'http://www.flipkart.com/camera/'
baseurl = 'http://www.flipkart.com/cameras/'
@sairam
sairam / screenshot.js
Last active April 16, 2016 04:17 — forked from n1k0/gist:1501173
PhantomJS: Capturing single dom elements as png files
// Usage:
// phantomjs --ssl-protocol=any screenshot.js "https://www.twitter.com/" twitter.png
// TODO: move '#topnav_wrapper' to selector or command line argument
// If element is not found, it will fetch the complete page
// Works with phontomjs 2.0 (does not work with 1.9)
// Ubuntu link for PhantomJS 2.0 - https://github.com/Pyppe/phantomjs2.0-ubuntu14.04x64
"use strict";
var page = require('webpage').create(),
@sairam
sairam / find_missing_no.rb
Created October 19, 2015 14:23
Find Missing Number from a string sequence
require 'pry'
=begin
x =(1..400).to_a ; deleted = x.delete(Random.rand(400)); data= x.join("")
counter = 0
prev_no = 0
offset = 0
loop do
current_no = (data[offset..(offset+counter)]).to_i
@sairam
sairam / tsws
Last active September 6, 2015 17:03 — forked from dfletcher/tsws
Totally simple web server using Bash and netcat (nc)
#!/bin/bash
# --------------------------------
# Totally Simple Web Server (TSWS)
# --------------------------------
#
# (c) 2015 Dave Fletcher
# All Rights Reserved
#
# This is free and unencumbered software released into the public domain.