Skip to content

Instantly share code, notes, and snippets.

View kra3's full-sized avatar
🤠
I may be slow to respond.

Arun Karunagath kra3

🤠
I may be slow to respond.
View GitHub Profile
@kra3
kra3 / gist:7398319
Last active December 27, 2015 22:19
udacity
#Define a procedure, collatz_steps, that takes as input a positive integer, n, and returns
#the number of steps it takes to reach 1 by following these steps:
# If n is even, divide it by 2. (You can test for evenness using n % 2 == 0.)
# If n is odd, replace it with 3n + 1.
def collatz_steps(n):
process = lambda x: x/2 if x % 2 == 0 else 3 * x + 1
if n==1:
@kra3
kra3 / gist:7070117
Created October 20, 2013 14:07
fish names
http://recipes.malayali.me/english-malayalam-fish-names
Aiyla – Mackerel
Mathi/Chaala – Sardine
Avoli – Pomfret
Aakoli – Silver Moony
Choora – Tuna
Kora / Kaala – Salmon
Ney Meen – Seer Fish / Queen Fish
Kari Meen – Pearl Spot/ Green Chromide
@kra3
kra3 / README.md
Created October 13, 2013 12:16 — forked from nikcub/README.md
@kra3
kra3 / gist:6941152
Last active December 25, 2015 07:39
Remove file extension from urls (Apache specific)

To remove file extention:

Use mode_rewrite

Add following in your .htaccess (is one way of doing this)

eg: (will remove .php from url, cange it to .html, .jsp, etc to tailor your needs)

ps: This is not a drop in solution (you may want to customise/check more conditions further)

@kra3
kra3 / viadeo.js
Last active December 24, 2015 04:39
viadeo invitation mess cleanup
/* I'm too lazy to automoate full process
*
* 1. Go to http://www.viadeo.com/addressbook/pendinginvitations/
* 2. Run the following in firebug (to remove a invite resend to any contacts listed there)
*
* Why I have to do this: There's no "select all and remove" option and all my 600+ contacts are in the resend loop.
*
* Being in the browser means, no nead for authentication codes (lazy, remember)
*/
@kra3
kra3 / django_south_demystified.sh
Last active December 23, 2015 11:01
Django south demystified
# Install and south to your django app
pip install south
# Add south to INSTALLED_APPS list of settings.py
vi settings.py
#-------------------------------------------
# A syncdb will create required south tables (now on only use `migrate` command)
python manage.py syncdb
## PS: (migration) generations are kept in a `/migrate/` sub directory of apps and are simple python files.
@kra3
kra3 / license.md
Last active December 21, 2015 00:59 — forked from hmarr/gist:1013596
Couple of virtualenvwrapper hooks
@kra3
kra3 / _readme.md
Created August 5, 2013 13:19 — forked from mislav/_readme.md

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@kra3
kra3 / timeexec.py
Last active December 14, 2015 22:59
Decorators to time function executions. - timeit: time the function execution time - repeater: repeat the function calls `N times` times.
def timeit(func):
def wrapper(*args, **kwargs):
t1 = time.time()
res = func(*args, **kwargs)
t2 = time.time()
log.info("______________________Function: %s, Time=%s", func.__name__, t2-t1)
return res
return wrapper
@kra3
kra3 / mysql_quick_back.sh
Created November 21, 2012 13:35
Shell script to backup all dbs of MySQL server.
#!/bin/bash
# $Id: mysql_quick_back.sh 31 2007-03-13 19:57:40Z damonp $
#
# Shell script to backup all dbs of MySQL server.
#
# Copyright (c) 2007 Damon Parker < damonp@damonparker.org >
# Licensed under the GNU GPL. See http://www.gnu.org/licenses/gpl.html
# This script is not supported in any way. Use at your own risk.