Skip to content

Instantly share code, notes, and snippets.

@mikob
mikob / pickOverlapping.ts
Last active June 28, 2023 07:11
TypeScript pick overlapping properties
type Overlap<T, U> = { [K in keyof T & keyof U]: U[K] };
/**
* Return an object with only the properties existing on both objects, values equal to what's on the latter object.
*/
export function pickOverlapping<T, U>(obj1: T, obj2: U): Overlap<T, U> {
const ret: any = {};
for (const k in obj2) {
if (k in obj1) {
ret[k] = obj2[k];
@mikob
mikob / FlipText.vue
Created October 4, 2018 14:35
Flippy text
<template>
<span class="item-cont">
<transition-group name="rolodex">
<span v-for="(item, index) of items" :key="index" v-show="index === i % items.length">{{ item }}</span>
</transition-group>
</span>
</template>
<style scoped>
.item-cont span {
@mikob
mikob / flatten-amd-modules.js
Created March 31, 2018 02:27
When you don't want to use require.js or another module lower but you have a single file with all of your amd modules.
// ./flatten-amd-modules.js [input file path] [output file path]
var fs = require('fs');
var esprima = require('esprima');
var _ = require('lodash');
let inputPath = process.argv[2];
let outputPath = process.argv[3];
const content = fs.readFileSync(inputPath, 'utf8');
var output = [];
var replacements = [];
@mikob
mikob / anki_bulk_download.py
Last active March 31, 2023 19:07
Bulk download audio pronunciations for Anki from Forvo and/or JapanesePod101. It will automatically update your anki deck with the populated the audio field.
#!/usr/bin/env python3
'''
Update 10/4/2021
* Download audio for the longest word in Spanish.
Update 9/22/2020
* Allow looking up through multiple lang codes by priority order on Forvo (eg. es_LATAM, es)
* Strip nbsp; when looking up words on Forvo
Update 9/5/2020
@mikob
mikob / AWS, ELB, CF and Let's Encrypt
Last active June 2, 2024 02:55
AWS, ELB, Let's Encrypt
Elastic Load Balancer, CloudFront and Let's Encrypt
function Messenger() {
}
Messenger.prototype.send = function(parcel) {
console.log("Handle auditing here");
this._send(parcel);
};
function TextMessenger(){
this._send = function(parcel) {