Skip to content

Instantly share code, notes, and snippets.

View cheeseonamonkey's full-sized avatar
😅
Sweating, and smiling

Alexander H cheeseonamonkey

😅
Sweating, and smiling
View GitHub Profile
@cheeseonamonkey
cheeseonamonkey / chesscomapi.js
Created May 20, 2024 20:09 — forked from replete/chesscomapi.js
get game data from chess.com API
//https://api.chess.com/pub/player/{username}/games/2023/02
(async function main () {
async function getChessGamesForMonth(username, year, month) {
const res = await fetch(`https://api.chess.com/pub/player/${username}/games/${year}/${month}`);
if (res.ok) {
const data = await res.json();
return data.games
} else {
console.error('Problem loading chess.com games from API', res);
@cheeseonamonkey
cheeseonamonkey / Float32_Base64_Encoding_Decoding.js
Created December 23, 2023 08:51 — forked from sketchpunk/Float32_Base64_Encoding_Decoding.js
Encode Float32Array to base64 , then decode it back
let verts = new Float32Array( [ 0, 2, 0, -1, 0.2, 0, 1, 0.2, 0 ] );
let v = base64_test( verts );
function base64_test( fary ){
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ENCODING TEST
console.log("Origin Data", fary );
let uint = new Uint8Array( fary.buffer );
console.log( "Convert F32 to Uint8 : Byte Length Test", fary.length * 4, uint.length );
@cheeseonamonkey
cheeseonamonkey / timestamp-hash.js
Created August 18, 2023 08:38 — forked from whoisryosuke/timestamp-hash.js
JS - Generate semi-unique hash based off timestamp
const hash = Number(new Date).toString(36)
@cheeseonamonkey
cheeseonamonkey / Linux Desktop Shortcut
Created July 2, 2023 03:02 — forked from KomanRudden/Linux Desktop Shortcut
Linux desktop shortcut for shell script
[Desktop Entry]
Name=SQL Developer
Exec=/home/koman/Java/sqldeveloper/sqldeveloper.sh
Icon=/home/koman/Java/sqldeveloper/icon.png
Terminal=false
Type=Application
@cheeseonamonkey
cheeseonamonkey / word2vec-download300model.sh
Created June 4, 2023 10:48 — forked from yanaiela/word2vec-download300model.sh
simple bash script for downloading the Google word2vec model (https://code.google.com/archive/p/word2vec/) from Google-Drive
#!/bin/bash
# usage:
# first make the file executable
# ./word2vec-download300model.sh output-file
OUTPUT=$( wget --save-cookies cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=0B7XkCwpI5KDYNlNUTTlSS21pQmM' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/Code: \1\n/p' )
CODE=${OUTPUT##*Code: }
echo $CODE
@cheeseonamonkey
cheeseonamonkey / exa-aliases.zsh
Last active April 22, 2023 01:12 — forked from akarzim/exa-aliases.zsh
Exa ZSH aliases
#modified these:
alias ls='exa --classify --icons --color-scale'
alias ll='exa --long --classify --icons --color-scale --no-user --no-permissions --no-time'
alias la='ll -a' # Lists human readable sizes, hidden files.
alias lm='la | "$PAGER"' # Lists human readable sizes, hidden files through pager.
alias lx='ll --sort=Extension' # Lists sorted by extension (GNU only).
alias lk='ll --sort=size -r' # Lists sorted by size, largest last.
alias lt='ll --sort=modified -r' # Lists sorted by date, most recent last.
#alias sl='ls' # I often screw this up.
@cheeseonamonkey
cheeseonamonkey / pretty_print.css
Created October 3, 2022 09:44 — forked from pinglamb/pretty_print.css
JSON Pretty Print JS
body { font-family: monospace; font-size: 1.1em; }
ul { margin: 0 0 0 .2em; list-style: none; }
li { padding: 0; margin: 0;}
li:after { content: ','; }
li:last-child:after { content: ''; }
span.object { font-weight: bold; }
span.string, span.string a { color: green; }
@cheeseonamonkey
cheeseonamonkey / Singletons.md
Created September 20, 2022 23:18 — forked from coiscir/Singletons.md
JavaScript Singletons

From http://stackoverflow.com/a/15196301/:

p.s. i'll be glad to hear you solution to my other question stackoverflow.com/questions/15274927/…. ( maybe you have a better solution). Royi Namir 2013-03-08 07:03:32Z

The answers do include good examples of both eagerly-loaded/instant (e.g., jantimon, SLaks) and lazy-loaded singletons (e.g., Kolink).

Though, for a few variations on lazy-loaded: :)

It is possible to return the instance (single-instance-constructor.js) each time, but this will probably be confusing unless [it's not actually new](http://jsfiddle.net/cois

@cheeseonamonkey
cheeseonamonkey / ExamplePartOfActivity.java
Created January 31, 2022 10:49 — forked from cardil/ExamplePartOfActivity.java
MultiSelectList Preference Settings
private static OnPreferenceChangeListener autoOnChangeListener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference rawPreference, Object newValue) {
List<CharSequence> selected = Arrays.asList((CharSequence[]) newValue);
if (selected.contains("1")) {
// do some work
}
return true;
}