Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am gbuesing on github.
  • I am gbuesing (https://keybase.io/gbuesing) on keybase.
  • I have a public key ASC44xkHYLkEbRYoSApMVLq2Bxr2c0PxWMbVVszNNqiFmwo

To claim this, I am signing this object:

@gbuesing
gbuesing / copy_row.sql
Created Jun 8, 2017
Copy single row from one Postgres DB into another via psql
View copy_row.sql
# database 1
# output single row in format compatible with INSERT VALUES
\copy (SELECT * FROM users WHERE email = 'me@example.com') To stdout With CSV force quote * null 'NULL' quote ''''
# database 2
# insert values outputted from above command into another database
INSERT INTO users VALUES (...);
@gbuesing
gbuesing / transloadit_blocking_assembly_runner.rb
Last active Nov 19, 2016
Transloadit blocking assembly runner
View transloadit_blocking_assembly_runner.rb
# Blocks until response received
# Designed to be run from a background job, not in request-response
# Usage:
# assembly = Transloadit::Rails::Engine.template :my_template
# response = TransloaditBlockingAssemblyRunner.run assembly
# results = response['results']
module TransloaditBlockingAssemblyRunner
class Error < StandardError; end
class TimeoutError < Error; end
class AssemblyError < Error; end
@gbuesing
gbuesing / Gemfile
Last active Oct 28, 2020
ActiveJob with resque-scheduler on Heroku
View Gemfile
gem 'resque-scheduler'
@gbuesing
gbuesing / neo4j_client.rb
Last active Jun 28, 2016
Neo4j Data Import Example
View neo4j_client.rb
require 'rest-client'
require 'json'
module Neo4jClient
SERVER = 'http://neo4j:neo4j@localhost:7474'
def self.cypher query, params = {}
resp = RestClient.post("#{SERVER}/db/data/cypher", {query: query, params: params}.to_json, content_type: :json, accept: :json)
JSON.parse resp
end
View ApplicationController.swift
// delare WKScriptMessageHandler as delegate
// add to WKWebViewConfiguration init:
configuration.userContentController.addScriptMessageHandler(self, name: "log")
// MARK: WKScriptMessageHandler
func userContentController(userContentController: WKUserContentController, didReceiveScriptMessage message: WKScriptMessage) {
if (message.name == "log") {
print(message.body)
}
View ApplicationController.swift
// declare WKUIDelegate as a delegate for ApplicationController
lazy var session: TLSession = {
let session = TLSession(webViewConfiguration: self.webViewConfiguration)
session.delegate = self
session.webView.UIDelegate = self // add this
return session
}()
// MARK: WKUIDelegate
@gbuesing
gbuesing / bounding_box.rb
Created Oct 27, 2015
GooglePlaces gem spots_by_bounds test
View bounding_box.rb
require 'google_places'
api_key = 'key'
# Actually executing stubbed-out spec "should request spots by bounds" from client_spec.rb
# Supplying a bounding box to a text search query does not seem to work, nor is this feature documented:
# https://developers.google.com/places/web-service/search#TextSearchRequests
query = 'pizza'
# Bounds is around city of Nashville TN
View query_helpers.coffee
addParams = (path, params) ->
query = objToQuery(params)
joinChar = if /\?/.test(path) then '&' else '?'
"#{path}#{joinChar}#{query}"
objToQuery = (obj) ->
pairs = []
for own key, val of obj
if val? and val != ''
val = encodeURIComponent(val)
@gbuesing
gbuesing / pubsub.coffee
Last active Oct 31, 2015
PubSub via jQuery without DOM bindings
View pubsub.coffee
# Simple global PubSub system built around $.Callbacks
# Enables PubSub without relying on DOM element bindings
#
# Usage:
#
# PubSub.subscribe 'foo', (message) -> console.log("Received: #{message}")
# PubSub.publish 'foo', 'bar'
# # Outputs: "Received: bar"
$(document).on 'ready', () ->
window.PubSub =