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 / 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}"
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
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'
}
# 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'
@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
@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()