A collection of Linux commands and concepts I tend to forget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/synth/8c9eee23aa9df535aa42a30f7cff9ba9 | |
require "parser/current" | |
module Flipper | |
module FlagRegistration | |
# These functions are all memoized because they should be static for the | |
# lifetime of a deployment (albeit they are really static to a Ruby process) | |
def self.registered_flags | |
@registered_flags ||= YAML.load_file("config/feature_flags.yml") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This solution was based on https://gist.github.com/GlenCrawford/16163abab7852c1bd550547f29971c18 | |
Rails.configuration.to_prepare do | |
ActiveRecord::SchemaDumper.ignore_tables = %w[ | |
salesforce._hcmeta | |
salesforce._sf_event_log | |
salesforce._trigger_log | |
salesforce._trigger_log_archive | |
] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: | |
# ./download_all.sh | |
# ./download_all.sh download us-east-1 my-function | |
# ./download_all.sh help | |
# | |
# Downloads all aws-lambda functions to a subdirectory | |
# Assumes you have a role that has at least read access to lambda. | |
# Credits to https://gist.github.com/nemani/defdde356b6678352bcd4af69b7fe529 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A script to migrate Sidekiq's redis to a new server. | |
# This obviously can work for any redis, but I only handled | |
# data types that Sidekiq uses. | |
require 'redis' | |
old_redis = Redis.new url: 'redis://old-redis:6379' | |
new_redis = Redis.new url: 'redis://new-redis:6379' | |
unknowns = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require(Dir.pwd + "/config/environment") | |
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| | |
ActiveRecord::Base.establish_connection(db_config.config) | |
context = ActiveRecord::Base.connection.migration_context | |
missing_migrations = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
NewerOlder