Skip to content

Instantly share code, notes, and snippets.

@Xodarap
Xodarap / booth.py
Created May 14, 2011 00:21
Booth's Multiplication Algorithm
from bitstring import BitArray
'''
Returns m * r using Booth's algorithm.
x = len(m) and y = len(r). Note that this is the length in base 2.
See http://en.wikipedia.org/wiki/Booth%27s_algorithm
'''
def booth(m, r, x, y):
# Initialize
totalLength = x + y + 1
class Rope {
constructor(text) {
this.text = text;
this.size = text.length
}
insert(text, location) {
let { left, right } = this.splitAt(location)
// Avoid creating empty children
if (right.toStringPretty() == '') right = undefined;
--Diagnoses
select "CPTItemDetail"."value", "BillingItems"."itemName", "BillingData"."icdcode1", "BillingData"."icdcode2", "BillingData"."icdcode3", "BillingData"."icdcode4", "PATIENT"."hl7Id", "PATIENT_USERS"."ssn", "PATIENT_USERS"."ptDob", case when "PATIENT_USERS"."sex" = '' then 'Unknown' else "PATIENT_USERS"."sex" end , case when "PATIENT"."deceased" = 1 then 'Yes' when "PATIENT"."deceased" = 0 then 'No' else 'UnKnown' end , "CHARGE_ETHNICITY"."Name", "PATIENT"."language", "encBillingData"."date", "ChargeUser___Patient"."ptDob", "PATIENT_USERS"."ufname", "PATIENT_USERS"."uminitial", "PATIENT_USERS"."ulname", "PATIENT_USERS"."uemail", "PATIENT_USERS"."upPhone", "PATIENT_USERS"."upaddress", "PATIENT_USERS"."upcity", "PATIENT_USERS"."upstate", "PATIENT_USERS"."zipcode", "EDI_FACILITIES"."code", "EDI_FACILITIES"."Id", "EDI_FACILITIES"."Name", "EDI_FACILITIES"."startedOn", "APPOINTMENT_DOCTOR"."NPI", "APPOINTMENT_PROVIDER"."uid", "APPOINTMENT_DOCTOR"."TaxID", "APPOINTMENT_DOCTOR"."SpecialityCode", "APPOIN
import psycopg2
import itertools
import pandas
import numpy as np
import matplotlib.pyplot as plt
def lorenz_curve(X):
X = np.array(X, dtype='int64')
X.sort()
X_lorenz = X.cumsum() / X.sum()
# send libnotify updates only for certain users. Edit the variable okAccounts to select which accounts.
#
# depends on notify-send
# To install, add this to your ~/.purple/plugins directory (you may have to create it)
# Then enable the plugin
use Purple;
# edit the keys in this hash to enable alerts for only these users
# the value is irrelevant
%okAccounts = ('User 1' => '1',
{
repository(owner: "sdiehl", name: "write-you-a-haskell") {
pullRequests(first: 100) {
nodes {
participants(first: 5) {
nodes {
login
isHireable
bio
email
@Xodarap
Xodarap / todo.rb
Created June 30, 2014 14:33
Scripts to synchronize Todoist and habitRPG
# Simple script to synchronize Todoist and habitRPG
# only marks complete items in Todoist as complete in habitRPG,
# doesn't synchronize non-complete to do items
#
# Note: this script uses a temporary file to store the most recent sequence number from
# Todoist. Therefore, it must be stored in a spot where it has write access to a new file,
# and if you move it you'll either need to comment out the body of the loop below or else
# move the file.
#
# If this is the first time you're running the script, you might want to comment out the
SELECT DISTINCT
doctors.NPI AS "Provider NPI",
users.ufname AS "Provider First Name",
users.ulname AS "Provider Last Name"
FROM
enc INNER JOIN doctors
ON enc.doctorID = doctors.doctorID
LEFT JOIN users
ON doctors.doctorID = users.uid
@Xodarap
Xodarap / food.r
Last active December 12, 2015 02:29
food things and veg
library(R.oo)
library(plyr)
# Main function. Given the number of new vegetarians (in millions),
# returns the number of people brought into or out of poverty.
changeInPoor = function(milVeg) {
# Demand in the F&P paper was 61 million bushels
# We find the % change in feed demand, and use that with the elasticity
# from F&P to find % change in price
relDemandChange = vegChange(milVeg) / 61
@Xodarap
Xodarap / heat.m
Created July 7, 2012 16:26
Heat calculation
function q = heat(mph)
% Given a walking speed in miles per hour, returns the energy given off as heat
% in 30 degree celsius temperature with no wind.
% No simple formula for energy taken by exercise, unfortunately
if mph == 3
exCalPerH = 230;
elseif mph == 4
exCalPerH = 350;
elseif mph == 5