Skip to content

Instantly share code, notes, and snippets.

View ahalbert's full-sized avatar

Armand Halbert ahalbert

View GitHub Profile
@ahalbert
ahalbert / gist:7236782
Created October 30, 2013 17:36
weather script
import urllib3
import re
import us
import string
import json
http = urllib3.PoolManager()
req = http.request('get', "http://icanhazip.com")
ip = req.data[:-1]
req = http.request('GET', 'http://api.ipinfodb.com/v3/ip-city/?key=APIKEY&ip=' + ip)
function BayesNet(vars) {
this.variables = {};
this.numVars = Object.keys(this.variables).length;
for (v in vars) {
this.variables[v] = new BayesNode(vars[v]);
this.variables[v].CPTorder = this.generateDomainRows(this.variables[v].parents);
this.variables[v].fullCPT = {}
for (var i = 0; i < this.variables[v].CPTorder.length; i++) {
this.variables[v].fullCPT[this.variables[v].CPTorder[i]] = this.variables[v].CPT[i];
}
function BayesNet(vars) {
this.variables = {};
this.numVars = Object.keys(this.variables).length;
for (v in vars) {
this.variables[v] = new BayesNode(vars[v]);
this.variables[v].CPTorder = this.generateDomainRows(vars[v].parents);
this.variables[v].fullCPT = {};
this.variables[v].blocks = false;
}
for (v in vars) {
This will make a single serving of an "Oatmeal in a Cup". Its taste and texture is similar to a muffin or a baked oatmeal dish.
1/2 cup of quick cook oatmeal
1/2 cup of milk
1 egg
1/3 apple, chopped
1/3 bannana
a generous dash of cinnamon
1 teaspoon of honey
users
primary key
human/zombie/dead
npc?
admin?
star timer
name
living area
handle
Facebook account
function safeCreateDir($dir, $exit = true) {
if (!file_exists($dir)) {
if (!mkdir($dir, 0700, true)) {
$processUser = posix_getpwuid(posix_geteuid());
error_log($dir." ".implode($processUser));
if ($exit) {
debugMail('failed to create dir: ' . $dir, true);
}
return false;
}
class PlanDatesTest extends PHPUnit_Framework_TestCase
{
public function testDateDisplay() {
$this->assertEquals(PlanDates::dateDisplay(1438198178), "July 29, 2015");
$this->assertEquals(PlanDates::dateDisplay("2015-03-7"), "March 7, 2015");
}
public function testYearStart() {
$this->getMock('Util', array("isGrad"));
augroup VimjectsAutogroup
au BufNewFile,BufRead .vimjectrc* setlocal ft=vim
au VimEnter call vimjects#source("")
au VimEnter let g:kdsfjdfksdfjsfj = "hello"
au BufReadPre call vimjects#source("")
augroup end
showUnitString :: Unit -> String
showUnitString Unit m u
| (null posUnits) && (null negUnits) = ms
| null posUnits = ms ++ " 1/" ++ (showall negUnits)
| null negUnits = ms ++ (showall posUnits)
| otherwise = ms ++ (showall negUnits) ++ "/" ++ (showall negUnits)
where negUnits = Map.map (abs) (Map.filter (\ x -> x < 0.0) u)
posUnits = Map.filter (\ x -> x > 0.0) u
ms = show m
import qualified Data.Map as Map
import qualified Data.Text as Text
import qualified Data.List.Split as Split
import Text.Regex.PCRE
--Units represent
--Adding and subtraction can only be done on the same unit
--Multiplication combines units
--Exponentiation mult/div units
--Can only Ord things of the same unit
type UnitMap = Map.Map String Double