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 { octokit } from './index.js'; | |
import fs from 'fs'; | |
// if no data.json file in root, make a new one | |
if (!fs.existsSync('./data.json')) { | |
let data = [{ query: 'defi language:javascript stars:>1000', extensions: ['js', 'ts', 'sol', 'yml'], currentPage: 0, endPage: 10, lastRunDate: null, files: [] }] | |
fs.writeFileSync('./data.json', JSON.stringify(data)); | |
} | |
async function searchRepo(query, page) { |
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 color balance algorithm using Python 2.7.8 and OpenCV 2.4.10. | |
# Ported from: http://www.morethantechnical.com/2015/01/14/simplest-color-balance-with-opencv-wcode/ | |
# See also http://web.stanford.edu/~sujason/ColorBalancing/simplestcb.html | |
import cv2 | |
import math | |
import numpy as np | |
import sys | |
def apply_mask(matrix, mask, fill_value): |
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
var f = function(theta) { | |
//return 30 * Math.log(theta) + 20 * Math.log(1-theta) | |
return Binomial({p: theta, n: 30}).score(14) | |
} | |
globalStore["x"] = 0.001; | |
repeat(100, | |
function() { | |
var x = globalStore["x"], |
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
// uses lodash, not underscore | |
var sampleSubset = function(xs) { | |
var n = xs.length; | |
var toBinary = function(dec){ | |
// convert decimal to binary | |
var _s = (dec >>> 0).toString(2); | |
// do left padding | |
var k = _s.length; |
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
var n = 15000; | |
// Switching from repeat to map(fn, _.range(n)) causes this to use lots of | |
// memory. (~1GB) | |
// Setting n = 20000 gives "Allocation failed - process out of memory". Up the | |
// limit with e.g. node --max-old-space-size=2000 | |
var data = repeat(n, function(i) { | |
var obj = { |
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 9.
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
"county","idnum","state","state2","stfips","zip","region","typebldg","floor","room","basement","windoor","rep","stratum","wave","starttm","stoptm","startdt","stopdt","activity","pcterr","adjwt","dupflag","zipflag","cntyfips","Uppm" | |
"AITKIN",5081,"MN","MN",27,55735,5,1,1,3,"N",NA,2,4,41,930,930,12088,12288,2.2,9.7,1146.49919,1,0,1,0.502054 | |
"AITKIN",5082,"MN","MN",27,55748,5,1,0,4,"Y",NA,5,2,40,1615,1615,11888,12088,2.2,14.5,471.366223,0,0,1,0.502054 | |
"AITKIN",5083,"MN","MN",27,55748,5,1,0,4,"Y",NA,3,2,42,1030,1515,20288,21188,2.9,9.6,433.316718,0,0,1,0.502054 | |
"AITKIN",5084,"MN","MN",27,56469,5,1,0,4,"Y",NA,2,2,24,1410,1410,122987,123187,1,24.3,461.62367,0,0,1,0.502054 | |
"ANOKA",5085,"MN","MN",27,55011,3,1,0,4,"Y",NA,3,2,40,600,600,12888,13088,3.1,13.8,433.316718,0,0,3,0.428565 | |
"ANOKA",5086,"MN","MN",27,55014,3,1,0,4,"Y",NA,5,2,22,900,1300,120287,121187,2.5,12.8,471.366223,0,0,3,0.428565 | |
"ANOKA",5087,"MN","MN",27,55014,3,1,0,4,"Y",NA,5,2,28,2000,2025,121887,122087,1.5,14.5,471.366223,0,0,3,0.428565 | |
"ANOKA",5088,"M |
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
var rDPmem = $b({ | |
name: 'rDPmem', | |
desc: 'Retrospective implementation of DPmem', | |
params: [{name: 'alpha', type: 'positive real', desc: 'Concentration parameter'}, | |
{name: 'f', type: 'function', desc: 'Function to stochastically memoize'}], | |
fn: function(alpha, f) { | |
var allStickSets = {}; | |
var cumulativeStickSums = {}; | |
var caches = {}; | |
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
(length (list 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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
\\(^\\|\\. \\)\\([a-z]\\) | |
\1\,(upcase \2) |
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
(define (pn x) (for-each display (list x "\n"))) | |
(define (! n) | |
(let iter ((product 1) | |
(counter 1)) | |
(if (> counter n) | |
product | |
(iter (* counter product) | |
(+ counter 1))))) |
NewerOlder