Skip to content

Instantly share code, notes, and snippets.

@eric-wieser
eric-wieser / README.md
Last active September 30, 2015 02:08
6.004 File downloader and uploader

Use bookmarklet.js to get files in and out of the browser, and convert.py to convert them into separate files per module

Downloading

  1. hit F12 to get the console and paste in the code below
  2. Click the download button that appeared on the toolbar (the cloud icon)
  3. (optional) drag the result onto convert.py to separate the modules

Uploading

  1. hit F12 to get the console and paste in the code below
  2. (optional) after making changes to the separated modules, drag the folder back onto convert.py
@eric-wieser
eric-wieser / README.md
Last active August 29, 2015 14:27 — forked from anonymous/Legoline.md
Legoline work

Initial concepts

Option A - chain with pin holes

Special parts needed:

  • 57520 - small sprocket (3LU diam)
  • 57519 - large sprocket (5LU diam)
  • 57518 - chain tread (1.5LU pitch)
import requests
import ravenclient
import time
import datetime
from bs4 import BeautifulSoup as soup
url = 'https://www.mealbookings.cai.cam.ac.uk/?event=455&date=2015-06-09'
# line below does non-superhall
url = 'https://www.mealbookings.cai.cam.ac.uk/index.php?event=431&date=2015-05-24'
template<int N>
std::array<float, N - 1> gradient(const std::array<float, N> &datain, float dx){
std::array<float, N - 1> result;
for (unsigned long i = 0; i < N-1; i++){
result[i] = (datain[i] + datain[i + 1]) / dx;
}
return result;
}
@eric-wieser
eric-wieser / readme.md
Created March 18, 2014 11:21
Pip vcvarsall.bat 64-bit python 3.4
@eric-wieser
eric-wieser / combined.json
Last active January 4, 2016 10:19
Wine vs tompkins score
[{"tompkins": 64.37, "firsts": 19.8, "name": "Sidney Sussex", "wine": 97507}, {"tompkins": 60.92, "firsts": 15.8, "name": "Newnham", "wine": 27263}, {"tompkins": 64.16, "firsts": 21.4, "name": "Fitzwilliam", "wine": 23028}, {"tompkins": 65.49, "firsts": 25.9, "name": "King's", "wine": 338559}, {"tompkins": 57.92, "firsts": 13.2, "name": "Hughes Hall", "wine": 14033.58}, {"tompkins": 60.51, "firsts": 18.9, "name": "Wolfson", "wine": 39647.1}, {"tompkins": 73.66, "firsts": 41.7, "name": "Trinity", "wine": 223291.98}, {"tompkins": 64.85, "firsts": 21.1, "name": "Caius", "wine": 96994}, {"tompkins": 68.94, "firsts": 28.1, "name": "Trinity Hall", "wine": 127186}, {"tompkins": 65.84, "firsts": 25.1, "name": "St John's", "wine": 260064}, {"tompkins": 66.51, "firsts": 26.9, "name": "St Catharine's", "wine": 62432}, {"tompkins": 66.76, "firsts": 24.7, "name": "Christ's", "wine": 71055}, {"tompkins": 66.05, "firsts": 23.0, "name": "Downing", "wine": 77798}, {"tompkins": 62.92, "firsts": 18.5, "name": "Girton", "wine":

Want to fork your own gists? No fork button? No problem! Install this user script by clicking refork.user.js' "raw" link down below: ⇓

@eric-wieser
eric-wieser / itemset.lua
Last active August 9, 2024 02:47
A library to make inventory management with computercraft turtles more straightforward
local ItemSet = {}
ItemSet.__index = ItemSet
ItemSet.new = function(mapping)
return setmetatable({mapping=mapping}, ItemSet)
end
-- internal functions
local _useItem = function(self, fn, name)
local i = self:slot(name)
turtle.select(i)
@eric-wieser
eric-wieser / gist:3804277
Created September 29, 2012 15:03
Pythons MRO implemented in Lua
merge = function(seqs)
local res = {}
while true do
--filter out empty sequences
local nonemptyseqs = {}
for _, seq in ipairs(seqs) do
if #seq > 0 then table.insert(nonemptyseqs, seq) end
end
--all sequences empty? we're done!
if #nonemptyseqs == 0 then return res end
@eric-wieser
eric-wieser / pyclass.lua
Created September 26, 2012 07:26
Python-style classes in lua
--quick implementation of python's id function. Fails for built in roblox objects
id = function(o)
return type(o) == "table" and o.__id__ or tonumber(tostring(o):sub(-8, -1). 16)
end
class = setmetatable({}, {
__call = function(_, name, implementer)
local cls = {__init__ = function() end, __name__ = name}
local instancemt = {}