- All processes require checklists.
- Automate everything, and continuously test your automation.
- Do not reinvent the wheel. Defer to idiomatic or popular solutions.
- Everything fails. Anticipate this and offer degraded service.
- Instrument everything.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import sys | |
import string | |
def mapper(input=sys.stdin): | |
reader = csv.DictReader(input) | |
for row in reader: #cycle through lines of code | |
print "%s\t%s" % (row["District"], row["Aadhaar generated"]) | |
mapper() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### MATPLOTLIBRC FORMAT | |
# This is a sample matplotlib configuration file - you can find a copy | |
# of it on your system in | |
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
# there, please note that it will be overridden in your next install. | |
# If you want to keep a permanent local copy that will not be | |
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux | |
# like systems) and C:\Documents and Settings\yourname\.matplotlib | |
# (win32 systems). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOMOGENAKA | |
SPALLYILL | |
ENEUCHSTROKY | |
BOBACHUELESS | |
SYNAPTEPIERAGE | |
HUMBLEENCRATY | |
EMITTERSOMEDAY | |
BUGLETINNLESS | |
BEAUPAINTER | |
TOXEMIASHALLOW |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CodingForInterviewsBitManipulation { | |
public static int setBit(int number, int index, boolean set) { | |
if (set) | |
return number | (1 << index); | |
else | |
return number & (~(1 << index)); | |
} | |
public static boolean getBit(int number, int index) { | |
int result = (number & (1 << index)) >> index; |
- "Courses" are intended for learning Python via an online interactive course.
- "Learning books" are intended for learning Python by reading them cover-to-cover.
- "Reference books" are intended for dipping into randomly as you face particular problems in Python or in general.
All material are specified in order of preference (most to least); all of these
N-Queens solution using naive recursion.
We know all queens must be on distinct columns. Hence for each column recursively attempt each row, terminating if the current configuration with the current subset of columns is invalid.
Validity checking does not need to check if any columns overlap (by definition they do not); we only check if both conditions are false:
- any rows overlap,
placement[i] == placement[j]
, and - any queen lies on the same diagonal as another,
Math.abs(i - j) == Math.abs(placement[i] - placement[j])
This is not the worst solution (the worst involves 64 choose 8 ~= 4 * 10^9!!), but not the best (a DFS graph search would do better). Indeed results show this code is too inefficient above n=14.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------------------------- | |
// Noddy little Tesseract wrapper. | |
// | |
// Usage: | |
// | |
// ./tesseractcli <path to screenshot image> [left] [top] [width] [height] | |
// | |
// - Screenshot path is mandatory, can be relative to current working | |
// directory or absolute. | |
// - Left, top, width, and height are optional integers that set a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayDeque; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Queue; | |
class KTreeNode { | |
Integer value; | |
Collection<KTreeNode> children = new ArrayList<KTreeNode>(); |