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
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var seedrandom = require('seedrandom'); | |
var rng = seedrandom.xor4096('hello.'); | |
console.log(rng()); |
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
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var $ = require('jquery'); | |
var seedrandom = require('seedrandom'); | |
var rng = seedrandom.xor4096('hello.'); | |
for (var j = 0; j < 20; ++j) { | |
$('body').append('<p>' + rng() + '</p>'); | |
} |
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 Parser = require('parse5').Parser; | |
//Instantiate parser | |
var parser = new Parser(null, {locationInfo: true}); | |
//Then feed it with an HTML document | |
var d = parser.parseFragment('<p>hello<p>hello') | |
var info = ['<pre>', 'fragment has ' + d.childNodes.length + ' top-level nodes']; | |
for (var j = 0; j < d.childNodes.length; ++j) { |
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
# Google form submit-maker. | |
# | |
# Usage: python googlesender.py https://docs.google.com/forms/d/e/1.../viewform | |
# | |
# Point this python file at a live Google forms URL, and it will generate | |
# code for a Javascript function that submits to that form cross-domain. | |
# | |
# Notes: | |
# - The form should be created with "short answer text" questions. | |
# - The viewform URL to scrape is the link shared when the form is sent. |
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
license: mit |
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
#!/usr/bin/env python | |
""" | |
npycat: cat utility and swiss army knife for numpy and pytorch files. | |
""" | |
import numpy, argparse | |
args = None | |
def main(): |
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
#!/usr/bin/env python2.7 | |
# Script to create simple flat pytorch ImageFolder folder hierarchy | |
# of training and validation images for miniplaces. Each category | |
# name is just a folder name (numbered in alphabetical order as in | |
# the original miniplaces), and both train and val images are places | |
# directly inside a single level of folders with the flat cateogry names. | |
import shutil, os, tarfile |
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 collections import defaultdict | |
from importlib import import_module | |
def autoimport_eval(term): | |
''' | |
Used to eval any expression containing fully-qualified names, such as | |
'torchvision.models.alexnet(pretrained=True)' with automatic import of | |
global module names. | |
''' |
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 os | |
import torch.utils.data as data | |
from torchvision.datasets.folder import default_loader, is_image_file | |
from PIL import Image | |
def grayscale_loader(path): | |
with open(path, 'rb') as f: | |
return Image.open(f).convert('L') | |
class FeatureFolder(data.Dataset): |
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
<!DOCTYPE html> | |
<html> | |
<!-- an example vue HTML file that displays images and metadata --> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js" | |
integrity="sha256-CMMTrj5gGwOAXBeFi7kNokqowkzbeL8ydAJy39ewjkQ=" | |
crossorigin="anonymous"></script> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.js" | |
integrity="sha256-qwbDmNVLiCqkqRBpF46q5bjYH11j5cd+K+Y6D3/ja28=" | |
crossorigin="anonymous"></script> |
OlderNewer