Skip to content

Instantly share code, notes, and snippets.

💭
We can pickle that

Shai Rosenfeld shaiguitar

💭
We can pickle that
Block or report user

Report or block shaiguitar

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
View gist:6c7778e21d3e54c40735914207d5abfb
#!/bin/sh
### BEGIN INIT INFO
# Provides: odrive
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: odrive init script
# Description: odrive server startup sctipt.
@shaiguitar
shaiguitar / gist:627d52ebc0c03af488477b5d636a8909
Created Aug 31, 2017
Using docker compose to mount current working directory dynamically into the container
View gist:627d52ebc0c03af488477b5d636a8909
# mount volume PWD on host to /app in container.
shai@lappy ~/tmp/example-working-docker-compose-environment-vars [master *] ± % cat docker-compose.yml
version: "3"
services:
some_server:
...
volumes:
- $PWD:/app
@shaiguitar
shaiguitar / mycache.rb
Last active Jun 7, 2017
fog-core caching class
View mycache.rb
class MyCache
def self.all(resource_klass, connection, meth, args = nil)
cachemsg = "resource #{resource_klass} connection #{connection.class} for #{Fog::Cache.namespace_prefix}: M:#{meth} A:#{args}"
if MyCache.renew?
info("Renewing cache now. Cache is non existant or older than #{EXPIRE_TIME} seconds.")
Fog::Cache.expire_cache!(resource_klass, connection)
end
@shaiguitar
shaiguitar / cache-policies.md
Created Jun 7, 2017
Fog-core cache expire policy example.
View cache-policies.md
  1. Record cache set/fetch time.
Fog::Cache.write_metadata({:last_refreshed => Time.now})
  1. Create some custom expirey method
      EXPIRE_TIME = (60 * 60 * 24) # day old cache.
      
View fog-example-cache.rb
require 'fog'
require 'fog/aws'
ec2 = Fog::Compute.new :provider => 'AWS', :region => 'us-east-1'
Fog::Cache.namespace_prefix = "benchmark-test"
begin
servers = Fog::Cache.load(Fog::Compute::AWS::Server, ec2)
puts "found cache."
View ruby-hash-access-in-string.txt
irb(main):001:0> foo = "i like food"
=> "i like food"
irb(main):002:0> foo["food"] = "beer"
=> "beer"
irb(main):003:0> foo
=> "i like beer"
View I-IV-II-V
======================
I VI II V progression
======================
Assuming you can
1) Substitute the minor IV for a dominant IV and the minor II for a dominant II
2) Substitue any of the VI/II's (because of #1) or V for a tritone equivalent
So...Some notation/glossary for the below:
@shaiguitar
shaiguitar / charlie-you-the-man.ly
Last active Aug 29, 2015
Charlie Christian Guitar Solo in Lilypond format
View charlie-you-the-man.ly
%{
Lilypond notation for Christian's guitar solo on https://www.youtube.com/watch?v=mOnhcdAMInA
%}
\header{
title = "Christian Charlie 7/11 solo"
}
@shaiguitar
shaiguitar / imdb_get_dir.rb
Last active Aug 29, 2015
Got a huge dir of movies, wants to know what movie to see according to IMDB ratings.
View imdb_get_dir.rb
require 'uri'
def safe_comparison(matrix)
matrix.map do |row|
row.map do |el|
el = el.to_s
end
end
end
@shaiguitar
shaiguitar / tail.rb
Last active Jul 22, 2016
tail in ruby
View tail.rb
class Tail
class << self
def tail(path, n)
file = File.open(path, "r")
buffer_s = 512
line_count = 0
file.seek(0, IO::SEEK_END)
offset = file.pos # we start at the end
You can’t perform that action at this time.