Skip to content

Instantly share code, notes, and snippets.

Avatar
Caffeinating in a Hybrid Way

Jesse Donat donatj

Caffeinating in a Hybrid Way
View GitHub Profile
View example.go
package main
import (
"syscall/js"
)
func main() {
quit := make(chan struct{}, 0)
document := js.Global().Get("document")
@donatj
donatj / cube.py
Last active Aug 12, 2022
Micropython Spinning Cube
View cube.py
import math
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
i2c=I2C(1,sda=Pin(26), scl=Pin(27), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
class Point3D :
x = 0;
y = 0;
View example.js
fileInput.addEventListener('input', function(){
fileInput.files[0].arrayBuffer().then(function(x){
const data = new Uint8Array(x[0]);
// send the data to Go (it only accepts bytes as Uint8Array's
})
});
@donatj
donatj / index.html
Created Jan 27, 2022
Simple Gif Play/Pause
View index.html
<html>
<body>
<img src="tumblr_ngqdgj3vqt1sulnzno1_500.gif">
<img src="tumblr_ngqdgj3vqt1sulnzno1_500.gif" width="100">
<img src="tumblr_ngqdgj3vqt1sulnzno1_500.gif" style="width: 30px; height: 200px;">
<br>
<button onclick="play()">Play</button>
<button onclick="pause()">Pause</button>
@donatj
donatj / ascii.php
Created Nov 9, 2011
Damn Simple PHP Ascii Art Generator
View ascii.php
#!/usr/bin/php -q
<?php
if(isset($argv[1]) && strlen($argv[1])) {
$file = $argv[1];
}else{
echo 'Please Specify a File';
exit(1);
}
@donatj
donatj / subtitles.php
Last active Jul 10, 2020
Crappy .srt helper
View subtitles.php
#!/usr/bin/env php
<?php
date_default_timezone_set('UTC');
$stderr = fopen('php://stderr', 'wb');
$shift = 0.0;
switch( $argv[1] ?? '' ) {
case 'shift':
@donatj
donatj / get-dependencies.sh
Created Apr 14, 2020
Recursively get every dependency and version from package-lock.json
View get-dependencies.sh
cat package-lock.json | jq -r '.. | select(.>={}) | .dependencies | select(. != null) | to_entries[] | .key + ": " + .value.version' | sort | uniq
@donatj
donatj / ColorCLI.php
Created Oct 26, 2011
Simple CLI color class
View ColorCLI.php
<?php
class ColorCLI {
static $foreground_colors = array(
'bold' => '1', 'dim' => '2',
'black' => '0;30', 'dark_gray' => '1;30',
'blue' => '0;34', 'light_blue' => '1;34',
'green' => '0;32', 'light_green' => '1;32',
'cyan' => '0;36', 'light_cyan' => '1;36',
@donatj
donatj / http.go
Last active Sep 12, 2018
Golang Basic Auth
View http.go
package utils
import (
"net/http"
)
func BasicAuth(handler http.Handler, username, password string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if u, p, ok := r.BasicAuth(); !ok || !(u == username && p == password) {
w.Header().Set("WWW-Authenticate", "Basic realm=\"ZorkIrc\"")
View examples.md

TypeScript

class MyLogicContainer {
    constructor(private x: number) { }
    
    add(y: number) {
        return this.x + y;
    }
}