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
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
Press minus + shift + s
and return
to chop/fold long lines!
brew install ImageMagick
ffmpeg -ss 14:55 -i video.mkv -t 5 -s 480x270 -f image2 %04d.png
import java.awt.*; | |
import javax.swing.*; | |
import java.awt.event.*; | |
/********************************** | |
This is the main class of a Java program to play a game based on hexagonal tiles. | |
The mechanism of handling hexes is in the file hexmech.java. | |
Written by: M.H. | |
Date: December 2012 |
authors: | |
hanzou: | |
name: Hanzou Hattori | |
display_name: Hanzou | |
gravatar: c66919cb194f96c696c1da0c47354a6a | |
email: hanzou@company.com | |
web: http://company.com | |
twitter: company | |
github: hhattori | |
jorgen: |
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.
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.
module Excel | |
module Formulas | |
def pmt(rate, nper, pv, fv=0, type=0) | |
((-pv * pvif(rate, nper) - fv ) / ((1.0 + rate * type) * fvifa(rate, nper))) | |
end | |
def ipmt(rate, per, nper, pv, fv=0, type=0) | |
p = pmt(rate, nper, pv, fv, 0); | |
ip = -(pv * pow1p(rate, per - 1) * rate + p * pow1pm1(rate, per - 1)) | |
(type == 0) ? ip : ip / (1 + rate) |