Skip to content

Instantly share code, notes, and snippets.

@peterjmag
peterjmag / reddit-comment-depth.py
Created December 30, 2011 09:16
A terribly inefficient script to determine the depth of a comment in a Reddit thread
#!/usr/bin/env python
# encoding: utf-8
"""
reddit-comment-depth.py
Created by peterjmag on 2011-12-30.
"""
import urllib2
import simplejson as json
@peterjmag
peterjmag / letters-to-100.py
Created September 20, 2012 02:46
Find English words whose letter values add up to 100
#!/usr/bin/env python
# encoding: utf-8
"""
letters-to-100.py
"""
import string
letter_values = dict((l, i) for i, l in enumerate(string.lowercase, start=1))
english_dict = open('/usr/share/dict/words', 'rU')
Anything added dilutes everything else.
Approachable is better than simple.
Avoid administrative distraction.
Design for failure.
Encourage flow.
Favor focus over features.
Half measures are as bad as nothing at all.
It's not fully shipped until it's fast.
Keep it logically awesome.
Mind your words, they are important.
/*
* Visit http://benzguo.com/bayan/ and paste this in your console.
*
* Originally from https://news.ycombinator.com/item?id=8217872, adapted
* to handle non-alpha characters like commas and semicolons.
*/
// SETTINGS
// var input = "rsa ecde srgu yhgr bv rsa ecde srgu yhgr bv hybtg ser erv";
// input += " hybtg iii r hybtg ser erv tvr rrr rvgres rrr rvg rrr rvgres ";
diff --git parker.js parker.js
index 48fa2fd..5d9b05b 100755
--- parker.js
+++ parker.js
@@ -25,6 +25,10 @@ cliController.on('runPaths', function (filePaths) {
var stylesheets = [];
async.each(filePaths, function (filePath, onAllLoad) {
var onFileLoad = function (err, data) {
+ if (err) {
+ console.log(err);
@peterjmag
peterjmag / react-native-talk.md
Last active June 21, 2021 10:13
Let's build a React Native app in 20 minutes - React Berlin #1 (April 2015)
@peterjmag
peterjmag / android-stuff.txt
Last active August 12, 2016 22:43
Some more code from the background in Ex Machina
struct state {
struct wakelock wakelock;
}
init() {
wake_lock_init(&state->wakelock, WAKE_LOCK_SUSPEND, "wakelockname");
}
Before freeing the memory, wake_lock_destroy must be called:
uninit() {
wake_lock_destroy(&state->wakelock);
}
@peterjmag
peterjmag / awesome-example.md
Last active August 29, 2015 14:21
the-node-ecosystem-is-ridiculous challenge of the day: What's the best thing you can write using *only* valid + existing npm module names?
@peterjmag
peterjmag / TextWithLineBreaks.jsx
Created August 30, 2015 21:30
TextWithLineBreaks React component
var _ = require('lodash');
var React = require('react');
module.exports = React.createClass({
displayName: 'TextWithLineBreaks',
render: function () {
var nodes = [];
var fragments = this.props.text.split('\n');
var key = 0;
@peterjmag
peterjmag / gource.sh
Last active January 31, 2024 00:41 — forked from XueshiQiao/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install