Skip to content

Instantly share code, notes, and snippets.

seamusabshere / shopify_import_orders.rb
Created May 25, 2020 22:51
Import orders into (paid) Shopify store
View shopify_import_orders.rb
Thread.abort_on_exception = true
require 'bundler/setup'
require 'thread/pool'
require 'csv'
require 'shopify_api'
pool = Thread.pool 2
mutex =
# ActiveResource::Base.logger =$stderr)
# ActiveResource::Base.logger.level = Logger::DEBUG
View gist:dca36bc5f1a99217af9c
### Keybase proof
I hereby claim:
* I am seamusabshere on github.
* I am seamusabshere ( on keybase.
* I have a public key whose fingerprint is 00E8 B10F 062A 1672 DF80 F69A 6417 28F0 0400 349E
To claim this, I am signing this object:
seamusabshere / safe_tmp_path.rb
Created November 11, 2014 15:48
safe tmp paths including keeping extname
View safe_tmp_path.rb
# requires the zaru gem, just get it :)
require 'tmpdir'
require 'zaru'
def tmp_path(name_hint = nil)
name_hint ||= 'tmp'
extname = File.extname name_hint
name_hint = Zaru.sanitize! File.basename(name_hint, extname).to_s.gsub(/\s+/, '_')
path = Dir::Tmpname.create(name_hint) {}
# Some things taken from here
# Set the colours you can use
seamusabshere / gg
Created October 20, 2014 12:53
global search and replace for filenames and file contents implemented in ruby with gsed
View gg
#!/usr/bin/env ruby
# USAGE gg "hello world" "hola mundo"
# * requirements: gem install posix-spawn, sudo port install coreutils (gsed)
# * changes file names and file contents (in the right order!)
# * limited regex support - it has to work with `system 'gsed', '--in-place', '-e', "s%#{search}%#{replace}%g", path`
require 'posix/spawn'
require 'fileutils'
force = ENV['FORCE'] == 'true'
View democall.sql
-- SELECT Faraday_JoyDivision('households'::text, 'year_built'::text) AS the_geom
explain analyze WITH
-- Snap the disparate points to a regular grid where theres data for the given filter
grid AS (
-- note transform here
ST_SnapToGrid(ST_Transform(the_geom, 4326), 0.002) the_geom,
seamusabshere / bigml_null.rb
Created January 24, 2014 22:21
bigml's list of values that count as null
View bigml_null.rb
MISSING = %w{ N/A n/a NULL null - #DIV/0 #REF! #NAME? NIL nil NA na #VALUE! #NULL! NaN #N/A #NUM! ? }
seamusabshere / hcsv
Last active January 18, 2023 01:40
hcsv - dump id + values from one hstore column
View hcsv
#!/usr/bin/env ruby
# Output columns will be id + all the hstore keys
dbname, tblname, hstorecol = ARGV[0..2]
# Get hstore keys
out = `psql #{dbname} --tuples --command "SELECT DISTINCT k FROM (SELECT skeys(#{hstorecol}) AS k FROM #{tblname}) AS dt ORDER BY k"`
headers = out.split(/\n/).map(&:strip)
seamusabshere / gg
Last active December 17, 2015 12:49
~/bin/gg and ~/bin/mmv
View gg
set -x
read -p "Replace contents? (y/n) " RESP
if [ "$RESP" = "y" ]; then
ack --print0 -l "$1" | xargs -0 -n 1 gsed --in-place="" -e "s%$1%$2%g"
read -p "Replace in filenames? (y/n) " RESP
if [ "$RESP" = "y" ]; then
find . -print0 -not -path "*.git*" -a -name "*$1*" | xargs -0 -n 1 mmv "s/$1/$2/"
seamusabshere / hstore--1.x.sql
Last active December 12, 2015 04:38
hstore that works with jdbc
View hstore--1.x.sql
/* contrib/hstore/hstore--1.1.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION hstore" to load this file. \quit
CREATE FUNCTION hstore_in(cstring)
RETURNS hstore