Skip to content

Instantly share code, notes, and snippets.

View lifthrasiir's full-sized avatar

Kang Seonghoon lifthrasiir

View GitHub Profile
// This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@lifthrasiir
lifthrasiir / 20101028.txt
Last active August 29, 2015 14:08
Short Q&A from #rust, mainly collecting my (Yurume's) answers
09:25:37 < duncan> i know i am just doing something stupid, but I am getting a confusing error message trying to implement the Iterator trait: http://is.gd/48ZeJk
09:26:12 < duncan> on the same line, I get 2 opposing errors: "error: wrong number of lifetime parameters: expected 0, found 1" "error: wrong number of type arguments: expected 1, found 0"
09:26:24 < duncan> same line, same column
09:26:42 < Yurume> duncan: Iterator accepts a type parameter, not a lifetime parameter.
09:26:55 < Yurume> maybe you want `impl Iterator<uint> for ...`
13:54:50 < derek_c> I want to iterate through a Vec and remove the first element that satisfies a certain condition. how may I do so?
13:56:16 < Yurume> derek_c: vec.remove(vec.as_slice().iter().position(|&e| ...).unwrap())
14:23:54 < bananasaur> if i don't need custom syntax is there any benefit to a macro over just inlining a function?
@lifthrasiir
lifthrasiir / safe-and-unsafe.md
Created November 6, 2014 04:43
Safe and Unsafe

The terms safe and unsafe are used for many related but slightly differing meanings in Rust.

  1. The provable memory safety: The compiler can prove that the code does not (or, cannot) violate the memory safety. Here the memory safety refers to the absence of access to the non-allocated or invalid pointers and the absence of dangling (allocated-then-never-deallocated) pointers.
  2. The memory safety: The code does not violate the memory safety. The compiler may or may not be able to prove that.
  3. The behaviorial safety: The code does not violate the user's expectation. The exact definition may vary, but this includes the memory safety, no unexpected integer overflows, no unexpected out-of-bounds condition, and so on.

Rust provides the provable memory safety, and allows users to mark the code with non-provable memory safety as unsafe. Rust in general does not provide a strict mechanism to eliminate the behaviorial unsafety, but both the standard library and 3rd-party library writers are *recomm

@lifthrasiir
lifthrasiir / crypto.md
Last active November 14, 2023 07:10
High-level understanding of cryptography

고수준에서 암호학 이해하기

이 글은 메아리 저널에 쓸 목적으로 한동안 작업하던 글입니다. 메아리 특유의 디자인(...)이 싫다면 여기로 링크하셔도 됩니다. 어느 쪽이든간에 의견은 이 아래의 코멘트 란 또는 메아리에 기재되어 있는 메일 주소를 써 주시면 감사하겠습니다. --lifthrasiir

암호학을 사용하는 많은 시스템은 세부적으로 무슨 알고리즘을 쓰는지보다는 그 알고리즘들이 어떻게 연결되어 있는지, 즉 구조가 실제 안전성에 더 큰 영향을 미친다. 따라서 구조와 그 구조를 이루는 빌딩 블럭을 아는 것이 중요한데, 여기에서는 이러한 암호학적 빌딩 블럭과 함께 블럭들이 어떻게 쓰여서 더 큰 구조를 만드는지를 알아 본다.

Key Exchange

키 교환. 두 사람만이 알 수 있는 새로운 키를 만든다. 이 과정이 끝나도 상대방이 내가 아는 사람인진 알 수 없지만 적어도 상대방과 내가 같은 키를 가지고 있다는 건 확신할 수 있다.

@lifthrasiir
lifthrasiir / rustmetadec.py
Last active November 11, 2017 15:58
Rust Metadata Decoder (of sorta)
import sys
import struct
import zlib
import collections
TAGS = {}
TAGS2 = {}
AUTOTAGS = {}
O = TAGS # normal objects
@lifthrasiir
lifthrasiir / code-of-conduct.md
Last active August 29, 2015 14:14
한국 Rust 모임 및 IRC 채널의 행동 규칙 (Code of Conduct)

