Skip to content

Instantly share code, notes, and snippets.

View santosh's full-sized avatar
:octocat:

Santosh Kumar santosh

:octocat:
View GitHub Profile
@santosh
santosh / python_keywords.py
Created February 26, 2013 07:22
This script lists the python keywords. Its portable so running as $ python python_keywords.py will list for Python 2 and $ python3 python_keywords.py will return for Python 3. Basically it will list the keywords of the current interpreter.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import sys
import keyword
'''
File: python_keywords.py
Author : Santosh Kumar <https://twitter.com/sntshk>
Date created: Fri 22 Feb 2013 07:00:09 PM IST
@santosh
santosh / raw_input.py
Created March 13, 2013 11:41
Erase conflict between input() and raw_input().
try:
input = raw_input
except NameError:
pass
@santosh
santosh / printflush.py
Created March 25, 2013 09:18
This script demonstrate the `flush` argument of print() function.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
from __future__ import print_function
from time import sleep
string = "The words in this sentence should appear letter by letter."
print("Please wait if you don't see another sentence appearing below.", end="\n\n")

English to rövarspråket converter

Call it like:

$ ./e2r.py "the english string"

Or import it into script:

from e2r import e2r
@santosh
santosh / numerical2words.c
Created October 4, 2013 01:19
Generate English words for given 'base 10' numbers, limited to 01-99.
/**
* File: numerical2words.c
* Author: Santosh Kumar <sntshkmr60@gmail.com>
* Date created: Tue 1 Oct 2013 09:27:49 IST
* Description: Translate numerical digit to English words, ranging 01 to 99
*/
#include <stdio.h>
#include <string.h>
@santosh
santosh / changebase.c
Created October 8, 2013 01:38
Program to convert a base 10 integer to base 2, 8 and 16.
/**
* File: 7.7.c
* Author: Santosh Kumar <sntshkmr60@gmail.com>
* Date created: Tue 08 Oct 2013 06:33:28 IST
* Description: Program to convert a positive integer to another base
* Taken from 'Programming in C' book.
*/
#include <stdio.h>
@santosh
santosh / crazify.py
Created October 12, 2013 05:13
Converts a "string" into "StRiNg".
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
from __future__ import print_function
import sys
var = sys.argv[1:]
def crazify(string):
"""Converts first index of string to uppercase followed by lowercase and so on.
@santosh
santosh / num_of_cores.cpp
Created January 26, 2015 15:26
get the number of cores
#include <thread>
unsigned int nthreads = std::thread::hardware_concurrency();
@santosh
santosh / randLocation.py
Created May 20, 2015 06:59
Create multiple poly objects and translate it to random locations. #AutodeskMaya
import maya.cmds as mc
import random
for i in range(5):
x = random.uniform(-10.0, 10.0)
y = random.uniform(-10.0, 10.0)
z = random.uniform(-10.0, 10.0)
mycube = mc.polyCube(h=2, w=2, d=2, n="Object#")
mc.move(x, y, z, mycube)
@santosh
santosh / noteredirect.php
Created June 28, 2015 03:53
Collect useragent and ipaddress data from friends. I created this note redirect script to do the same. They were pointed to this script saying that they will be shown a note they must read.
<?php
/*
@scriptName: noteredirect.php
@author: Santosh Kumar
@authorURL: http://sntsh.com
*/
// set the content type which is read by browser
header("Content-type: text/plain");