Skip to content

Instantly share code, notes, and snippets.

Benjamin Fleischer bf4

View GitHub Profile
bf4 / clock
Created Apr 3, 2019
Script to run only in the specified minute range
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
bf4 / jdbc_sample.rb
Created Apr 18, 2018 — forked from rwjblue/jdbc_sample.rb
Convert JDBC ResultSet into Ruby Hash with JRuby
View jdbc_sample.rb
require './lib/adsjdbc-'
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
View test_schema_jsonapi.json
"$schema": "",
"description": "JSON:API Schema",
"type": "object",
"properties": {
"link": { "$ref": "file://schemata/link.json#" },
"meta": { "$ref": "file://schemata/meta.json#" }

A collection of Linux commands and concepts I tend to forget

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


A technique for writing parsers.


  • Easy to understand
  • Generally applicable
  • Full power of the programming language at your disposal
  • Declarative
bf4 / ams.rb
Created Apr 3, 2017 — forked from sineed/ams.rb
Upgrade AMS from 0.9.0 to 0.10.0
View ams.rb
module AMS
module V09
class Serializer < ActiveModel::Serializer
def serializable_hash(adapter_options = nil,
options = {},
adapter_instance = self.class.serialization_adapter_instance)
object.nil? ? nil : super
bf4 / find_relations_in_batches.rb
Created Mar 22, 2017
ActiveRecord Rails Find Relations in Batches
View find_relations_in_batches.rb
# Finds and yields relations in batches. Adapted from record.find_in_batches since that yields
# arrays and we want to operate on relationships.
# Adapted from:
def find_in_batches(target, batch_size: default_batch_size, start: nil)
relation = target
if logger && (target.arel.orders.present? || target.arel.taken.present?)
logger.warn("Scoped order and limit are ignored, it's forced to be batch order and batch size")
relation = relation.reorder(target.send(:batch_order)).limit(batch_size)
You can’t perform that action at this time.