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 | |
# jekyll Starts and stops Jekyll | |
# | |
# | |
# chkconfig: - 85 15 | |
# description: Jekyll is a Ruby based website caching engine | |
# processname: jekyll | |
# pidfile: /var/run/jekyll.pid | |
# Configure your values here |
namespace :db do | |
require "sequel" | |
Sequel.extension :migration | |
DB = Sequel.connect(ENV['DATABASE_URL']) | |
desc "Prints current schema version" | |
task :version do | |
version = if DB.tables.include?(:schema_info) | |
DB[:schema_info].first[:version] | |
end || 0 |
# DelegateToAll. Like delegate.rb from Ruby's std lib but lets you have multiple target/delegate objects. | |
require 'delegate' | |
class DelegatorToAll < Delegator | |
# Pass in the _obj_ to delegate method calls to. All methods supported by | |
# _obj_ will be delegated to. | |
# | |
def initialize(*targets) | |
__setobj__(targets) |
## Generated by install_server.sh ## | |
# Redis configuration file example | |
# Note on units: when memory size is needed, it is possible to specify | |
# it in the usual form of 1k 5GB 4M and so forth: | |
# | |
# 1k => 1000 bytes | |
# 1kb => 1024 bytes | |
# 1m => 1000000 bytes | |
# 1mb => 1024*1024 bytes |
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
# Signal catching | |
def shut_down | |
puts "\nShutting down gracefully..." | |
sleep 1 | |
end | |
puts "I have PID #{Process.pid}" | |
# Trap ^C | |
Signal.trap("INT") { |
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
I'm writing this up from memory, so errors may appear.
This has been updated to use SHA256 certificates.
I frequently administer remote servers over SSH, and need to copy data to my clipboard. If the text I want to copy all fits on one screen, then I simply select it with my mouse and press CMD-C, which asks relies on m y terminal emulator (xterm2) to throw it to the clipboard.
This isn't practical for larger texts, like when I want to copy the whole contents of a file.
If I had been editing large-file.txt
locally, I could easily copy its contents by using the pbcopy
command:
require 'sinatra' | |
require 'json' | |
require 'csv' | |
# Serve data as JSON | |
get '/hi/:name' do | |
name = params[:name] | |
content_type :json | |
{ :message => name }.to_json | |
end |