Skip to content

Instantly share code, notes, and snippets.

View santhoshtr's full-sized avatar
👷‍♂️
Work in progress

Santhosh Thottingal santhoshtr

👷‍♂️
Work in progress
View GitHub Profile
<script>
s=Math.sin;z=0;d=document;function
a(){for(i=0;i<50;i++){z?0:d.write('<b id=x'+i+' style=position:absolute>&#'+(3333+i)+';</b>');w=i*s(z);o=d.all['x'+i];if(o!=null){r=o.style;r.top=s(w)*i*4+230;r.left=s(w+2)*i*4+230;}}z+=.015;setTimeout('a()',50)}a()
</script>
@santhoshtr
santhoshtr / syllabify-with-index.py
Created May 1, 2011 10:41
syllabify with word and syllable index
#!/usr/bin/python
# -*- coding: utf-8 -*-
texts =[u"वाराणसी", u"भौगोलिक", u"उपदर्शन"]
signs = [
u'\u0902', u'\u0903', u'\u093e', u'\u093f', u'\u0940', u'\u0941',
u'\u0942', u'\u0943', u'\u0944', u'\u0946', u'\u0947', u'\u0948',
u'\u094a', u'\u094b', u'\u094c', u'\u094d']
limiters = ['.','\"','\'','`','!',';',',','?']
virama = u'\u094d'
@santhoshtr
santhoshtr / 0_urllib2.py
Created August 17, 2011 06:33 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@santhoshtr
santhoshtr / listglyphsofthefont.py
Created August 21, 2011 16:44
List the glyph properties of the Font
import fontforge
font = fontforge.open("/usr/share/fonts/truetype/ttf-malayalam-fonts/Meera_04.ttf", 4)
print "Glyphs"
for (i,g) in enumerate(font.glyphs()):
print "%s\t%s\t%s\t%s\t%s\t%s\t%s"%(i,g.glyphname,g.glyphclass,g.script,g.encoding,g.unicode,g.getPosSub("*"))
print "GSUB Lookups"
for (i,g) in enumerate(font.gsub_lookups):
print "%s\t%s"%(i,g)
print "GPOS Lookups"
for (i,g) in enumerate(font.gpos_lookups):
@santhoshtr
santhoshtr / numbergrouping.php
Created September 13, 2011 17:30
Format a number using given format
<?php
function formatNumber($format, $string)
{
$numMatches = preg_match_all("/(#+)/", $format, $matches);
preg_match("/\d+/", $string, $numberpart);
preg_match("/\.\d*/", $string, $decimalpart);
$groupedNumber = (count($decimalpart)>0)?$decimalpart[0]:"";
$start = $end = strlen($numberpart[0]);
if($numMatches==0){
return $string;
@santhoshtr
santhoshtr / undocumentedmessages.php
Created January 25, 2012 14:21
List messages without documentation in mediawiki i18n files
<?php
if ( PHP_SAPI !== 'cli' )
{
exit( 1 );
}
if( !isset($argv[1]) || $argv[1] === "-h" ){
echo "Usage: php undocumentedmessages.php i18nfile \n";
exit( 0 );
}
$i18nfile = $argv[1];
@santhoshtr
santhoshtr / levenshtein.php
Created January 31, 2012 15:00
levenshtein in php, supports multibyte characters
<?php
function levenshtein_php($str1, $str2){
$length1 = mb_strlen( $str1, 'UTF-8');
$length2 = mb_strlen( $str2, 'UTF-8');
if( $length1 < $length2) return levenshtein_php($str2, $str1);
if( $length1 == 0 ) return $length2;
if( $str1 === $str2) return 0;
$prevRow = range( 0, $length2);
$currentRow = array();
for ( $i = 0; $i < $length1; $i++ ) {
@santhoshtr
santhoshtr / levenshtein.js
Created August 10, 2012 08:59 — forked from IgorInger/levenshtein.js
Levenshtein distance- Javascript
var levenshteinDistance = function(u, v) {
var m = u.length;
var n = v.length;
var D = [];
for(var i = 0; i <= m; i++) {
D.push([]);
for(var j = 0; j <= n; j++) {
D[i][j] = 0;
}
}
@santhoshtr
santhoshtr / gitstats
Created August 17, 2012 04:59
Git stats
# Number of contributors to the project
git log --pretty='%aN'|sort -u|wc -l
# Total commits made
git log --oneline | wc -l
# NUmber of lines written/modified
git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/;'
# Top 5 contributos all time
@santhoshtr
santhoshtr / eclipse-mediawiki-js.xml
Created August 31, 2012 14:22
Eclipse formatter xml for Mediawiki style javascript code
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="11">
<profile kind="CodeFormatterProfile" name="mediawiki" version="11">
<setting id="org.eclipse.wst.jsdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.wst.jsdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.wst.jsdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.wst.jsdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.wst.jsdt.core.formatter.alignment_for_compact_if" value="16"/>