It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
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 bash | |
set -e | |
if [ -e static ]; then | |
rm -r static | |
fi | |
mkdir -p static | |
sass src/sass/main.scss > static/application.css | |
$(npm bin)/browserify src/js/main.js > static/application.js |
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 collections import namedtuple | |
from datetime import date | |
# Here's a user defined using the usual "OO" style. | |
class UserClass: | |
def __init__(self, first, last, birthday): | |
self.__first = first | |
self.__last = last | |
self.__birthday = birthday |
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
$ heroku pg:backups | |
Installing Heroku Toolbelt v4... done. | |
For more information on Toolbelt v4: https://github.com/heroku/heroku-cli | |
Setting up node-v4.1.1... done | |
Installing core plugins heroku-cli-addons, heroku-apps, heroku-fork, heroku-git, heroku-local, heroku-run, heroku-status... | |
▸ | |
Error reading plugin: heroku-apps. See /Users/grb/.heroku/error.log for more information. | |
Error reading plugin: heroku-cli-addons. See /Users/grb/.heroku/error.log for more information. | |
Error reading plugin: heroku-fork. See /Users/grb/.heroku/error.log for more information. | |
Error reading plugin: heroku-git. See /Users/grb/.heroku/error.log for more information. |
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
failbowl:~(master) $ curl 'http://maps.google.com/?saddr=St.%20Petersburg%20Shavrova%2015&daddr=St.%20Petersburg%20Sadovaya%2030&dirflg=r&output=json' | |
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> | |
<TITLE>302 Moved</TITLE></HEAD><BODY> | |
<H1>302 Moved</H1> | |
The document has moved | |
<A HREF="http://maps.google.com/maps?saddr=St.%20Petersburg%20Shavrova%2015&daddr=St.%20Petersburg%20Sadovaya%2030&dirflg=r&output=json">here</A>. | |
</BODY></HTML> | |
failbowl:~(master) $ curl 'http://maps.google.com/maps?saddr=St.%20Petersburg%20Shavrova%2015&daddr=St.%20Petersburg%20Sadovaya%2030&dirflg=r&output=json' | |
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> |
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
CyBurTaz: i programed my comps memory to read my own lang | |
RAVERgrl34: LoL... oh muh god! | |
CyBurTaz: FOXXY STFU | |
RAVERgrl34: you are a piece of shit! | |
RAVERgrl34: ROFL | |
RAVERgrl34: LMAO | |
RAVERgrl34: oh muh god! | |
RAVERgrl34: you are lamest mother fucking i have ever seen! | |
RAVERgrl34: oh muh god, you are lame. |
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 adjust(t,h);(3*h)−(4*t*h);end | |
def adjust(t,h);(3*h)-(4*t*h);end |
(A book that I might eventually write!)
Gary Bernhardt
I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.
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
module TwitterLib | |
def self.authenticate | |
libs = [Twitter, TweetStream] | |
libs.each do |lib| | |
lib.configure do |config| | |
config.consumer_key = ENV.fetch("TWITTER_CONSUMER_KEY") | |
config.consumer_secret = ENV.fetch("TWITTER_CONSUMER_SECRET") | |
config.oauth_token = ENV.fetch("TWITTER_OAUTH_TOKEN") | |
config.oauth_token_secret = ENV.fetch("TWITTER_OAUTH_SECRET") | |
end |
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
# This is a stripped-down example based on Selecta's TTY handling. We store the | |
# TTY state in `tty_state`, then go into an infinite loop. When the loop is | |
# terminated by a ^C, we try to restore the TTY state. It's important that this | |
# work, but it doesn't in some subtle situations, and I don't know why. | |
# | |
# Save this file as test.rb and run it via this command, where `stty` should | |
# successfully restore the TTY state: | |
# bash -c 'echo | ruby test.rb' | |
# | |
# Next, run it via this command, where `stty` should fail to restore the TTY |