Skip to content

Instantly share code, notes, and snippets.

set -g cmd_cnt 1
if [ $USER -eq root ]
set -g shell_char \#
else
set -g shell_char \$
end
bind \n __prompt_pre_exec
@jeiea
jeiea / rLines.hs
Created February 25, 2017 04:57
Windows CR/LF compatible lines
import ClassyPrelude
-- | Windows CR/LF compatible lines
rLines :: Textual t => t -> [t]
rLines str = res where
(firstLine, rems) = break (\c -> c == '\r' || c == '\n') str
res = case uncons rems of
Nothing -> case uncons firstLine of
Nothing -> []
Just _ -> [firstLine]
@jeiea
jeiea / reclaimWindows10.ps1
Created February 27, 2017 02:04 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
@jeiea
jeiea / reclaimWindows10.ps1
Created February 27, 2017 02:04 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
@jeiea
jeiea / 하스켈을 C만큼 빠르게 만들기 - 엄격함, 느긋함, 재귀 파헤치기.md
Last active February 9, 2018 01:26
Korean translation of 'Write Haskell as fast as C: exploiting strictness, laziness and recursion'

하스켈을 C만큼 빠르게 만들기: 엄격함, 느긋함, 재귀 파헤치기

원본: Write Haskell as fast as C: exploiting strictness, laziness and recursion

역주: 번역 시점에서 10년 된 글... 현재와는 다른 부분이 상당하다.

최근 메일링 리스트에서 Andrew Coppin이 긴 double 실수값 리스트의 평균을 계산하는 "깔끔하고 선언적인" 코드가 성능이 나쁘다고 불평했습니다.

import System.Environment

import Text.Printf

@jeiea
jeiea / echo-server.js
Created March 25, 2018 09:54
node.js echo server
const net = require('net');
let clients = [];
let server = net.createServer(stream => {
stream.setEncoding('utf8');
clients.push(stream);
let idx = clients.indexOf(stream);
console.log(`client ${idx} connected.`);
stream.on('data', data => {
@jeiea
jeiea / WeakCache.cs
Created July 15, 2018 21:04
Not thread safe..
public class WeakCache<T> where T : class {
private Dictionary<object, WeakReference<T>> Index
= new Dictionary<object, WeakReference<T>>();
public bool TryGetValue(object key, out T val) {
if (Index.TryGetValue(key, out WeakReference<T> weak))
if (weak.TryGetTarget(out T target)) {
val = target;
return true;
}
@jeiea
jeiea / FlatDictionary.cs
Last active September 1, 2018 10:35
A utility for importing separate xaml files while previewing it in xaml editor
using System;
using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Markup;
/// <summary>
/// A utility for importing separate xaml files while previewing it in xaml editor.
/// </summary>
// <example>
@jeiea
jeiea / TsvReader.kt
Last active November 3, 2018 20:04
For those who file.readText().lines().map { it.split('\t') } is not sufficient
import java.io.Reader
/**
* Portable tsv reader supporting multiline
* Usage: File("a.tsv").bufferedReader().use { TsvReader(it).readAll() }
*/
class TsvReader(private val reader: Reader) {
private val sb = StringBuilder()
private val eof = (-1).toChar()
@jeiea
jeiea / 10.3-layout.md
Created December 27, 2018 04:45
하스켈 2010 레포트 들여쓰기 규칙을 필요에 의해 번역함

10.3 레이아웃(이하 들여쓰기)

2.7장에서 들여쓰기 규칙을 간단히 설명했습니다. 이번 장에서 더 자세히 정의합니다.

하스켈 프로그램의 의미는 들여쓰기에 따라 달라집니다. 중괄호와 세미콜론을 적절히 추가하는 것으로 들여쓰기의 효과를 완전히 갈음할 수 있습니다. 그렇게 한 프로그램은 들여쓰기할 필요가 없어집니다.

들여쓰기된 프로그램에 어떻게 중괄호와 세미콜론을 추가하는지 설명해서 들여쓰기의 효과를 설명하겠습니다. 들여쓰기 변환 함수 L을 정의하겠습니다. L의 입력은:

  • 아래 토큰이 추가된 하스켈 레포트 어휘 구문에 정의된 어휘소lexeme 스트림:
  • let, where, do, of 키워드 뒤에 {가 없으면 {n} 토큰이 그 키워드 뒤에 들어갑니다. n은 다음 어휘소의 들여쓰기 수준을 의미하고 파일의 끝일 때는 0이 됩니다.