Skip to content

Instantly share code, notes, and snippets.

@seokju-na
seokju-na / print.ts
Last active June 24, 2022 13:18
react-thermal-printer
const port = new SerialPort('COM1', {
baudRate: 9600
});
const receipt = await renderToBuffer(
<ThermalPrint type="EPSON" width={42} characterSet="KOREA">
<ThermalPrint.Txt size={{ width: 1, height: 1 }}>10,000원</ThermalPrint.Txt>
<ThermalPrint.Txt>결제 완료</ThermalPrint.Txt>
<ThermalPrint.Br />
<ThermalPrint.Line type="single" />

Keybase proof

I hereby claim:

  • I am seokju-na on github.
  • I am seokjume (https://keybase.io/seokjume) on keybase.
  • I have a public key ASD8Q29ezkb6WCiQ4al7t2n4qP51HCDRn-LAUmFFYn1zWwo

To claim this, I am signing this object:

@seokju-na
seokju-na / algebraic_effects.kt
Created July 31, 2020 03:43 — forked from tanmatra/algebraic_effects.kt
Simple "algebraic effects" implementation on Kotlin
/*
* https://overreacted.io/algebraic-effects-for-the-rest-of-us/
*/
private val effectsStack = ThreadLocal<EffectsFrame>()
fun <T> perform(effectKey: Any): T {
var frame = effectsStack.get()
while (frame != null) {
@Suppress("UNCHECKED_CAST")
@seokju-na
seokju-na / adbwifi.sh
Created November 1, 2019 09:31 — forked from toori67/adbwifi.sh
Android adb wifi debug shell script.
#!/bin/bash
adb kill-server
adb start-server
echo "Connect device with usb cable"
adb wait-for-device
ANDROID_IP=`adb shell ifconfig wlan0 | awk '/inet addr/ {gsub("addr:", "", $2); print $2}'`
adb tcpip 5555
adb connect $ANDROID_IP:5555
{
"username": "seokju-na",
"displayName": "Seokju Na",
"email": "seokju.me@gmail.com",
"avatarImageUrl": "...",
"profileUrl": "https://github.com/seokju-na"
}
import 'zone.js/dist/zone';
const loadZone = Zone.current.fork({
name: "seokju zone",
onScheduleTask(parent, current, target, task) {
console.log('Schedule ' + task.source, task);
parent.scheduleTask(target, task);
},
onInvokeTask(parent, current, target, task) {
console.log('Invoking ' + task.source, task);
@seokju-na
seokju-na / lotto.js
Created July 28, 2019 05:54
GDG Campus Korea - Try Flutter 경품 추천 코드
const chalkAnimation = require('chalk-animation');
const { blue, gray, cyan, white, bold } = require('chalk');
const { prompt } = require('node-ask');
const parse = require('csv-parse/lib/sync');
const fs = require('fs');
const { shuffle, sample } = require('lodash');
const center = require('center-align');
const fileData = fs.readFileSync('./codelab.csv', 'utf8');
const candidates = parse(fileData).slice(2);
import Event from './Event';
export type ReducerHandler<E extends Event, State> = (state: State, event: E) => State;
type EventType<E> = E extends Event ? E['type'] : never;
type ExtractEvent<E extends Event, Type> = E extends { type: Type } ? E : never;
export default interface Reducer<E extends Event, State> {
initialState?: State;
ensureFirstEventTypeToBe?: EventType<E>;
const obj = { a: 'b' };
const num = '123';
obj.toString();
num.toString(); // ???
interface Props {
title: string;
durationTime: number;
className?: string;
}
function ScrollDownButton({ durationTime, title, className }: Props) {
const { animate, cancel } = useScrollDownAnimationBehavior();
const handleClick = useCallback(
() => {