Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
EvanHahn / gist:2587465
Last active October 9, 2023 01:26
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
"Encrypt" like this:
caesarShift('Attack at dawn!', 12); // Returns "Mffmow mf pmiz!"
And "decrypt" like this:
@tizmagik
tizmagik / getLastInMap.js
Created August 13, 2016 03:22
ES6 Last Item in Map()
// Since ES6 Map()'s' retain their order of insertion, it can sometimes be useful to get the last item or value inserted:
export const getLastItemInMap = map => Array.from(map)[map.size-1]
export const getLastKeyInMap = map => Array.from(map)[map.size-1][0]
export const getLastValueInMap = map => Array.from(map)[map.size-1][1]
// Obviously getLastKey and getLastValue can reuse getLastItem, but for maximum portability I opted for verbosity.
@CelliesProjects
CelliesProjects / structToFile.ino
Last active September 1, 2023 18:04
Read and write a c++ struct to a file. Arduino IDE. ESP32.
/*
* EXAMPLE READING AND WRITING A C++ STRUCT TO A FILE
*/
#include <FS.h>
#include <FFat.h>
const char *fileName = "/somefile.txt";
struct aStruct {
char someString[11];
@hacknightly
hacknightly / riffwave.js
Created September 24, 2012 15:20
riffwave.js
/*
* RIFFWAVE.js v0.03 - Audio encoder for HTML5 <audio> elements.
* Copyleft 2011 by Pedro Ladaria <pedro.ladaria at Gmail dot com>
*
* Public Domain
*
* Changelog:
*
* 0.01 - First release
* 0.02 - New faster base64 encoding
@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example
@pda
pda / lircd.conf
Created January 4, 2014 05:35
LIRC config for my Apple Remote (aluminum) on Raspberry Pi / RaspBMC via one of these IR receivers: http://www.ebay.com/itm/121156693642?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sat Dec 7 19:14:59 2013
#
# contributed by
#
# brand: lirc-pda.conf
# model no. of remote control:
@mpilosov
mpilosov / GettingStartedWithGRBL.md
Last active May 26, 2023 19:22
Controlling Machines with GRBL

Instructions for a machine with GRBL already on it

My machine (basically this build: https://www.thingiverse.com/thing:1514145) has GRBL 0.9 : https://github.com/grbl/grbl/wiki/Configuring-Grbl-v0.9 The documents for newer version are up there too, obviously. It would definitely be good to get v1.1 working in order to learn the process of getting it on a fresh Arduino board. I'll outline the process of how to do that in the section below this one and fill in the details as I get around to figuring them out. Here's what I do know for sure though...

Sending GCode to the Machine

You can use any number of GUIs but the premise is always the same. Once the firmware is on your board, connect it via USB, power it on, and search in your /dev/ directory for your Arduino (type that into Terminal and start typing "tty" and then hit Tab until something shows up). If you have the Arduino software, use the drop down menus to identify an address like /dev/ttyusb#### or /dev/wchusbserial#### The numbers will be u

@runeb
runeb / js-exif-rotate.html
Created May 23, 2014 10:49
Auto-rotate images locally in the browser by parsing exif data
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input id="file" type="file" accept="image/*" />
<br/>
<h2>As read:</h2>
<img id="placeholder1" width=300/><br/>
<h2>Rotated by exif data:</h2>
<img id="placeholder2" width=300/>
<script>
@JedWatson
JedWatson / API-Auth-With-KeystoneJS.md
Last active April 16, 2023 02:11
API Auth with KeystoneJS

To implement API authentication in KeystoneJS, you need the following:

For key based authentication

  • Middleware that validates the key in the request body or a header

For session based authentication

  • An endpoint that handles signin
  • An endpoint that handles signout
@biovisualize
biovisualize / README.md
Last active April 12, 2023 12:15
direct svg to canvas to png conversion

It seems that Chrome finally found a way to let us convert from svg to canvas to png without the tainted canvas security feature/bug.