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
#!/bin/bash -ex | |
perl -pi -e 's/^#?Port 22$/Port 443/' /etc/ssh/sshd_config | |
service sshd restart || service ssh restart |
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
from datetime import datetime | |
import math | |
def friendly_ago_string(d): | |
""" | |
Returns a friendly string like "8 minutes ago" representing the | |
differences between now and d. | |
""" | |
if not d or not isinstance(d, datetime): | |
return None |
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
def worker(n): | |
return n**2 | |
squared = mtmap(worker, [2, 3, 4, 5]) | |
#= [4, 9, 16, 25] | |
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
def mtmap(fn, iterable): | |
""" A multi-threaded map(). Must be used with care - large | |
iterables might cause a machine to crash from too many | |
threads. If an exception is thrown in a thread, | |
the iteration stops and that exception is thrown. | |
""" | |
result = {} | |
threads = [] | |
exception_q = Queue.Queue() |
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
/** | |
* @fileOverview Signup page JS code. | |
* @author <a href="mailto:hi@alexmic.com"> Alex Michael </a> | |
* @requires PK.js, facebox.js | |
*/ | |
PK.onPageLoad(function(){ | |
// Once the register page is loaded, make | |
// a request to FB and fill in user fields. |
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
#!/usr/bin/env python | |
import string | |
import os | |
import uuid | |
import mimetypes | |
class Uploader: | |
def __init__(self, request = None): |
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
from swiss import Api | |
from swiss.resources import Resource, Group | |
from swiss.auth import BasicAuth, noauth | |
from swiss.fields import parse, serialize, parselize | |
from swiss.fields import String, Int, Boolean | |
# simple dicts for schemas and serialization | |
schema = { | |
'name': String, |
NewerOlder