Skip to content

Instantly share code, notes, and snippets.

@sids
sids / xml_twig.pl
Created July 24, 2008 10:30
Perl: XML Parsing and creation examples.
#!/usr/bin/perl
use strict; use warnings;
use XML::Twig;
my $t= XML::Twig->new( twig_handlers =>
{
'level(2)' => \&filter_doc
},
pretty_print => 'indented',
output_filter => 'safe'
@sids
sids / README
Created July 24, 2008 11:01
Perl: Unicode handling
http://gist.github.com/2118
Unicode handling in Perl.
@sids
sids / PackTest.java
Created July 24, 2008 11:30
Perl: I/O examples
import java.io.DataOutputStream;
public class PackTest {
public static void main (String[] args) throws Exception {
DataOutputStream out = new DataOutputStream(System.out);
out.writeInt(11351);
out.flush();
}
}
@sids
sids / README
Created July 24, 2008 12:20
Perl: database handling examples
http://gist.github.com/2125
Examples of database handling in Perl.
@sids
sids / gist:5209
Created August 13, 2008 07:06
Linux: Setting up auxiliary swap
# setting up auxiliary swap in linux
dd if=/dev/zero of=/auxswap bs=1M count=2048
mkswap /auxswap
swapon /auxswap
# trun it on:
swapon -s
# turn it off:
@sids
sids / sshd_config
Created August 13, 2008 09:22
Linux: sshd config tips
# sshd config tips
# add these lines at the end of /etc/ssh/sshd_config
# don't try reverse-dns lookup on connecting clients (this speeds up the initial connection establishment a lot):
UseDNS no
# make sure the client does not get disconnect due to being idle (ping every 5 mins):
ClientAliveInterval 300
@sids
sids / gist:9850
Created September 10, 2008 08:01
git tips
## setup
git config user.name "Siddhartha Reddy"
git config user.email ""
## setup -- global
git config --global user.name "Siddhartha Reddy"
git config --global user.email ""
git config --global color.branch "auto"
git config --global color.status "auto"
git config --global color.diff "auto"
@sids
sids / Recipe: Tomato Pappu
Created October 21, 2008 14:52
Mom's recipe for Tomato Pappu :)
Recipe: Tomato Pappu
^^^^^^^^^^^^^^^^^^^^
Ingredients
===========
Toor Dal : 1 measure
Tomatoes : 4-5 measures
Turmeric Powder : a pinch
Oil : 1 tea spoon / measure
@sids
sids / uri_escape.pl
Created October 29, 2008 09:10
Perl: URI encoding/decoding
#!/usr/bin/perl
use strict; use warnings;
use URI::Escape;
# http://www.perlhowto.com/encode_and_decode_url_strings
my $string = "Hello world!";
my $encode = uri_escape($string);
print "Original string: $string\n";
@sids
sids / domain.htaccess
Created July 11, 2009 09:53
Apache mod_rewrite tricks
### Forcing a particular domain ###
RewriteCond %{HTTP_HOST} !^www.sids.in$ [NC]
RewriteRule ^(.*)$ http://www.sids.in$1 [R=301,L]