Skip to content

Instantly share code, notes, and snippets.

View benwilson512's full-sized avatar

Ben Wilson benwilson512

  • CargoSense
  • Fairfax, VA
View GitHub Profile
package com.button.radio;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
require 'rubygems'
require 'json'
SITE = "http://www.righttofoodindia.org/"
links = JSON.parse(File.open("map.json").read)
# links.each do |link|
# filename = link["name"].downcase.gsub(" ", "_").gsub("'", "").gsub("/", "")
# category = link["uri"].split("/").first
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)
public void holdYaw(double target,double factor) throws FgException
{
// get current Heading degree
// calculate the deviation in degree
double aircraftHdg = a.getHeadingDeg();
double degreeToTurn = calcDegreeToTurn();
// Limit the potential for an integrator to accumulate ridicuously high values when
// we cannot reach its target yaw for a period of time.
@benwilson512
benwilson512 / linear regression
Last active December 22, 2015 22:59
Linear regression for a set of points. of the form [{x1, y1}, {x2, y2}] etc. I iterate through the point array several times which is unfortunate. The alternative was to try to iterate once and build several different states simultaneously, but this was at least prima facie easier.
# http://en.wikipedia.org/wiki/Simple_linear_regression
defmodule Exchange.Calc do
def linear_regression(points) do
n = length(points)
# Average of sum of products
sop_bar = sum_of_products(points) / n
# Average of sum of x and y respectively
# 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
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