Skip to content

Instantly share code, notes, and snippets.

View lincerely's full-sized avatar
🕹️

Lincerely lincerely

🕹️
View GitHub Profile
@justinmeiners
justinmeiners / why_is_std_map_a_red_black_tree.md
Last active January 31, 2024 17:54
Why is std::map typically implemented as a red-black tree?

Why is std::map typically implemented as a red-black tree?

Why not a hash table?

A type only requires < operator (comparison) to be used as a key in a tree. However, hash tables require that each key type has a hash function defined. Keeping type requirements to a minimum is very important for generic programming so you can use it with a wide variety of types and algorithms.

Designing a good hash table requires intimate knowledge of the context it which it will be used. Should it use open addressing, or linked chaining? What levels of load should it accept before resizing? Should it use an expensive hash that avoids collisions, or one that is rough and fast?

Since the STL can't anticipate which is the best choice for your application, the default needs to be more flexible. Trees "just work" and scale nicely.

@gvoze32
gvoze32 / ffmpeg GIF to MP4.MD
Last active May 12, 2026 12:51
Convert animated GIF to MP4 using ffmpeg in terminal.

To convert animation GIF to MP4 by ffmpeg, use the following command

ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4

Description

movflags – This option optimizes the structure of the MP4 file so the browser can load it as quickly as possible.

pix_fmt – MP4 videos store pixels in different formats. We include this option to specify a specific format which has maximum compatibility across all browsers.

@ideoforms
ideoforms / sox-cheat-sheet.sh
Last active July 16, 2026 17:25
sox cheat sheet
################################################################################
# sox cheat sheet
################################################################################
# Example commands for the sox command-line audio processing tool,
# for manipulating or batch processing audio files.
################################################################################
# Daniel Jones <dan-web@erase.net>
################################################################################
################################################################################
@joannakl
joannakl / resources_APS.md
Last active December 12, 2025 17:58
Resources for Algorithmic Problem Solving
@datlife
datlife / README.md
Last active February 23, 2025 23:19
Build LLVM / Clang on MacOS

Build LLVM / Clang on MacOS

Problem

Built-in Clang / LLVM shipped by Xcode does not support Leak Santizer (-fsantize=leak) feature. For example, this code has memory leak:

// File: main.c

#include <stdlib.h>
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 13, 2026 23:40
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@jnbdz
jnbdz / firefox_bookmarks.sh
Last active August 23, 2024 08:59
Get FireFox bookmarks with the help of the terminal
#!/usr/bin/env bash
firefoxbookmarks() {
mkdir -p /tmp/bookmark/ && \
cp ~/.mozilla/firefox/0fkse04m.default/places.sqlite /tmp/bookmark && \
sqlite3 -line /tmp/bookmark/places.sqlite 'select moz_places.url, moz_bookmarks.title from moz_bookmarks join moz_places on moz_bookmarks.fk = moz_places.id' && \
rm /tmp/bookmark/places.sqlite
}
@ozgurshn
ozgurshn / NLTokenizer.swift
Created March 10, 2019 19:59
NLTokenizer
import NaturalLanguage
let text = "All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood."
let tokenizer = NLTokenizer(unit: .word)
tokenizer.string = text
//let tokenArray = tokenizer.tokens(for: strRange)
tokenizer.enumerateTokens(in: text.startIndex..<text.endIndex) { tokenRange, _ in
print(text[tokenRange])
return true
@uchcode
uchcode / Create-standalone-Mac-OS-X-applications-with-Python.md
Last active February 5, 2025 15:20
PythonでスタンドアロンのMac OS Xアプリケーションを作成する

PythonでスタンドアロンのMac OS Xアプリケーションを作成する

Pythonのプログラムを配布可能なアプリケーションを作成する方法について扱います。

Pythonプログラムの実行方式

コンピュータが理解できるのは突き詰めると、0と1だけです。そのため、プログラムを実行するには「プログラミング言語で書かれたテキストのプログラム」を0と1に変換する必要があります。そのやり方には2つあり、ひとつはコンパイラを使うもので、もうひとつはインタプリタを使うものです。

以下に両者の違いについて記載します。

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from spell import *
updater = Updater(token="")
dispatcher = updater.dispatcher
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)