Skip to content

Instantly share code, notes, and snippets.

Benjamin Fleischer bf4

Block or report user

Report or block bf4

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
@bf4
bf4 / dump_memcache.rb
Created Aug 2, 2019 — forked from BalmanRawat/dump_memcache.rb
Dumping and restoring the memcache key values using telnet & dalli gem
View dump_memcache.rb
#!/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 = []
@bf4
bf4 / live_database_dump.rb
Last active Jun 19, 2019 — forked from njakobsen/live_database_dump.rb
Live stream a database dump (or any other STDOUT) using Rails 4. Why would you want this? If you have a large database dump and want to avoid storing it in memory as Rails streams it. This allows pipe the dump directly into the http response instead of storing it as a file, sending it, and then deleting it. Let me know what you think! I've teste…
View live_database_dump.rb
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
@bf4
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-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
View 0.README-Linux-Command-Line-Cheat-Sheet.md

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
View parser-combinator.md

What

A technique for writing parsers.

Why

  • Easy to understand
  • Generally applicable
  • Full power of the programming language at your disposal
  • Declarative
@bf4
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
end
end
View learn_clojure_recipe.md
@bf4
bf4 / go_kinesis_with_structs.go
Created Mar 14, 2017 — forked from pricees/go_kinesis_with_structs.go
Go + AWS Kinesis + Encode/Decode Structs
View go_kinesis_with_structs.go
/**
NOTE:
Assumes env contains aws credentials:
AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY
AWS_SECRET_KEY_ID or AWS_SECRET_KEY
and AWS_REGION_NAME (e.g. 'US-EAST-1')
see EnvAuth() below
*/
You can’t perform that action at this time.