Skip to content

Instantly share code, notes, and snippets.

View benwilson512's full-sized avatar

Ben Wilson benwilson512

  • CargoSense
  • Fairfax, VA
View GitHub Profile
# http://en.wikipedia.org/wiki/Simple_linear_regression
# Exchange.Calc.Regression.run(self, [{1,1},{2,2},{3,3}])
defmodule Exchange.Calc.Regression do
def run(recipient, points) do
n = length(points)
fn_builder = spawn(Exchange.Calc.Regression, :build_function, [recipient, []])
spawn(Exchange.Calc.Regression, :sum_products_avg, [fn_builder, points, n])
defmodule Generator do
# Generates a method like the following
# def to_word(n) when n >= 1_000 do
# [to_word(div(n, 1_000)), "thousand,", to_word(rem n, 1_000)]
# end
defmacro gen_method(input) do
quote bind_quoted: [input: input] do
def to_word(n) when n >= unquote(input[:num]) do
[to_word(div(n, unquote(input[:num]))), "#{unquote(input[:text])},", to_word(rem n, unquote(input[:num]))]
end
#!/bin/bash
#Initial wifi interface configuration
ifconfig $1 up 10.0.0.1 netmask 255.255.255.0
sleep 2
###########Start dnsmasq, modify if required##########
if [ -z "$(ps -e | grep dnsmasq)" ]
then
dnsmasq
fi
-- File "seemingly-impossible.hs",
-- automatically extracted from literate Haskell
-- file http://www.cs.bham.ac.uk/~mhe/papers/seemingly-impossible.html
--
-- Martin Escardo, September 2007
-- School of Computer Science, University of Birmingham, UK
--
-- These algorithms have been published and hence are in the
-- public domain.
--
#[bench]
fn test_overflow(b: &mut Bencher) {
let nums = [0i, ..1000000];
b.iter(|| {
let mut x = 0i;
for i in range(0, nums.len()) {
x = nums[i];
}
});
}
#![feature(simd)]
#![allow(experimental)]
extern crate test;
extern crate time;
use std::simd::f64x2;
use std::sync::{Arc,Future};
static CHUNKS: uint = 4;
static POINTS: uint = 10000000;
FROM fedora:22
ENV LANG="en_US.UTF-8" LANGUAGE="en_US:en" LC_ALL="en_US.UTF-8"
RUN dnf groupinstall -y "Development Tools" "Development Libraries" && dnf install -y wget git tar bzip2 && dnf clean all
RUN \
wget http://www.erlang.org/download/otp_src_18.1.tar.gz && \
tar -zxf otp_src_18.1.tar.gz && \
cd otp_src_18.1 && \
export ERL_TOP=`pwd` && \
defmodule PuzzledPintScriptElixir do
@base_string "http://www.puzzledpint.com/puzzles/august-2015/semaphore/"
defp get_file_strings do
File.read! "/usr/share/dict/cracklib-small"
end
def list_of_urls do
get_file_strings
|> String.split("\n", trim: true)
mutation do
field :submit_comment, :comment do
arg :repo_fullname, non_null(:string)
arg :content, non_null(:string)
resolve fn args, _ ->
comment = # create comment
{:ok, comment}
end
end
# Comment on a repository, returns the new comment
submitComment(
# The full repository name from GitHub, e.g. "apollostack/GitHunt-API"
repoFullName: String!,
# The text content for the new comment
commentContent: String!
): Comment
type Subscription {
# Subscription fires on every comment added