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
### Generic Dockerfile demonstrating good practices | |
### Imports | |
# Bad-ish, we do not need Ubuntu for this, nor do we want latest if we are using in a build system, predictable is better | |
FROM ubuntu:latest | |
# Better, using a small image since our app has no dependency on Ubuntu | |
FROM alpine:3.3 |
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
>> engine = ArelBack::Engine.new(ar.connection, Arel::Visitors::MySQL) | |
>> table = Arel::Table.new(ar.table_name, engine) | |
>> table.project(Arel.sql('*')).to_sql | |
=> "SELECT * FROM `awesome_table` " | |
>> |
class ApplicationController | |
private | |
def newrelic_metric_path(action_name_override = nil) | |
format_string = case | |
when request.format.html? | |
'.html' | |
when request.format.json? | |
'.json' | |
when request.format.xml? | |
'.xml' |
I've been playing around with trying to make it as simple as possible to start logging a few metrics with as little effort in setup as possible.
As I was working on Papertrail I came up with a couple interesting ideas, some of which were inspired by OpenTSDB.
In this example we are pretending we're processing emails as background jobs and would like to track how many we've sent over time.
This time bay-beee I'll beeeeeeEEEEEEEEEeeeee - BullehhhhhhhhhhhhhhhT PROOOF. | |
This time may-beee I'll beeeeeeeeeee... Bulleeeeeht proof. |
// paste this into firebug or chrome console or whatever | |
// to load jquery into pages that dun have it | |
j=document.createElement("SCRIPT"); | |
j.src="http://code.jquery.com/jquery-latest.pack.js"; | |
document.getElementsByTagName("HEAD")[0].appendChild(j); |
## Ruby Quiz #666 | |
module CompileSite; end | |
def compile(name, source) | |
CompileSite.class_eval <<-RUBY | |
def #{name}(locals) | |
Thread.current[:tilt_vars] = [self, locals] | |
class << self | |
this, locals = Thread.current[:tilt_vars] |
// See comments below. | |
// This code sample and justification brought to you by | |
// Isaac Z. Schlueter, aka isaacs | |
// standard style | |
var a = "ape", | |
b = "bat", | |
c = "cat", | |
d = "dog", |