Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db |
BEGIN { | |
require 'net/http' | |
Net::HTTP.module_eval do | |
alias_method '__initialize__', 'initialize' | |
def initialize(*args,&block) | |
__initialize__(*args, &block) |
class MigrateUserToDevise < ActiveRecord::Migration | |
def self.up | |
change_table :users do |t| | |
t.string :encrypted_password, :null => false, :limit => 128 | |
# ... | |
end | |
end | |
def self.down | |
end |
namespace :assets do | |
desc "Check that all assets have valid encoding" | |
task :check => :environment do | |
paths = ["app/assets", "lib/assets", "vendor/assets"] | |
extensions = ["js", "coffee", "css", "scss"] | |
paths.each do |path| | |
dir_path = Rails.root + path |
#!/bin/bash | |
case "${1:-''}" in | |
'start') | |
# start commands here | |
/opt/nginx/sbin/nginx | |
;; | |
'stop') | |
# stop commands here | |
kill `cat /opt/nginx/logs/nginx.pid` |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
Sprockets::Helpers::RailsHelper::AssetPaths.class_eval do | |
class MissingAssetError < StandardError; end | |
def digest_for_with_presence_check(logical_path) | |
unless asset_environment[logical_path] | |
raise MissingAssetError.new("#{logical_path} doesn't exist") | |
end | |
digest_for_without_presence_check(logical_path) | |
end | |
alias_method_chain :digest_for, :presence_check |
class Foo | |
def self.bar(&block) | |
block.call(42) | |
end | |
end | |
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
Dispatch::Queue.concurrent(:low).async do | |
Foo.bar{|res| p "the answer is #{res}"} |
class MyController < UIViewController | |
def viewDidLoad | |
@button = UIButton.alloc.init | |
@button.when_tapped do | |
weak_self = WeakRef.new(self) # <--- create a weak reference to self | |
@alert = UIAlertView.alertViewWithTitle "Alert", | |
message: "Message", | |
cancelButtonTitle: "Dismiss", |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000