Note: this is a reasonably faithful verbatim transcript of a live conference lightning talk, not a re-worked blog format presentation of this content.
Links:
- [Slides][]
- [YouTube recording of presentation][]
- [Lanyrd entry][]
/** | |
* When browser supports inline pdfs | |
* There is no need to append a large jquery plugin that displays them inline. | |
* | |
* You can actually use an iframe (and style it appropriately) | |
* or a link whenever inline PDF viewing is not supported | |
* | |
* This function is fairly simple and it's only for demo purposes | |
*/ | |
function appendPdf(id, url) { |
This is a list of tips for the Vim editor
require 'mongo' | |
require 'ap' | |
include Mongo | |
# Create a connection to a local MongdDB Instance | |
db = Connection.new.db('underscore-demo') | |
# Read and eval Underscore.js | |
underscore = File.read('underscore-min.js') |
tell application "Finder" | |
open item "System:Library:Input Methods:CharacterPalette.app" of the startup disk | |
end tell |
on run {input, parameters} | |
tell application "Finder" | |
set sel to selection | |
if (count sel) > 0 then | |
set myTarget to item 1 of sel | |
else if (count window) > 0 then | |
set myTarget to target of window 1 | |
else | |
set myTarget to path to home folder | |
end if |
#!/usr/bin/env python | |
import SimpleHTTPServer | |
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_my_headers() | |
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self) | |
def send_my_headers(self): |
Ignoring the cache: Composer doesn't have an option to make it ignore its cache while running a command. The Composer developers do not believe this is an important feature and they refused an issue opened to request it. However, it can be helpful for debugging dependency installation. To make a single Composer command (e.g., composer update
) ignore the cache, use one of the following:
This version generates innocuous, ignorable errors about the cache directory:
COMPOSER_CACHE_DIR=/dev/null composer update
# Play a blues melody on Pythonista on the iPad (iOS) | |
import sound | |
import time | |
def playNotes(inNotes, inWithEmphisis=False): | |
for note in inNotes: | |
sound.play_effect('Piano_' + note) | |
if (inWithEmphisis): | |
time.sleep(0.25) | |
sound.play_effect('Piano_' + note) |
# Demo of how to generate a list of prime numbers and cache them | |
# in a data file for fast access (using the marshal module). | |
def gen_primes(n): | |
# Source: http://code.activestate.com/recipes/366178-a-fast-prime-number-list-generator/#c19 | |
s = range(0, n+1) | |
s[1] = 0 | |
bottom = 2 | |
top = n // bottom | |
while (bottom * bottom <= n): |