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 = [] |
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 |
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 README.md
ways to manually update RubyGems without susceptibility to CVE-2015-3900 (until there is a new ruby release)
because gem update --system
uses rubygems to get the newest rubygems-update gem, and the vulnernability is in rubygems...
via ruby:
\curl -sSL https://gist.github.com/bf4/4223e83e8becacfb2a8e/download | \
tar xzvf - --include 'update.rb' -O | ruby
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
View reminder.py
import time | |
import webbrowser | |
total_breaks = 8 | |
break_count = 0 | |
while (break_count < total_breaks): | |
time.sleep(3600) | |
webbrowser.open("https://31.media.tumblr.com/288d6e631cd930de65547ef5044fefb8/tumblr_mlksb86paT1qbuvyto1_500.gif") | |
break_count = break_count + 1 |
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 |
NewerOlder