Skip to content

Instantly share code, notes, and snippets.

from subprocess import call
# List of programs to install.
programs = [
# "Essential" utilities:
"sudo", # the minimal install on Debian doesn't come with this
"vim",
"vim-gtk", # for gundo, which requires python
"python",
"python3",
snippet hash "insert sha1 hash of the current file"
`!v strpart(system("sha1sum ".expand("%")), 0, 40)`
endsnippet
@riceissa
riceissa / inter.py
Created January 10, 2015 20:48
find the intersection of characters given a list of strings
# Fencepost loop using dictionaries.
def inters_dict(lst):
dct = {ch: True for ch in lst[0]}
for s in lst[1:]:
dct = {ch: True for ch in s if ch in dct}
return dct.keys()
# I suspect Pythonistas would find the use of (ch, True) as key-value
# pairs to be jarring, so here it is using sets---essentially, the
# "True" part is implied by virtue of being in the set.
@riceissa
riceissa / max_subarray.py
Created April 16, 2015 02:33
max subarray
#!/bin/python3
from math import floor, ceil
def max_subarray_brute_force(A):
'''
Given a list, return a tuple (low_index, high_index, max_sum), where
low_index and high_index give the starting and ending indices (both
inclusive) of the maximum subarray, and max_sum gives the sum of
that subarray.
@riceissa
riceissa / screenshotter.sh
Created May 13, 2015 02:14
randomly screenshot
#!/bin/bash
while true; do
sleep $[($RANDOM % 10) * 100 + ($RANDOM % 10) * 10 + ($RANDOM % 10) + 1]s
scrot ~/Pictures/%Y-%m-%d_%T_scrot.png
done
@riceissa
riceissa / filter_out_chinese.py
Created June 18, 2015 05:23
filter out Chinese chars
#!/usr/bin/python3
# From http://stackoverflow.com/a/9169489
c1 = (set(range(0x4E00, 0xA000)) |
set(range(0x3400, 0x4DC0)) |
set(range(0x20000, 0x2A6E0)) |
set(range(0x2A700, 0x2B740)) |
set(range(0x2B740, 0x2B820)) |
set(range(0xF900, 0xFB00)) |
set(range(0x2F800, 0x2FA20)) |
@riceissa
riceissa / reddit
Last active August 29, 2015 14:23
cognito mentoring info wiki reddit page
[https://www.reddit.com/ Reddit] is an online discussion and content sharing site that has been called the "front page of the internet". Despite the impressive volume of information on Reddit, it's probably underused by young people as a source of intellectual content due to the site's difficult navigation, [[Wikipedia:Reddit#Controversies_involving_reddit|controversiality]], and general lack of awareness as a place to discover intellectual content.
In general the signal-to-noise ratio on Reddit is low (lower than on sites like [[Quora]] or LessWrong), but since many more people use Reddit than Quora or LessWrong, there is still possibly more total opportunities to discover interesting content or connect with smart people there. Moreover, developing the ability to [https://www.quora.com/What-are-the-most-underrated-life-skills/answer/Alex-K-Chen sort through low-quality content for good information] may prove useful.
On this page we describe some considerations on how to get the most out of Reddit.
==Gene
<html>
<head><title>hello, world!</title></head>
<body>
<p>hello!</p>
</body>
</html>
@riceissa
riceissa / .nvimrc
Last active August 29, 2015 14:26
nvimrc
" This is free and unencumbered software released into the public
" domain.
"
" Anyone is free to copy, modify, publish, use, compile, sell, or
" distribute this software, either in source code form or as a compiled
" binary, for any purpose, commercial or non-commercial, and by any
" means.
"
" In jurisdictions that recognize copyright laws, the author or authors
" of this software dedicate any and all copyright interest in the
>>> A = [1, 2]
>>> B = [3, 4]
>>> for i in A:
... for j in B:
... print((i,j))
...
(1, 3)
(1, 4)
(2, 3)
(2, 4)