Skip to content

Instantly share code, notes, and snippets.

View c2huc2hu's full-sized avatar

Christopher Chu c2huc2hu

View GitHub Profile
@c2huc2hu
c2huc2hu / pypipe
Created June 16, 2023 19:45
Use python lambdas/functions with bash pipes
#!/usr/bin/env python
import argparse
import importlib
import sys
parser = argparse.ArgumentParser(description="Use python functions on the command line", epilog=r"""example:
echo "hello\nworld" | pypipe "lambda s: s.upper()"
echo "1\n2\n3" | pypipe "lambda x: int(x) ** 2"
@c2huc2hu
c2huc2hu / webstack.md
Created November 8, 2021 22:48
Updated summary of web stacks

Web stack

Creating webpages is fairly easy, but it's hard to know where to get started. This document will cover the very basic technologies. I'm mostly going to show what I hope are illuminating examples.

Ex 1: Let's start with a basic webpage

index.html

<h1> Title. Note the opening and closing tags </h1> 
@c2huc2hu
c2huc2hu / filter-tests.html
Created February 18, 2021 21:38
Test different audio filters for voice muffling
<p>
Audio filters to muffle human voice in a Gist so I can iterate on it quickly.
<ul>
<li>Convolution with white noise for reverb</li>
<li>Lowpass to further remove speech frequencies </li>
<li>Delay so you can hear what you just said</li>
</ul>
</p>
<video style="width: 600px; height: 400px;"></video>
<button onclick="start()">Click me to start</button>
@c2huc2hu
c2huc2hu / checklist.md
Last active January 22, 2024 15:18
Checklist for factorio "there is no spoon" on default settings

Factorio There is no spoon run

These are guidelines for a multiplayer run at default settings (speedrunning default% settings). For an easier time, you can set the resource richness high, starting area to max and biters to minimum (but not off), but where's the fun in that?

Basic Resources

For a normal run with increased resource richness, your starter patches will be large enough. If not, you need to select patches with a total of:

import random
import time
import numpy as np
N = 10000000
# exclude initialization from benchmarks
a = [random.randint(1, 100) for i in range(N)]
b = [random.randint(1, 100) for i in range(N)]
a_np = np.array(a)
b_np = np.array(b)
@c2huc2hu
c2huc2hu / arduino_color.ino
Created February 1, 2019 02:20
Code for a skittle sorter
/* Arduino Project - Color Sorting Machine
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
*/
#include <Servo.h>
#define S0 2
#define S1 3
#define S2 4
@c2huc2hu
c2huc2hu / clustering_method.m
Created November 5, 2018 04:44
Two solutions that don't work because of MATLAB grader
target = imread('example_target.png');
% harris returns two objects: pts, cim. cluster them
[pts, cim] = harris(target, 1, 1500, true);
T = clusterdata(pts', 0.8);
% Find the 48 largest clusters
[n, bin] = hist(T, unique(T));
[~,idx] = sort(-n);
largest_clusters = bin(idx(1:48));
@c2huc2hu
c2huc2hu / software_cheatsheet.md
Last active October 7, 2017 18:55
RSX software cheatsheet
@c2huc2hu
c2huc2hu / charging_stations.json
Created January 21, 2017 03:34
List of charging stations pulled from: http://www.afdc.energy.gov
{"station_locator_url":"http://www.afdc.energy.gov/afdc/locator/stations/","total_results":337,"station_counts":{"total":2309,"fuels":{"LNG":{"total":0},"BD":{"total":0},"CNG":{"total":0},"LPG":{"total":0},"E85":{"total":0},"ELEC":{"total":2309,"stations":{"total":337}},"HY":{"total":0}}},"fuel_stations":[{"access_days_time":"24 hours daily; for Tesla use only","cards_accepted":null,"date_last_confirmed":"2016-11-02","expected_date":null,"fuel_type_code":"ELEC","id":50813,"groups_with_access_code":"Public","open_date":"2012-12-01","owner_type_code":"P","status_code":"E","station_name":"Milford Southbound Service Plaza - Tesla","station_phone":"877-798-3752","updated_at":"2016-11-02T17:18:04Z","geocode_status":"GPS","latitude":41.24718,"longitude":-73.009992,"city":"Milford","intersection_directions":"Connecticut Turnpike","plus4":null,"state":"CT","street_address":"I-95 S","zip":"06460","bd_blends":null,"e85_blender_pump":null,"ev_connector_types":["TESLA"],"ev_dc_fast_num":2,"ev_level1_evse_num":null,"ev_lev
@c2huc2hu
c2huc2hu / Main.java
Created October 20, 2016 21:33
PID Controller for LEJOS
/* Code by Richard, Albert, Chris */
/* P, PI, PID controller. for the real thing, we tuned it with the main2 code */
import lejos.hardware.motor.*;
import lejos.hardware.port.SensorPort;
import lejos.hardware.sensor.EV3ColorSensor;
import lejos.hardware.Button;
public class Main {
public static void main(String[] args) {
System.out.println("STARTING MAIN");