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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>items</key> | |
<array> | |
<dict> | |
<key>assets</key> | |
<array> | |
<dict> |
# First the end result of what we want: | |
class Foo | |
before_hook :whoa | |
before_hook :amazing | |
def test | |
puts "This is kinda cool!" | |
end |
namespace :db do | |
def local_database?(config, &block) | |
if config['host'].in?(['127.0.0.1', 'localhost', '192.168.30.1']) || config['host'].blank? | |
yield | |
else | |
$stderr.puts "This task only modifies local databases. #{config['database']} is on a remote host." | |
end | |
end | |
end |
<?php /* Copyright(c) 2013 Robert Maupin. Released under the ZLIB License. */ | |
if(count($_FILES) > 0) { | |
extract($_FILES['file']); | |
list($w,$h,$type)=getimagesize($tmp_name); | |
/*see exif-imagetype() documentation :) */ | |
if(!$type||$type>3||filesize($tmp_name)>1024*200) | |
exit(); | |
$ext=image_type_to_extension($type,false); | |
$md5=md5_file($tmp_name); | |
move_uploaded_file($tmp_name,$n="img/$md5.$ext"); |
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
require "active_record" | |
namespace :db do | |
db_config = YAML::load(File.open('config/database.yml')) | |
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'}) | |
desc "Create the database" | |
task :create do | |
ActiveRecord::Base.establish_connection(db_config_admin) |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)def ago(elapsed): | |
o = [] | |
for unit, size in [("yr",365*24*60*60),("mo",30*24*60*60),("wk",7*24*60*60),("d",24*60*60),("hr",60*60),("min",60),("sec",1)]: | |
if size > elapsed: continue | |
total = int(elapsed / size) | |
elapsed = elapsed % size | |
o.append(str(total) + unit) |
; An example of YNAB-ish envelope budgetting with hledger/ledger | |
; cf https://github.com/simonmichael/hledger/issues/315 | |
; Using accounts like the following: | |
; | |
; assets | |
; business | |
; bank | |
; wf | |
; bchecking |
I often find myself ssh'ing into my servers and checking my systemd service logs with $ journalctl -f -u {name}.service
. One day I got tired of this and wanted all of my important logs in once place (Amazon AWS Cloudwatch). To my dismay, there weren't any real good tutorials on how to do so. So, voilà.
Overall, it's a fairly simple process consisting of the following few steps.
Open the service file with $ sudo vi /lib/systemd/system/{name}.service
Modify the [Service]
section: