Skip to content

Instantly share code, notes, and snippets.

View benwilson512's full-sized avatar

Ben Wilson benwilson512

  • CargoSense
  • Fairfax, VA
View GitHub Profile
Categories below - after internal discussion we reduced the reparations as follows:
Severe - sacrifice captial or other major city:
Diablito (Swinging London)
LauraChristine (Complete)
Xandrosch
Keeves (Almost complete)
Sooner
Wuzzel/Wuzzy
@Kroll.method
public void getWirelessNetworks(KrollInvocation invocation) {
if (Util.gEmulatorMode == false) {
wifiMgr = (WifiManager) invocation.getTiContext().getActivity().getSystemService(Context.WIFI_SERVICE);
receiver = new WifiReceiver();
invocation.getTiContext().getActivity().registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
wifiMgr.startScan();
}
}
int[] x = [1,2,3,4,5]
int[] y;
for(int i = 0; i < x.length; i++) {
y[i] = Math.exp(x[i], 2);
}
x = 1...5
y = x.map {|n| n**2 }
class Device
attr_accessor :measurements
def initialize
@measurements = []
end
end
class Measurement
attr_accessor :frequency, :points, :magnitudes
last_file = Dir.open('.').select{|d| d.include?("output")}.sort.last
current_session = last_file ? last_file.match(/[0-9]{1,}/).to_s.to_i + 1 : 0
File.open("output#{current_session}.txt", 'a') do |f|
puts "Session: #{current_session}"
while thought = gets != "that's all for now\n"
print "\e[2J\e[f" # clear the screen.
f.write(thought)
end
end
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
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