Skip to content

Instantly share code, notes, and snippets.

:shipit:
This is like AIM all over again, isn't it?

James Gifford jrgifford

:shipit:
This is like AIM all over again, isn't it?
Block or report user

Report or block jrgifford

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jrgifford
jrgifford / sleep5.sh
Created Jun 12, 2019 — forked from jj1bdx/sleep5.sh
A shell one-liner for an infinite loop (sh/zsh/bash compatible)
View sleep5.sh
while true; do date; sleep 5; done
View zero-width-space.rb
def
puts "zero width space method"
end
@jrgifford
jrgifford / main.rb
Created Apr 10, 2019
Ruby CSV library is smart and will select just keys in the headers if given headers and a hash
View main.rb
require 'csv'
filename = "/tmp/csv_test.csv"
things_to_write = [
{a: "a", b: "b", c: "c"},
{c: "c", b: "b", a: "a", does_not: "exist"},
{a: "a", c: "c"}
]
CSV.open(filename, "wb", headers: things_to_write.first.keys) do |csv|
things_to_write.each do |thing|
@jrgifford
jrgifford / restore
Created Feb 10, 2017 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
View restore
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
@jrgifford
jrgifford / Gemfile
Created Feb 1, 2017 — forked from somazx/Gemfile
Using Amazon Elasticsearch securely (signed requests) with Rails & searchkick gem on Heroku.
View Gemfile
gem 'elasticsearch', '>= 1.0.15'
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
gem 'patron'
gem 'faraday_middleware-aws-signers-v4'
gem 'searchkick'
View main.rb
params = {}
params[:start_date] = "2017/08/03"
params[:end_date] = "2017/08/05"
start_date = Date.parse(params[:start_date])
end_date = Date.parse(params[:end_date])
dates = (start_date..end_date).step(1.day).map { |date|
date.strftime('%y-%m-%d')
}
View company_names_each_no_index.rb
company_names = ["Tekfly", "Yabox", "Vinder", "Skiptube", "Fivespan"]
company_names.each do |company_name|
puts "#{company_name}"
end
View company_names_each_with_index.rb
company_names = ["Tekfly", "Yabox", "Vinder", "Skiptube", "Fivespan"]
company_names.each_with_index do |company_name, index|
puts "#{company_name} has index #{index}"
end
View results.txt
Tekfly has index 0
Yabox has index 1
Vinder has index 2
Skiptube has index 3
Fivespan has index 4
View company_names.rb
company_names = ["Tekfly", "Yabox", "Vinder", "Skiptube", "Fivespan"]
You can’t perform that action at this time.