Skip to content

Instantly share code, notes, and snippets.

View freshwater's full-sized avatar

Tony Marquez-Raygoza freshwater

View GitHub Profile
context = document.createElement('canvas').getContext("2d");
measure = (s) => context.measureText(s).width;
input = document.querySelector("input");
context.font = window.getComputedStyle(input).font;
searchHeight = parseInt(window.getComputedStyle(input).height, 10);
tokens = ['from:', 'to:', 'mention:', 'mentioned:'];
function makeDiv() {
let div = document.createElement('div');
@freshwater
freshwater / EC2.md
Last active October 8, 2020 17:58
EC2

Start an instance

  • Go to AWS. https://console.aws.amazon.com.
  • Be sure to set the region as North Virginia (us-east-1).
    • Many services are separated by region, and some services are only available in us-east-1.
    • us-east-1 is the safe/default choice.
    • The UI is also separated by region. If you aren't finding something that you thought you created, it might be in a different region.
  • Navigate to EC2 and start the instance launch process.
  • Search for the "deep learning" image. Choose an Ubuntu image. The first one is fine.
    • This image is useful if you don't want to figure out how to install specific libraries.
  • In the long run, I recommend getting familiar with Dockerfiles.
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
# from itertools import chain, combinations
from IPython.display import SVG
# named colors
_colors = matplotlib.colors.cnames
## Interface: 30000
## Title: TargetNotes
## Notes: Store notes about a target. The notes will be visible whenever the target is seen again.
## SavedVariables: TARGETNOTES_DB, TARGETNOTES_INDEX
database.lua
target_ui.xml
search_ui.xml
search_ui.lua
main.lua
@freshwater
freshwater / automata4.m
Created December 30, 2012 02:39
Cellular Automata on Cylindrical Geometry
(* Cellular Automata on Cylindrical Geometry *)
graphicsSize = {600, 400};
gridControlHeight = 14;
shapeChoicesIconSize = {25, 25};
{widthDefault, widthMin, widthMax} = {40, 30, 60};
{iterationsDefault, iterationsMin, iterationsMax} = {60, 10, 80};
@freshwater
freshwater / flipbook.js
Created October 2, 2012 07:07
Custom slide view control.
/*
* made for my website http://www.oftenpaper.net
*/
jQuery(document).ready( function($) {
// construct is called on each flipbook
var constructFlipbook = function( $, flipbook ) {
var lis = flipbook.children('li');
@freshwater
freshwater / L-systems.m
Created September 30, 2012 03:47
An L-systems demonstration in Mathematica.
(* title: Graphical L-systems demonstration *)
(* a live version of this demonstration can be found at
http://demonstrations.wolfram.com/GraphicalLSystems/ *)
imageSize = {400, 400};
thumbSize = {26, 26};
thumbPadding = 2;
nextStyle = {RGBColor[1, .6, .6], Dashing[1 / (40 + 3^(i+1))]};
maxIterations = 5; (* initialized so it's not Null *)
@freshwater
freshwater / co.lisp
Created September 30, 2012 03:43
Symmetric coroutines/generators/iterators in Arc.
;co - an implementation of symmetric coroutines/generators/iterators in Arc
;Arc is a Lisp dialect built on top of MzScheme. It uses that
;language's call-with-current-continuation (ccc in Arc).
;This code is so short it almost looks easy, but it took some
;headaches to figure out how to do it.
;Within the body, 'yield is the function which holds the exit
;continuation. Since it's a function, it can be passed around at
;will, such as into higher-order functions. (example below)
@freshwater
freshwater / StateMachine.java
Created September 30, 2012 03:40
Reversible state machine for a calculator application.
package com.hudcalc.hudcalc;
import com.hudcalc.hudcalc.SymbolList.Symbol;
public class StateMachine
{
// maximum input length for each number, in digits
int maxLength = 8;
enum State {
@freshwater
freshwater / parser.fs
Created September 30, 2012 03:32
Parser/Executor for a simple LOGO language.
#light
// parser-executer for a simple LOGO language
// was to form part of a larger project which I
// ultimately chose to pursue in C# with embedded Lua
module parser
open System