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
#
# Copyright (c) 2010 Sairam Kunala
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@sairam
sairam / gist:1209799
Created September 11, 2011 16:38 — forked from tinogomes/gist:1182499
credit card validation on ruby
# References
# http://en.wikipedia.org/wiki/Bank_card_number
# http://en.wikipedia.org/wiki/Luhn_algorithm
def valid_credit_card?(number)
number = number.to_s.gsub(/\D/, "")
return false unless valid_association?(number)
number.reverse!
@sairam
sairam / config-initializers-partial_renderer_override.rb
Created April 8, 2012 10:13
Open files in textmate from browser
if Rails.env.development?
module ActionView
class PartialRenderer < AbstractRenderer
alias :render_orig :render
def render(context, options, block)
setup(context, options, block)
file_path = find_partial.inspect
span_tag = "<span class='the-real-file-path' data-uri='txmt://open/?url=file://#{Rails.root.join file_path}'></span>".html_safe if file_path =~ /\.html/
render_orig(context, options, block) + span_tag
@sairam
sairam / g.tld.txt
Created June 13, 2012 13:02
New Top Level Domains
# Sorted by the number of applications for the domain name.
13 APP
11 INC
11 HOME
10 ART
9 SHOP
9 LLC
9 BOOK
9 BLOG
@sairam
sairam / LICENSE
Created July 1, 2012 11:59
Hacker Rank Script to automate submission
Copyright (C) 2012, Sairam Kunala
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@sairam
sairam / LICENSE
Created July 21, 2012 21:14
Download Magazines
GNU GPL v3
@sairam
sairam / dnsd.rb
Created January 18, 2013 14:45 — forked from peterc/dnsd.rb
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@sairam
sairam / etc-init.d-redis.conf
Last active October 16, 2018 17:29
Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. This works on Fedora. After adding the description for chkconfig the error "service redis_6379 does not support chkconfig" disappeared.
#!/bin/sh
#
# redis - this script starts and stops the redis daemon
#
# chkconfig: - 85 15
# description: Redis is an open source, BSD licensed, advanced \
# key-value store. It is often referred to as a \
# data structure server since keys can contain \
# strings, hashes, lists, sets and sorted sets.
# processname: redis
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# pidfile: /var/run/nginx.pid
@sairam
sairam / iptables-default
Last active December 19, 2015 10:49
Sample iptables config in digital ocean to only allow 443, 80 and port 22
# Generated by iptables-save v1.4.7 on Mon Jul 8 01:20:10 2013
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [5:1668]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP
-A INPUT -i lo -j ACCEPT