이 행동 규칙은 Rust 기여자의 행동 규칙/r/rust 서브레딧의 규칙을 토대로, 후자를 한국어로 번역하고 한국어 화자에게 익숙하지 않을 수 있는 부분을 부연한 것입니다. 번역 수정을 포함한 제안은 IRC 채널 등의 공개된 장소에서 해 주세요.

보시면 아시겠지만 이 내용은 "상식적인" 규칙들을 문서화해 놓은 것에 불과합니다. 즉, 이미 상식적으로 행동하고 있다면 규칙에 어긋날 가능성은 크지 않으며, 이 규칙은 "상식"의 범위를 명확히 규정하는 용도라고 생각하면 편할 것입니다. 무엇보다 온라인 상에서 보는 모든 사람은 진짜 사람이라는 것을 생각하면서 행동해 주세요. --lifthrasiir


아래 규칙은 한국 Rust 모임 전체에서, 어떤 권한을 가진 사람이든간에 공통적으로 적용되는 기본 규칙입니다.

  1. 우리는 성별, 성적 지향, 장애 여부, 인종, 종교를 포함한 개인적 특징과 상관 없이 누구에게나 우호적이고, 안전하며 따뜻한 환경을 만들려 하고 있습니다.
  2. 뻔하게 성적이거나 기타 우호적이고, 안전하며 따뜻한 환경을 해칠 수 있는 이름을 피해주세요.
@lifthrasiir
lifthrasiir / formats.md
Last active April 4, 2025 23:53
Comparison of schemaless byte-oriented binary serialization format

What the heck?

  • Schemaless: The format does not have a knowledge about the underlying data at all.
  • Byte-oriented: The format is built upon a byte stream, probably for the ease of implementation and performance.
  • Binary: The format is not targeted for human consumption and specified in terms of "bytes" (which is 8 bits long for our purpose).
  • Serialization: The format is primarily to be used for storage and transmission, not for the in-memory representation.

Contenders

  • S-Expressions (1997), a "canonical" encoding (which is also used for transport)
@lifthrasiir
lifthrasiir / userContent.css
Last active September 11, 2015 14:23
Responsive redesign of /r/rust CSS
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix("https://www.reddit.com/r/rust/"), url-prefix("https://en.reddit.com/r/rust/") {
@media screen and (max-width: 900px) {
body {
display: table;
width: 100%;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABzCAYAAABuMad3AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAJO5JREFUeNrtnXmcnEW197+nqp7umSRAIiCgrIoRCIGQQJCgLyRAMklYxIV7FVAREJSr4Irb9YriggtXUVHZFfcNL0I2dpFNw04Qedm9aECQJZnMdD9PnfP+UU/3dE86yWQSCO+9cz6fTnqeter86tRZqxpGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRGaIRG6KVAsqEbMFQ65137bIy4HoMHn/XLbj31vLs2dJNeEAobugENOufoqeNx7kiJ8WbRYuFxP7ldG+d+cvhrpNfs/aCniep9L2PMm4G/tN1/zLQtgHcCf8fs5++56Kb6hu7TcMht6AYAnHfkFOeEDznVz4hzF2jWdVjr+WerG+0d8+KkWM+95vmEolb70DcPHl9pnP/OUVPHqdlXDc4AzkRk8obu03DpRZOQ7x8zLfP12m7A8nzcpve/99uLrHFOi2J7YjxIESJuS83r/3nmwTv1fuiy+xZ9ceaOG61
@lifthrasiir
lifthrasiir / rules.txt
Created October 29, 2015 05:46
Curls: Canonical URLs
?-utm_*
http://-www.yes24.com/24/goods/*?-*
http://news.naver.com/main/read.nhn?oid&aid&-*
http://news.naver.com/main/ranking/read.nhn>/main/read.nhn?oid&aid&-*
*>https://-www.google.com/?q&-*
*>https://-www.google.com/?+q=$query&-*#q&-*
*>https://^www.google.co.*>/?q&-*
*>https://^www.google.co.*>/?+q=$query&-*#q&-*
http://$id.blogspot.*>$id.blogspot.com
# This is a part of rust-encoding.
# Copyright (c) 2013-2015, Kang Seonghoon.
# See README.md and LICENSE.txt for details.
import urllib
import sys
import os
import os.path
def whatwg_index(name, comments):