p = {
'name': 'Ystr',
'age': 119,
'skills': ['spamming', 'egging']
}
print(p['name']) # => Ystr
print(p['skills'][1]) # => egging
This file contains hidden or 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
from rx import Observable, Observer | |
from collections import defaultdict | |
users = [ | |
{ "id" : 0, "name" : "Hero" }, | |
{ "id" : 1, "name" : "Dunn" }, | |
{ "id" : 2, "name" : "Sue" }, | |
{ "id" : 3, "name" : "Chi" }, | |
{ "id" : 4, "name" : "Thor" }, | |
{ "id" : 5, "name" : "Clive" }, |
This file contains hidden or 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
#!/usr/bin/env python | |
import fileinput | |
import sys | |
# Reverse each incoming line | |
input_lines = fileinput.input(sys.argv[2:]) | |
for line in input_lines: | |
line = line.strip()[::-1] + '\n' | |
sys.stdout.write(line) |
This file contains hidden or 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
#!/usr/bin/env python | |
import math | |
from Crypto.Util.number import * | |
import Crypto.PublicKey.RSA as RSA | |
with open('key1','r') as f1, open('key2', 'r') as f2: | |
# Short n | |
n1 = long(f1.readline().strip()) | |
# Long n |
This file contains hidden or 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
#!/usr/bin/env python | |
from pwn import * | |
from itertools import permutations | |
def check_palindrome(s): | |
length = len(s) | |
half = length / 2 | |
return s[:half] == s[-half:][::-1] |
This file contains hidden or 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
<!DOCTYPE html> | |
<!-- Source: http://bl.ocks.org/gka/17ee676dc59aa752b4e6 --> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
.dash { width: 100%; } | |
table, #toggles { display: inline-block; } | |
Inspired by Building robust software in Python using unit tests. I didn't want to bother with fswatch, and I found a similar script in the pyinotify wiki.
With the included Makefile, you can just run make dev_test
,
and your tests will execute whenever you make an edit! Better for the early stages of a TDD project.
Note that you can add more than just .py
files. autotest.py ~/path/to/project .py,.js,.html "clear && make tests"
will run your test suite whenever you create, delete, or edit a file with a .py, .js, or.html extension.
NewerOlder