Skip to content

Instantly share code, notes, and snippets.

@serjKim
serjKim / concat.md
Last active June 17, 2018 20:12
T-SQL: Fast concat table rows
create table #rows (id uniqueidentifier, value varchar(10))

insert into #rows
values	('11111111-1111-1111-1111-111111111111', 'a'),
	('22222222-2222-2222-2222-222222222222', 'b'),
	('11111111-1111-1111-1111-111111111111', 'c'),
	('22222222-2222-2222-2222-222222222222', 'd'),
	('11111111-1111-1111-1111-111111111111', 'e'),
	('33333333-3333-3333-3333-333333333333', 'f'),
@serjKim
serjKim / typescript-reflect-metadata.ts
Created September 1, 2017 13:36
reflect-metadata
import 'reflect-metadata';
type MyDecObj = {a: number};
const myDecKey = Symbol('design:myDec')
function MyDec(obj: MyDecObj) {
return Reflect.metadata(myDecKey, obj);
}
@serjKim
serjKim / gist:7f453992211637731d2f4d762c60f7a5
Last active July 6, 2022 21:43
integrate expo to the existing project
  1. add app.json, set the newest sdkVersion
{
  "name": "<yourname>",
  "displayName": "<yourname>",
  "expo": {
    "sdkVersion": "25.0.0"
  }
}
private ref: Ref<ScrollView & Component<ScrollViewProps>> = (instance) => {
this.scrollView = instance;
}
@serjKim
serjKim / functor_applicative_monad.md
Last active April 14, 2020 12:20
F#: Functor, Applicative, Monad
type F<'a> = F of 'a

module Functor =
    // Def
    // map : f:('a -> 'b) -> F<'a> -> F<'b>
    let map f (F x) = F (f x)

    let x = F 123
   
@serjKim
serjKim / apply_bind_kleisli.fs
Created June 11, 2019 14:32
apply vs bind vs keilsli
open System
type EmployeeEmail =
| Email of string
| Invalid of string list
let bind f x =
match x with
| Email x -> f x
| Invalid m -> Invalid m
CREATE TABLE #MyLocks
(
	hash VARCHAR(50),
	age int,
)

ALTER TABLE #MyLocks
ADD UNIQUE (hash)
 
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Webpack",
@echo Deleting old branches...
git branch --merged develop | grep -v 'develop$' | xargs git branch -d
@serjKim
serjKim / srtp.fs
Last active February 16, 2020 13:27
F#: SRTP + AP
let inline (|HasLength|) x =
fun () -> (^a: (member Length: int) fst x)
let inline (|HasMethod|) x =
fun () -> (^a: (member Method: int with get) snd x)
let inline length (HasLength f1 & HasMethod f2) =
let a = f1()
let b = f2()
a + b