Skip to content

Instantly share code, notes, and snippets.

View brandon-fryslie's full-sized avatar

Brandon Fryslie brandon-fryslie

View GitHub Profile
@brandon-fryslie
brandon-fryslie / genetic.js.coffee
Created February 24, 2012 08:32
Genetic Algorithm in CoffeeScript
# Add some useful features to array prototypes
Array::fold = (initial, fn) -> initial = fn initial, x for x in @; initial
Array::sum = -> @fold 0, (memo, i) -> memo + i
Array::mean = -> @sum() / @length
Array::max = -> Math.max.apply {}, @
Array::min = -> Math.min.apply {}, @
Array::median = -> if @length % 2 is 0 then (@[@length/2-1]+@[@length/2])/2 else @[Math.ceil @length/2]
Array::variance = -> avg = @mean(); @fold(0, (memo, i) -> memo + Math.pow i-avg, 2) / @length
Array::std_dev = -> Math.sqrt @variance()
@brandon-fryslie
brandon-fryslie / output.genetic.txt
Created February 24, 2012 08:34
Genetic Algorithm in CoffeeScript Output
Generation 0
Population 1
---
Pop Size : 100
Max : 37.5
Min : 14.0625
Mean : 25.984375
Median : 21.875
Variance : 24.592529296875
# Start one task
# Returns a promise
start_task = (env) ->
deferred = Q.defer()
if env.start_message
console.log env.start_message.yellow, 'Doing ', "[ #{env.command.join(' ')} ]".green
proc = nexpect.spawn(env.command, [],
stream: 'all'
DE25845 {
db.name = System.env.DB_NAME ?: 'DE25845'
jdbc {
user.name = db.name
password = db.name
service.name = System.env.JDBC_SERVICE_NAME ?: '@//bld-engdb-02:1530/okidb11'
}
let startIndex = 0;
const pageSize = 200;
let promises = [];
while (startIndex < watches.length) {
promises.push(AlmApi.query('/artifact/', {
query: buildUUIDQuery(uuids.slice(startIndex, startIndex + pageSize)),
fetch: fetchFields,
pagesize: pageSize
@brandon-fryslie
brandon-fryslie / fix-sombrero-imports.fb
Last active April 7, 2016 15:32
Fix Sombrero Imports
#!/usr/bin/env ruby
# Build a map of component names to paths - conveniently, there's a file
# already containing that information
def build_component_map()
text = File.read("#{ENV['HOME']}/projects/sombrero/components/index.js")
text.lines.reduce({}) do |res, line|
if /^\s+(\w+):\s*require\(\'\.([^']*)/ =~ line
key = $1
path = "sombrero/components#{$2}"
get_bad_builds(build)
bad_builds = []
if isList(build)
for b in build
bad_builds.append(get_bad_build(b))
if build.hasKey('builds')
get_bad_builds(build.builds)
docker.f4tech.com/rally/oracle-11g:alm-prod x
docker.f4tech.com/jenkins/alm-services x
docker.f4tech.com/jenkins/burro x
docker.f4tech.com/jenkins/churro-node x
docker.f4tech.com/rally/oracle-11g:alm ?
docker.f4tech.com/jenkins/docker-compose-node
docker.f4tech.com/rally/oracle-11g:alm-subs
docker.f4tech.com/testn/oracle-reload-node
docker.f4tech.com/jenkins/alm-node
source "${HOME}/.zgen/zgen.zsh"
# if the init scipt doesn't exist
if ! zgen saved; then
# Disable loading default Prezto modules
# This is necessary due to a quirk of zgen that will load these plugins after
# our custom plugins, overwriting our customizations
# https://github.com/tarjoilija/zgen/issues/74
export ZGEN_PREZTO_LOAD_DEFAULT=0
zgen prezto
Replacing text with iedit
Spacemacs uses the powerful iedit mode through evil-iedit-state to quickly edit multiple occurrences of a symbol or selection.
evil-iedit-state defines two new evil states:
* iedit state
* iedit-insert state
The color code for these states is red.
evil-iedit-state has also a nice integration with expand-region for quick edition of the current selected text by pressinge.
iedit states key bindings
State transitions
Key Binding From To