This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiplicative_pair_count(a,b) | |
count = 0 | |
a.each_index.to_a.combination(2).each do |i,j| | |
c1 = a[i] + b[i]/1_000_000.0 | |
c2 = a[j] + b[j]/1_000_000.0 | |
count +=1 if c1*c2 >= c1+c2 | |
return 1_000_000_000 if count >= 1_000_000_000 | |
end | |
count | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def min_abs_slice_sum(a) | |
a.each_index.to_a.combination(2).map{|i,j| a[(i..j)].inject(&:+).abs}.min | |
end | |
def run_benchmark | |
require 'benchmark' | |
n = 3 | |
Benchmark.bm(17) do |x| | |
(0..n).each do |i| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IntList | |
attr_accessor :value, :next | |
end | |
def get_length(l) | |
return 0 if l.nil? | |
len = 1 + get_length(l.next) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ul{ | |
list-style-type:none; | |
counter-reset: section; | |
} | |
li:before { | |
counter-increment: section; | |
content: counter(section); | |
} | |
li:nth-child(3n):before, li:nth-child(5n):before{ | |
content: ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edit this file to introduce tasks to be run by cron. | |
# | |
# Each task to run has to be defined through a single line | |
# indicating with different fields when the task will be run | |
# and what command to run for the task | |
# | |
# To define the time you can provide concrete values for | |
# minute (m), hour (h), day of month (dom), month (mon), | |
# and day of week (dow) or use '*' in these fields (for 'any').# | |
# Notice that tasks will be started based on the cron's system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'octokit' | |
ACCESS_TOKEN = "" # Create at https://github.com/settings/tokens | |
ORGANIZATION_NAME = "SalesLoft" | |
USER_NAME = "thephw" | |
PULL_REQUEST_OPTIONS = {state: :all, head: USER_NAME, sort: :created, direction: :desc} | |
FILTER_AFTER = Time.parse('2015-05-18 00:00:00 UTC') | |
client = Octokit::Client.new(access_token: ACCESS_TOKEN) | |
repositories = client.repositories.map(&:full_name).select{|repo| repo.start_with?(ORGANIZATION_NAME)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* iPhone 4 */ | |
@media | |
only screen and (-webkit-min-device-pixel-ratio : 1.5), | |
only screen and (min-device-pixel-ratio : 1.5) { | |
/* Styles */ | |
#centercol { | |
width: 450px; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Schema Information | |
# | |
# Table name: foobars | |
# | |
# id :integer not null, primary key | |
# created_at :datetime not null | |
# updated_at :datetime not null | |
# name :string(255) not null | |
# baz :string(255) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export KITTENIFY=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/colorize.rb | |
## Just for prettier output | |
class String | |
def colorize(color, options = {}) | |
background = options[:background] || options[:bg] || false | |
style = options[:style] | |
offsets = ["gray","red", "green", "yellow", "blue", "magenta", "cyan","white"] | |
styles = ["normal","bold","dark","italic","underline","xx","xx","underline","xx","strikethrough"] | |
start = background ? 40 : 30 |