Skip to content

Instantly share code, notes, and snippets.

View aliceklipper's full-sized avatar

Alice Klipper aliceklipper

View GitHub Profile
@aliceklipper
aliceklipper / booleans.js
Last active December 30, 2017 22:58
Typelevel stuff in Flow
// Basic typelevel boolean functions.
type If<A: boolean, Then, Else = empty> = $Call<typeof If_, A, Then, Else>;
declare function If_<Then, Else>(true, Then, Else): Then;
declare function If_<Then, Else>(false, Then, Else): Else;
type Not<A: boolean> = If<A, false, true>;
type And<A: boolean, B: boolean> = If<A, B, false>;
type Or<A: boolean, B: boolean> = If<A, true, B>;
@aliceklipper
aliceklipper / encode-gif
Last active July 30, 2017 12:08
Encode GIFs using mpv's A-B loop and ffmpeg.
#!/usr/bin/zsh
start="$1"
end="$2"
input="$3"
outdir="/home/aliceklipper/Pictures/Screenshots/MpvGifs/"
basename="${input##*/}"
@aliceklipper
aliceklipper / xre-shashes.xml
Created June 11, 2017 12:33
xre regular expressions highlighting for IntelliJ IDEA
<LanguageInjectionConfiguration>
<injection language="RegExp" injector-id="js">
<display-name>xre-slashes</display-name>
<value-pattern>^/(.*)/.*$</value-pattern>
<place><![CDATA[jsLiteralExpression().withParent(psiElement().withText(string().startsWith("xre")))]]></place>
</injection>
</LanguageInjectionConfiguration>
@aliceklipper
aliceklipper / README.md
Last active May 31, 2017 23:28
Оформление постов

Как постить

При постинге скринов постить подряд только один тайтл, перед первым скрином с каким-то тайтлом обязательно размещать пост по шаблону чуть ниже.

Чатик из канала лучше не устраивать, но если есть что сказать по делу (и хоть как-то полезное/интересное читателям) — всегда пожалуйста.

Главное, без фанатизма.

Шаблон

@aliceklipper
aliceklipper / sasai-kudasai.js
Created April 12, 2017 12:06
Here at lines 26 and 27 are type errors.
// @flow
function MSasaiable (constructor) {
return class extends constructor {
sasai (string : string) {
return `Sasai ${string}!`;
}
};
}
./fuck.js:3:1,5:3: [type: {|ha: string|}]
./fuck.js:7:10-16: (base: This) => This
./fuck.js:7:19-22: This
./fuck.js:8:12,12:5: This
./fuck.js:8:26-29: This
./fuck.js:9:22-49: {|ha: string|}
./fuck.js:10:13-19: {+_exception: (...data: Array<any>) => void, +assert: (condition: mixed, ...data: Array<any>) => void, +clear: () => void, +count: (label: string) => void, +debug: (...data: Array<any>) => void, +dir: (...data: Array<any>) => void, +dirxml: (...data: Array<any>) => void, +error: (...data: Array<any>) => void, +group: (...data: Array<any>) => void, +groupCollapsed: (...data: Array<any>) => void, +groupEnd: () => void, +info: (...data: Array<any>) => void, +log: (...data: Array<any>) => void, +profile: (name: string) => void, +profileEnd: () => void, +table: (tabularData: {[key: string]: any,} | Array<{[key: string]: any,}> | Array<Array<any>>) => void, +time: (label: string) => void, +timeEnd: (label: string) => void, +timeStamp: (label?: string) => void, +trace: (...data: Array<any>) => void, +warn: (..
@aliceklipper
aliceklipper / webpack.config.js
Last active November 30, 2019 16:16
Simplest config for just TS building
const { join } = require('path');
const webpack = require('webpack');
const DefinePlugin = webpack.DefinePlugin;
module.exports = {
target : 'web',
entry : './src/index.tsx',
output : {
chunkFilename : '[id].index.js',
filename : 'index.js',
@aliceklipper
aliceklipper / Localizable.tsx
Created April 1, 2017 14:12
Abstract class for creating localizable React components (TS & MobX)
import * as React from 'react';
import { LocalizableStore } from './LocalizableStore';
export interface LocalizableProps {
l10n : LocalizableStore;
}
export abstract class Localizable<PropsType extends LocalizableProps, StateType> extends React.Component<PropsType, StateType> {
tl : (string : string) => string;
__ : (strings : TemplateStringsArray, ...props : any[]) => string;
@aliceklipper
aliceklipper / array-and-pure.kawaii
Last active February 25, 2017 15:22
Arrays and pure functions
from fs import readFile as read
from console import print
async main () : I32
let raw = (await read('array.txt')).toString()
let split = raw.split('\n')
let mapper = pure (line, number) # `line`'s type inferred as `String`
'Line #`number + 1`: `line`'
#
No `return` keyword
@aliceklipper
aliceklipper / io.kawaii
Last active February 25, 2017 14:52
Read text from file
from fs import readFile as read
from console import print
async main () : I32
let file = await read('hello.txt') # `file`'s type inferred as Buffer
print('File contents: `file`') # `file` converted to string using implicit `toString()` method invocation