This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
repository(owner: "sdiehl", name: "write-you-a-haskell") { | |
pullRequests(first: 100) { | |
nodes { | |
participants(first: 5) { | |
nodes { | |
login | |
isHireable | |
bio | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder