Skip to content

Instantly share code, notes, and snippets.

@gretel
gretel / amiibo.sh
Last active November 23, 2022 22:37
query, read, encode (using amiitool), write and lock NTAG215 (using uFR Nano hardware) for the purpose of researching Nintendo's Amiibo infrastructure Raw
#!/bin/bash
# This is a companion script to https://github.com/konstantin-kelemen/arduino-amiibo-tools
# The original post this was crafted for was https://games.kel.mn/en/create-amiibo-clones-with-arduino/
# For more info go to https://games.kel.mn/en/companion-script-to-simplify-amiibo-cloning-with-arduino/
#requirements:
#sha1sum (part of coreutils)
#xxd (part of vim)
#hexdump
#amiitool (https://github.com/socram8888/amiitool)
@stereokai
stereokai / index.css
Created June 18, 2017 11:03
Trigonometry in CSS
//----------------------------------*\
// TRIGONOMETRY FUNCTIONS
//----------------------------------*/
// # Trigonometry in CSS
//
// - Through Taylor/Maclaurin polynomial representation: http://people.math.sc.edu/girardi/m142/handouts/10sTaylorPolySeries.pdf
// - Useful if you don't want to use JS.
// - With CSS Variables.
// - `calc()` can't do power (x ^ y) so I used multiplication instead.
const RE_YEAR = re`(?<year>[0-9]{4})`;
const RE_MONTH = re`(?<month>[0-9]{2})`;
const RE_DAY = re`(?<day>[0-9]{2})`;
const RE_DATE = re`${RE_YEAR}-${RE_MONTH}-${RE_DAY}`;
const matchObj = RE_DATE.exec('1999-12-31');
const year = matchObj.groups.year; // 1999
const month = matchObj.groups.month; // 12
const day = matchObj.groups.day; // 31
@dy
dy / saveAs.js
Created March 18, 2017 21:37
Open data-uri in new window
function saveAs(arrayBuffer, fileName, mime) {
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.TEMPORARY, arrayBuffer.byteLength, function(fs) {
fs.root.getFile(fileName, {create: true}, function(fileEntry) {
fileEntry.createWriter(function(writer) {
var dataView = new DataView(arrayBuffer);
var blob = new Blob([dataView], {type: 'font/opentype'});
writer.write(blob);
writer.addEventListener('writeend', function() {
@jherax
jherax / is-private-mode.js
Last active March 19, 2024 18:29
Detect if the browser is running in Private mode - Promise based (last update: Feb 2020)
/**
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise<boolean>}
*
* Live demo:
* @see https://output.jsbin.com/tazuwif
*
* This snippet uses Promises. If you want to run it in old browsers, polyfill it:
* @see https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js
*
@pudgereyem
pudgereyem / _hidden-scrollbar.sass
Created October 13, 2016 12:43
Hidden Scrollbar
/*
* Hidden scrollbar
*/
::-webkit-scrollbar
width: 0px
::-webkit-scrollbar-track-piece
background-color: transparent
-webkit-border-radius: 6px
@tzmartin
tzmartin / embedded-file-viewer.md
Last active April 15, 2024 06:30
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@gund
gund / http-interceptor-concept.md
Last active September 19, 2022 01:08
Concept of Http Interceptor for Angular 2

First, we need to define interfaces with which we will work:

export interface Interceptable<T extends Interceptor<any, any>> {
  addInterceptor(interceptor: T): Interceptable<T>;
  removeInterceptor(interceptor: T): Interceptable<T>;
  clearInterceptors(interceptors?: T[]): Interceptable<T>;
}

export interface Interceptor<T, D> {
@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.
@robertpenner
robertpenner / employee_salaries.ts
Last active June 26, 2020 23:16
Employee Average Salaries | Victor Savkin's Functional TypeScript
// https://vsavkin.com/functional-typescript-316f0e003dc6
class Employee {
constructor(public name: string, public salary: number) {}
}
class Department {
constructor(public employees: Employee[]) {}
works(employee: Employee): boolean {