Skip to content

Instantly share code, notes, and snippets.

View linktohack's full-sized avatar

Quang-Linh LE linktohack

View GitHub Profile
@linktohack
linktohack / .laxtexmkrc
Created September 11, 2017 08:22
.laxtexmkrc
$pdf_mode = 1;
$pdflatex = "pdflatex -shell-escape -synctex=1";
# $pdflatex = "xelatex -shell-escape -synctex=1";
$pdf_previewer = "open -a Skim";
@linktohack
linktohack / epilogue.d.ts
Last active September 25, 2017 17:24
Epilogue type
declare module 'epilogue' {
import { Express, Request, Response } from 'express';
import { Instance, Sequelize } from 'sequelize';
function initialize(options: InitializeOptions): Epilogue;
function resource(options: ResourceOptions): Resource;
interface Epilogue {
}
@linktohack
linktohack / withoutNull.js
Last active November 29, 2017 10:07
Without null
function withoutNull(object) {
object = _.omitBy(object, _.isNull);
_.forEach(object, function (val, key) {
if (_.isObject(object[key])) {
object[key] = withoutNull(val)
}
if (_.isArray(val)) {
object[key] = _.map(val, withoutNull)
@linktohack
linktohack / Base.bs.js
Last active June 29, 2018 09:30
ReasonML inheritance interop
// Generated by BUCKLESCRIPT VERSION 3.1.5, PLEASE EDIT WITH CARE
'use strict';
class BaseModel {
static findById() {
return new this();
}
@linktohack
linktohack / rec.ml
Created July 4, 2018 14:29
REASONML Two modules
module Sig =
struct
module type NoteSig = sig type t end
module type TodoSig = sig type t end
end
module Same =
struct
module rec Note:Sig.NoteSig = struct type t = {
todo: Todo.t;} end
and Todo:Sig.TodoSig = struct type t = {
@linktohack
linktohack / Makefile
Last active July 11, 2018 09:15
Swagger codegen for loopback + Swift
codegen:
java -jar swagger-codegen-cli-2.3.1.jar generate -l swift4 -i def.yaml -o ~/Downloads/Hello/Hello/Api -DresponseAs=RxSwift
cd ~/Downloads/Hello/Hello && \
sed -i~ 's/: Any\?/: String?/g' Api/SwaggerClient/Classes/Swaggers/Models/*.swift && \
sed -i~ 's/Any\.self/String.self/g' Api/SwaggerClient/Classes/Swaggers/Models/*.swift && \
sed -i~ 's/XString/XAny/g' Api/SwaggerClient/Classes/Swaggers/Models/*.swift && \
sed -i~ 's/RequestBuilder<Any>/RequestBuilder<String>/g' Api/SwaggerClient/Classes/Swaggers/APIs/*.swift && \
if [ -f api.patch ]; then patch -p2 -R < api.patch; fi
@linktohack
linktohack / index.html
Created July 24, 2018 12:29
two cameras
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
async function series<T>(promises: (() => Promise<T>)[],): Promise<T[]> {
const results: T[] = [];
async function seriesInner(promises: (() => Promise<T>)[]): Promise<T[]> {
if (promises.length > 0) {
const p = promises.shift();
const result = await p();
results.push(result);
return seriesInner(promises);
} else {
return results;
@linktohack
linktohack / Program.fsx
Created May 14, 2019 12:08
Fable (2.2+) interop
module Program
open System.Text.RegularExpressions
open Fable.Core
open Fable.Core.JS
open Fable.Core.JsInterop
module Process =
type IEnv =
abstract PORT: string option
@linktohack
linktohack / app.ts
Last active May 15, 2019 20:57
(Somewhat) Elm in TypeScript
// FRAMEWORK
type Html<Msg> =
| {
el: string;
attrs: { [key: string]: string };
events: { [key: string]: (event: Event) => Msg };
children: Html<Msg>[];
}
| { text: string };