Skip to content

Instantly share code, notes, and snippets.

View arocks's full-sized avatar

Arun Ravindran arocks

View GitHub Profile
dirs = "NESW" # Notations for directions
shifts=[(0,1),(1,0),(0,-1),(-1,0)] # delta vector for each direction
# One letter function names corresponding to each robot instruction
r = lambda x, y, a: (x, y, (a + 1) % 4)
l = lambda x, y, a: (x, y, (a - 1 + 4) % 4)
m = lambda x, y, a: (x + shifts[a][0], y + shifts[a][1], a)
raw_input() # Ignore the grid size
while 1:
# parse initial position triplet
x, y, dir = raw_input().split()
import Data.List
dirs = "NESW"
shifts 0 = (0, 1)
shifts 1 = (1, 0)
shifts 2 = (0, -1)
shifts 3 = (-1, 0)
instrn (x, y, a) 'R' = (x, y, mod (a + 1) 4)

Serving Django and Twisted using HAproxy

  • on the same IP
  • on the same Port 80

Why?

coming...

Who?

#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
alert("hi")
@arocks
arocks / Emacs-Python
Created April 25, 2015 18:08
Outline of my lightning talk "Emacs and Python" at Bangpypers April 2015
# Emacs and Python
## Why?
## Intro
- Arun Ravindran <arunrocks.com> @arocks
- Emacs user for 15 years
- Python user for 13 years
- Author of "Django Design Patterns and Best Practices"
@arocks
arocks / raffle.py
Created May 1, 2015 09:32
Randomly pick a twitter username n times and show the last picked as winner
# -*- coding: utf-8 -*-
""" raffle - Randomly pick a twitter username n times and show the last picked as winner"""
import random, time
TIMES = 20
entries = """
https://twitter.com/username1
https://twitter.com/username2
https://twitter.com/username3
@arocks
arocks / hangman.py
Last active February 16, 2016 14:54 — forked from danverbraganza/hangman.py
Hangman implemented in 3 lines of Python
# -*- coding: utf-8 -*-
"""A simple text-based game of hangman
A re-implementation of Hangman 3-liner in more idiomatic Python 3
Original: http://danverbraganza.com/writings/hangman-in-3-lines-of-python
Requirements:
A dictionary file at /usr/share/dict/words
Usage:
"""A simple hello application in Python 3.6"""
പേര്: str = input("What is your name? ")
print(f"Hey {പേര്}!")
@arocks
arocks / secret_key.sh
Created February 4, 2019 13:44
Create a new environment variable called SECRET_KEY with a new random value
heroku config:set SECRET_KEY=(python -c 'import random; import string; print("".join([random.SystemRandom().choice("{}{}{}".format(string.ascii_letters, string.digits, string.punctuation)) for i in range(50)]))')