Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
@ecounysis
ecounysis / orm.js
Created June 12, 2016 15:19
One-Rep Max calculation functions
function Epley(wt, reps) {
return wt * ( 1 + reps / 30);
}
function Brzycki(wt, reps) {
return wt * 36 / (37 -reps);
}
function Lander(wt, reps) {
return 100 * wt / (101.3 - reps * 2.67123);
@ecounysis
ecounysis / fnAverage.js
Last active June 12, 2016 04:56
a function to average the results of applying other functions in javascript
function fnAverage() {
// Accepts any number of functions as its arguments.
// Returns a function that averages all the argument functions.
// Argument functions can accept args. In which case, just pass them into the
// returned function at call time.
// Resulting function will error if called with fewer args
// than required by function requiring the most args.
/*
// Example:
@ecounysis
ecounysis / css-parser.md
Created June 7, 2016 21:39 — forked from kachayev/css-parser.md
Parsing CSS file with monadic parser in Clojure
(defn summarize
"Summarizes a data set. Groups data by result of groupingf applied to each
member of coll. Applies summarizingf to each group."
[groupingf summarizingf coll]
(let [grouped (group-by groupingf coll)]
(map #(list (first %) (summarizingf (second %))) grouped)))
(defn summarize-count
[groupingf coll]
(summarize groupingf count coll))
require 'net/https'
require 'uri'
# create a path to the file "C:\RailsInstaller\cacert.pem"
cacert_file = File.join(%w{c: RailsInstaller cacert.pem})
uri = URI.parse("https://curl.haxx.se/ca/cacert.pem")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
using System.ComponentModel;
using System.Collections.Generic;
using System.Threading;
using System;
namespace Ecounysis.DataProcessing
{
// How to use this:
// 1. create a subclass
open System
let printLines n =
for s = 1 to n do
Console.WriteLine()
n
let getInt x =
let succ = Int32.TryParse(x)
module Parsing =
//type Char = string
//type Str = string
type Remaining = string
type Result<'a> = Success of 'a * Remaining
| Failure
type Parser<'a> = string -> Result<'a>
@ecounysis
ecounysis / primes.fs
Last active August 29, 2015 14:09
primes
let divisors x =
List.init (int (Math.Sqrt(float x))) (fun x -> x + 1)
|> List.filter (fun y -> x % y = 0)
|> List.map (fun y -> [y ; x / y])
|> List.reduce (fun x y -> x @ y)
|> List.sort
let isPrime x =
List.length (divisors x) = 2
@ecounysis
ecounysis / Obfuscation.fs
Created November 10, 2014 20:36
String obfuscation
namespace Obfuscation
// very weak encryption
// uses a "one-time pad" that is used over and over
// http://en.wikipedia.org/wiki/One-time_pad
module Text =
type Operation =
| Encryption