Skip to content

Instantly share code, notes, and snippets.

@Jach
Jach / .htaccess
Created January 5, 2011 02:49
micro-framework pieces
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.php|imgs|js|css|flex|public|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
@Jach
Jach / encryption.py
Created June 8, 2011 06:53
Caesar, ROT13 encryption/decryption
import collections
import string
def rotate(lst, amount):
items = collections.deque(lst)
items.rotate(amount)
return items
def rotate_str(str, amount):
return ''.join(rotate(str, amount))
@Jach
Jach / crab_canon.mxml
Created June 11, 2011 13:51
crab canon helper/maker
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
<s:layout>
<s:VerticalLayout paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10" />
</s:layout>
<fx:Declarations>
</fx:Declarations>
<s:TextArea id="norm" change="alter();" width="100%" height="100%" />
@Jach
Jach / pw.sh
Created July 1, 2011 13:43
Random password generator, remember a passphrase + unique key (such as sitename)
#!/bin/sh
# Prints out (highly likely at least) 64 random characters, along with some truncations for common password length limits.
# Shows random characters in the printable set as well as just alpha-numeric.
# get rid of -s flag if you want to see what you type
# (possible enhancement for people who typo a lot: read into $p2 as well and only proceed if the entries are equal.)
read -s p
hash=`echo -n $p | sha256sum | sed -e 's/-//' | sed -e 's/ //'`
hash=`python -c "import random, sys, struct; random.seed(0x$hash); bits=[random.getrandbits(64) for i in range(200)]; sys.stdout.write(struct.pack('Q'*len(bits), *bits)); print"`
hash2=`echo $hash | tr -cd "[:graph:]" | head -c ${1:-64}`
@Jach
Jach / NetworkServiceImpl1.java
Created August 4, 2011 19:02
Coding style comparison...
// ....
public RepositoryHolder getRepositories() throws AppException {
final String query = "select id, repo_url from localdb.sys_network.repositories";
List<Repository> repo_list = new ArrayList<Repository>();
Repository master = new Repository();
DB.execute(query, master, repo_list);
RepositoryHolder ret = new RepositoryHolder();
ret.repositories = repo_list;
@Jach
Jach / number_hack.py
Created September 10, 2011 11:44
Overrides the Python integer five to be equal to four with ctypes magic
import sys
import ctypes
pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5))
five = ctypes.cast(id(5), pyint_p)
print(2 + 2 == 5) # False
five.contents[five.contents[:].index(5)] = 4
print(2 + 2 == 5) # True (must be sufficiently large values of 2 there...)
@Jach
Jach / gist:1448054
Created December 8, 2011 18:58
Stuff from LOL translated into Clojure
; listing 1.4: group
(defn group [coll n]
(if (zero? n)
(throw (Exception. "zero length"))
(partition-all n coll)))
; listing 1.5: flatten
; built-in
; listing 1.6: fact-and-choose
@Jach
Jach / clipboard.py
Created December 21, 2011 13:32
System clipboard getter/setter
# Is this a stupid pattern?
def clipboard(text=None):
'''
Given no argument, returns the contents of the system clipboard or
None if empty.
Given an argument string, sets that as the value of the system clipboard and
returns the given string.
Note: The presence of calling this function will result in the system
clipboard being flushed on program termination.
@Jach
Jach / mig.py
Created December 30, 2011 04:09
Dirty migration script from Jira issues to Github issues
'''
Steps:
1. Create any milestones
2. Create any labels
3. Create each issue, linking them to milestones and labels
3.1: Update status for new issue if closed
4: Create all the comments for each issue
'''
import getpass
import json
@Jach
Jach / gist:1610886
Last active March 10, 2024 11:51
Book Reading List Queue

My ideal goal is to read at least one book a month, on average, or 12 per year. (Yay success in 2018, 2020-2022.) I've been very bad at this goal before but still have it. This is a mostly most-recent-first sorted non-exhaustive list of books (sometimes papers or short articles too) I've read with short 'reviews' or thoughts. There are spoilers since this list is mainly meant for myself. At the end there is a non-exhaustive non-sorted list of books I'd like to read before I die.

I may eventually sort these by subject as the list or my desire to procrastinate grows, and maybe go through change logs and memory to try and annotate when a book was actually read -- maybe even add all the books I read before I started this log, even if I don't recall the plot very well. Finally, here's a link to my Amazon Wish List in case you're looking for gifts. ;) http://www.amazon.com/gp/registry/wishlist/225QQLO3JIGTL


2024

Raft - Stephen Baxter - https://www.amazon.com/Raft-Stephen-Baxter-author/dp/1473224055/