Skip to content

Instantly share code, notes, and snippets.

naufragio del desastre linda metafísico de producción oncall compwron

Block or report user

Report or block compwron

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:256a8594c87dbbf98359
require 'spec_helper'
describe 'testing contexts' do
before { p 1 }
context 'aa' do
before { p 2 }
it 'foo' do
expect(42).to eq 42
end
View gist:9004950
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@compwron
compwron / gist:0499c61ba441e3e8cb4a
Created Jul 1, 2014
vim tmux practice navigation setup generator
View gist:0499c61ba441e3e8cb4a
class Tvcom
attr_reader :command
attr_accessor :valid
def initialize(foo, valid)
@command = foo
@valid = valid
end
def flip
View gist:86c220dc000085f5c444
files = `git ls-files | grep -v vendor`.split("\n")
a = files[Random.new.rand(files.size)]
p a
`open -a "/Applications/Sublime\ Text.app/" #{a}`
@compwron
compwron / gist:eaa59d38c33e86f923ca
Created Dec 9, 2014
howto set all input fields from hash in ruby
View gist:eaa59d38c33e86f923ca
def initialize(field_data)
field_data.each do |name, value|
instance_variable_set("@#{name}", value)
end
end
View gist:fea94a0eac08695e30ca
# You are asked to write a max_slice function which takes as an input an array of integers, and returns the slice with the largest sum of the elements
a = [1, 2, 3, 4, 5]
b = [1, -2, 6, -4, 5]
[1]
[1, -2]
[1, -2, 6]
[-2, 6]
View gist:a64972f2e3c527405923
filename = ARGV[0] || 'app/models/transaction.rb'
f = File.open(filename, 'rb')
c = f.read
all = c.split(/\n|,/).map { |i| i.strip.gsub(/[^A-Za-z0-9\s\[\]\._\(\)]/, '') }.reject(&:empty?)
# too many false positives
DEFAULT = 'aaa --- DEFAULT --- '
alph_list = [DEFAULT]
all.each do |line|
if [alph_list.last, line].sort.last == line # this line is after everything in alph list alphabetically
View gist:115a7cf9aaa9d5271e2a
def sum2 choices, result
arrays = []
choices.each_with_index {|i, index|
choices.each_with_index {|j, index2|
break if index == index2
arrays << [i, j] if i + j == result
}
}
arrays
end
View gist:d883710cf84bbd213eed
# Task: write a function to determine if a string is
# 'balanced'. Balanced means that opening and closing
# brackets match each other in the proper order. Other
# characters are possible and should be handled. The
# possible characters for balancing are {}, (), and []
# Example Input:
# '{}' -> True
# '{[]}' -> True
@compwron
compwron / gist:65f8a1eedffe9cd2d208
Created Jan 23, 2015
max diff in moving subset window
View gist:65f8a1eedffe9cd2d208
def max_devi(choices, setlength) # v, d
largest_diff = 0
largest_diff_subset = []
(0..choices.length - setlength).each do|i|
subset = choices[i..i + setlength]
diff = subset.max - subset.min
if diff > largest_diff
largest_diff_subset = subset
largest_diff = diff
end
You can’t perform that action at this time.