A collection of Linux commands and concepts I tend to forget
View db.rake
require "active_record" | |
databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml | |
db_namespace = namespace :db do | |
if Rails.version.start_with?("6.0") | |
# https://github.com/rails/rails/pull/38770/files | |
namespace :rollback do | |
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name| |
View dump_memcache.rb
#!/usr/bin/env ruby | |
# List all keys stored in memcache. | |
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place. | |
require 'net/telnet' | |
require 'csv' | |
headings = %w(id expires bytes key) | |
rows = [] |
View live_database_dump.rb
class DatabaseController < ApplicationController | |
def database_dump | |
database = Rails.configuration.database_configuration[Rails.env]["database"] | |
send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup") | |
pipe = IO.popen("pg_dump '#{database}' -F c") | |
stream = response.stream | |
while (line = pipe.read(1024)) # per https://gist.github.com/njakobsen/6257887#gistcomment-1238467 | |
stream.write line | |
Thread.pass # per https://gist.github.com/njakobsen/6257887#gistcomment-1235792 |
View clock
#!/usr/bin/env bash | |
# Created by Benjamin Fleischer 2019 | |
# Distributed under the MIT license | |
# | |
# Usage: | |
# MINUTE_RANGES="0...10 30...40" ./clock echo 'we done it' | |
# DEBUG=true MINUTE_RANGES="0...10 30...40" ./clock echo 'we done it' | |
main() { | |
local ranges |
View jdbc_sample.rb
require './lib/adsjdbc-10.10.0.28.jar' | |
java_import java.sql.Driver | |
java_import java.sql.DriverManager | |
java_import 'com.extendedsystems.jdbc.advantage.ADSDriver' | |
class AdsAdapter | |
def initialize(connect_string) | |
@connect_string = connect_string | |
end |
View test_schema_jsonapi.json
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"description": "JSON:API Schema", | |
"type": "object", | |
"properties": { | |
"link": { "$ref": "file://schemata/link.json#" }, | |
"meta": { "$ref": "file://schemata/meta.json#" } | |
} | |
} |
View gist:e9a7016e4c5dca2d6b8a19d6e10d23c0
Step 0. Install Docker
Step 1. For your chosen project, decide where you want to store your notebooks and files in a workingfolder
.
Step 2. Open that folder in the terminal cd workingfolder
Step 3. Run this command
docker run -it --rm -v $PWD:/home/jovyan/work -p 8888:8888 jupyter/all-spark-notebook
View parser-combinator.md
What
A technique for writing parsers.
Why
- Easy to understand
- Generally applicable
- Full power of the programming language at your disposal
- Declarative
View jsonapi-overview.md
Table of contents
NewerOlder