Skip to content

Instantly share code, notes, and snippets.

Miko mikob

  • Tokyo, Japan
View GitHub Profile
@mikob
mikob / pickOverlapping.ts
Last active Dec 25, 2018
TypeScript pick overlapping properties
View pickOverlapping.ts
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];
View FlipText.vue
<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 Mar 31, 2018
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.
View flatten-amd-modules.js
// ./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 Jun 17, 2020
Bulk download audio pronunciations for Anki from Forvo and/or JapanesePod101. It will automatically update your anki deck with the populated the audio field.
View anki_bulk_download.py
#!/usr/bin/env python3
'''
You will need to adjust CARD_TYPE and possibly DECK_NAME or create your own class that extends
AudioDownloader for other languages.
Make sure to adjust BACKUP_LOC to a directory of your choosing.
You might need to adjust the fields for kana and kanji for Japanese.
'''
import sqlite3
from abc import ABC, abstractmethod
View AWS, ELB, CF and Let's Encrypt
Elastic Load Balancer, CloudFront and Let's Encrypt
View gist:ef4a7d765ce86a324f36
function Messenger() {
}
Messenger.prototype.send = function(parcel) {
console.log("Handle auditing here");
this._send(parcel);
};
function TextMessenger(){
this._send = function(parcel) {
You can’t perform that action at this time.