Skip to content

Instantly share code, notes, and snippets.

View ksaynice's full-sized avatar

-=K=- ksaynice

View GitHub Profile
def merge_sort(arr)
return arr if arr.size <= 1
left, right = halve_array(arr)
left_part = merge_sort(left)
right_part = merge_sort(right)
array = []
offset_left_part = 0
offset_right_part = 0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.811765 0.796078 0.564706 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 16.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@ksaynice
ksaynice / gist:208828d7ea889edcdd88
Last active December 4, 2017 09:07 — forked from bkimble/gist:1365005
List all keys stored in memcache
#!/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'
headings = %w(id expires bytes cache_key)
rows = []
# Function to print strftime results
def print_strftime_formats(a,cur_date)
a.each do |format|
b = "%#{format}"
output = cur_date.strftime(b)
puts "t.strftime('#{b}'), => #{output}"
end
end
a = ('a'..'z').to_a
@ksaynice
ksaynice / puma.rb
Last active October 13, 2015 04:32 — forked from sj26/boot.rb
Use dotenv with unicorn (put in config/boot.rb, thanks @keithpitt)
class PumaHelper
def self.refresh_connection_pool(base_klass, config_key)
base_klass = base_klass.constantize
config = Rails.application.config.database_configuration[config_key]
base_klass.connection_pool.disconnect! rescue ActiveRecord::ConnectionNotEstablished
base_klass.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
base_klass.establish_connection config
true
rescue
@ksaynice
ksaynice / iceage.py
Created January 22, 2019 10:52 — forked from lrettig/iceage.py
Simulation script for ice age block times
# Date, blocknum, difficulty as of 2019-01-18
# Script by vbuterin, slightly modified by lrettig
import random
import datetime
import sys
def calc_bomb(i):
period = i // 100000
if (period > 0):
# Subtract 2, this is the original formula