Skip to content

Instantly share code, notes, and snippets.

@bisby
bisby / grades.rb
Last active August 29, 2015 14:20
Grades prediction
hw = [100, 85, 80, 95]
hw_avg = hw.inject(:+).to_f/hw.size
hw_weight = 35
midterm_score = 84
midterm_weight = 25
pmtg = 91
final_weight = 40
@bisby
bisby / Seq_sums.rb
Created April 26, 2015 23:46
Sequential Sums
total = ARGV[0] ? ARGV[0].to_i : 175
ways = ARGV[1] ? ARGV[1].to_i : 10
avg = total/ways
min = avg - (ways-1)/2
max = avg + (ways-1)/2 + 1
result = *(min..max)
resum = result.reduce(:+)
puts "Start "+total.to_s
@bisby
bisby / seq_split.php
Created April 26, 2015 23:35
Sum splitter
<?php
$X = isset($argv[1]) ? $argv[1] : 175;
$n = isset($argv[2]) ? $argv[2] : 10;
$y = $X/$n;
$result = range($y - ($n-1)/2, $y + ($n-1)/2);
$resum = array_reduce($result, function($carry, $item) {
return $carry + $item;
Game update: AppID 220200 "Kerbal Space Program", ProcID 3712, IP 0.0.0.0:0
ERROR: ld.so: object '/home/bisbyx/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/bisbyx/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Found path: /home/bisbyx/.local/share/Steam/SteamApps/common/Kerbal Space Program/KSP.x86_64
Mono path[0] = '/home/bisbyx/.local/share/Steam/SteamApps/common/Kerbal Space Program/KSP_Data/Managed'
Mono path[1] = '/home/bisbyx/.local/share/Steam/SteamApps/common/Kerbal Space Program/KSP_Data/Mono'
Mono config path = '/home/bisbyx/.local/share/Steam/SteamApps/common/Kerbal Space Program/KSP_Data/Mono/etc'
Aborted
Game removed: AppID 220200 "Kerbal Space Program", ProcID 3712
@bisby
bisby / asus-rma.rb
Last active August 29, 2015 14:06
ASUS RMA Status
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'json'
class AsusRma
attr_accessor :json, :data
@@url = "http://www.asus.com/support/Repair-Status-Result"
@rmano = ''
@bisby
bisby / infinite loop
Created September 10, 2014 20:32
Its crazy isn't it.
<?php
$array = array("123", "456A", "78");
while ($array[0] < $array[1]) {
echo "{$array[0]} < {$array[1]}" . PHP_EOL;
array_push($array, array_shift($array));
}
function compareVersion (a, b) {
var parts_a = a.split('.');
var parts_b = b.split('.');
var length = Math.max(parts_a.length, parts_b.length);
parts_a = extendAsInt(parts_a, length);
parts_b = extendAsInt(parts_b, length);
return parts_a.reduce( function (prev, current, i, self) {
if (prev != 0) { return prev; }
<canvas id="whiteboard" width="400" height="400"></canvas>
<script>
var example = document.getElementById('example');
var context = example.getContext('2d');
var X = 0, Y = 0, draw = false;
example.onmousedown = function(e) {
X = e.pageX - this.offsetLeft;
Y = e.pageY - this.offsetTop;