Skip to content

Instantly share code, notes, and snippets.

View rajadain's full-sized avatar

Terence Tuhinanshu rajadain

View GitHub Profile
@rajadain
rajadain / graycode.py
Created December 7, 2012 05:24
Graycode generator
def graycode(n):
a = [0]*n
for i in range(0,pow(2,n)):
b = 'X'
for j in range(0,n):
if ((i % pow(2,j+1)) - pow(2,j) == 0):
a[j] = pow(1 - a[j], 2)
b = j
break
print i, "".join((map(str,a)))[::-1], b
@rajadain
rajadain / shorthandles.php
Created December 9, 2012 05:55
Finding Short Twitter Handles
<?php
for ($i = 97; $i < 122; $i++) {
for ($j = 0; $j < 100; $j++) {
$usn = chr($i) . strval($j);
$url="http://api.twitter.com/1/users/show.json?screen_name=".$usn;
$json = file_get_contents($url,0,null,null);
if ($http_response_header[0] == "HTTP/1.1 404 Not Found ")
echo "<p style='color:red'>$usn is available.</p>";
else
echo "<p style='color:grey'>$usn is not available.</p> ";
@rajadain
rajadain / keybase.md
Created March 30, 2014 17:42
Keybase.io verification

Keybase proof

I hereby claim:

  • I am rajadain on github.
  • I am rajadain (https://keybase.io/rajadain) on keybase.
  • I have a public key whose fingerprint is 325A F5CB CCBC 481F E244 1E3A B4E7 1755 48AD 5DBE

To claim this, I am signing this object:

@rajadain
rajadain / ConEmu-MaterialTheme.xml
Last active November 6, 2023 08:57
ConEmu Material Theme
<key name="Colors" modified="2015-12-10 22:46:43" build="151210">
<value name="Count" type="dword" data="00000001"/>
<key name="Palette1" modified="2015-12-10 22:46:43" build="151210">
<value name="Name" type="string" data="Material Theme"/>
<value name="ColorTable00" type="dword" data="004d4335"/>
<value name="ColorTable01" type="dword" data="006b60eb"/>
<value name="ColorTable02" type="dword" data="008de8c3"/>
<value name="ColorTable03" type="dword" data="0095ebf7"/>
<value name="ColorTable04" type="dword" data="00c4cb80"/>
<value name="ColorTable05" type="dword" data="009024ff"/>
@rajadain
rajadain / unstable-warner.js
Last active November 15, 2017 02:01
GitHub Pull Request Unstable Warner Tampermonkey Script
// ==UserScript==
// @name Unstable Warner
// @namespace http://tampermonkey.net/
// @version 0.5
// @description Warn before merging unstable pull requests on GitHub
// @author Terence Tuhinanshu @rajadain
// @match https://github.com/**/pull/*
// @grant none
// ==/UserScript==
@rajadain
rajadain / github-hasklig-fira-code-style.css
Last active February 6, 2019 19:43
Hasklig / Fira Code on GitHub Stylish CSS
@-moz-document domain("github.com"), domain("gist.github.com"), domain("render.githubusercontent.com") {
/* Hasklig https://github.com/i-tu/Hasklig */
/* Fira Code https://github.com/tonsky/FiraCode */
/* Ligaturizer https://github.com/ToxicFrog/Ligaturizer */
.branch-name,
.blob-num,
.blob-code-inner,
.CodeMirror pre,
.commit .sha,
.commit-desc pre,
@rajadain
rajadain / haskellbook-chapter-5-notes.md
Created July 18, 2017 03:25
Haskell Book Chapter 5 Notes and Exercises

Notes and Exercises from Chapter 5 of Haskell Book

Benefits of a type system:

  • Many errors caught before program execution, at compile time
  • Compiler optimizations
  • Documentation of programs
  • Less code to write because you don't have to validate data at every step

Many, perhaps most, programming languages have type systems that feel like haggling with a petty merchant. Haskell provides a type system that more closely resembles a quiet, pleasant conversation with a colleague than an argument in the bazaar.

@rajadain
rajadain / README.md
Last active August 9, 2017 20:44
PNG to GeoTrellis ColorMap

Requirements

Demo

$ ./convert.sh ppt_colorbar.png
+ gm convert ppt_colorbar.png txt:-
@rajadain
rajadain / haskellbook-chapter-10-notes.md
Created August 22, 2017 07:39
Haskell Book Chapter 10 Notes and Exercises

Notes and Exercises from Chapter 10 of Haskell Book

Undefined Spine vs Undefined Item

[1, 2, 3] ++ undefined
 :
@rajadain
rajadain / 11-exercise-phone.hs
Created September 5, 2017 20:10
Haskell Book Chapter 11 Exercise: Phone
-- 11-exercise-phone.hs
module ExercisePhone where
import Data.Char
import Data.List
import Data.Maybe
type Key = Char
type Presses = Int