Skip to content

Instantly share code, notes, and snippets.

View crosstyan's full-sized avatar

Crosstyan crosstyan

View GitHub Profile
@quan-nh
quan-nh / [clj].lexical-dynamic-scope.md
Last active April 12, 2022 10:21
Understanding the difference between lexical and dynamic scope in Clojure.

concept

  • lexical scope (static scope): dependent only on the program text.
  • dynamic scope: dependent on the runtime call stack.

clojure

  • (def x 1) default Var is static, using let for local Var, with-redefs to change the root binding var within its scope (visible in all threads).
  • (def ^:dynamic x 1) dynamic Var, using binding to change value (thread-local, cannot be seen by any other thread).

In example bellow:

  • binding only changes the value of *dynamic-var* within the scope of the binding expression
@csukuangfj
csukuangfj / default-linker-script.txt
Last active June 10, 2025 03:43
This file shows the default linker script of `ld`, use `ld --verbose` to show it.
GNU ld (GNU Binutils for Ubuntu) 2.25.1
Supported emulations:
elf_x86_64
elf32_x86_64
elf_i386
i386linux
elf_l1om
elf_k1om
i386pep
i386pe
@wilon
wilon / vim-surround使用指南.MD
Last active March 11, 2025 04:30
vim-surround使用指南,vim-surround如何使用

普通模式

命令 说明 + 示例
ds 删除括号
ds " "Hello world!" =>
Hello world!
cs 替换括号
cs "( "Hello world!" =>
(Hello world!)
cS 替换括号,括号内文本做新一行
cS "{ "Hello world!" => {     Hello world! }
@taogashi
taogashi / How-to-use-cmake-externalproject.md
Created December 29, 2016 12:44
正确地使用ExternalProject_Add添加外部项目到本地cmake项目

官方文档
其中PREFIX决定了所有缺省的路径

TMP_DIR      = <prefix>/tmp
STAMP_DIR    = <prefix>/src/<name>-stamp
DOWNLOAD_DIR = <prefix>/src
SOURCE_DIR   = <prefix>/src/<name>
BINARY_DIR   = <prefix>/src/<name>-build
INSTALL_DIR  = <prefix>
@itod
itod / split_keyboards.md
Last active June 18, 2025 03:13
Every "split" mechanical keyboard currently being sold that I know of
@BrianWill
BrianWill / Javascript - asynchronous code.md
Last active April 26, 2024 08:11
Using asynchronous API's using callbacks and Promises

In most programming languages, most functions are synchronous: a call to the function does all of its business in the same thread of execution. For functions meant to retrieve data, this means the data can be returned by calls to the function.

For an asynchronous function, a call to the function triggers business in some other thread, and that business (usually) does not complete until after the call returns. An asynchronous function that retrieves data via another thread cannot directly return the data to the caller because the data is not necessarily ready by the time the function returns.

In a sense, asynchronous functions are infectious: if a function foo calls an asynchronous function to conclude its business, then foo itself is asynchronous. Once you rely upon an asynchronous function to do your work, you cannot somehow remove the asynchronicity.

callbacks

When the business initiated by an asynchronous function completes, we may want to run some code in response, so the code run

@cobalamin
cobalamin / HaskellVsElm.md
Last active April 2, 2022 09:19
Elm (0.17) syntax and functionality differences for Haskell programmers
  • Types are declared with : and not ::, and the consing operator conversely is :: instead of :
  • No where clauses, only let/in
  • The standard style is different, check http://elm-lang.org/docs/style-guide for reference
  • Multiline strings are a thing with """
  • Haskell's data corresponds to type in Elm, and also, Haskell's type corresponds to Elm's type alias
  • ($) is (<|), but you don't use it all that much – Elm people like the flipped operator (|>) which lets you build something that reads like a pipeline
  • Related: Backticks will likely die soon in favour of functions that have an argument order that lends itself to pipelining with (|>)
  • Also, (.) is (<<), and a flipped version (>>) exists, but I don't see it used that much either
  • (&gt;&gt;=) is not an available operator and would not be polymorphic (no typeclasses, see below), and is instead commonly named SomeType.andThen – e.g. Maybe.andThen : Maybe a -&gt; (a -&gt; Maybe b) -&gt; Maybe b
@nebgnahz
nebgnahz / gstreamer.md
Last active January 9, 2025 13:12
Collections of GStreamer usages

Most GStreamer examples found online are either for Linux or for gstreamer 0.10.

This particular release note seems to have covered important changes, such as:

  • ffmpegcolorspace => videoconvert
  • ffmpeg => libav

Applying -v will print out useful information. And most importantly the negotiation results.

@daredude
daredude / docker-clear.bat
Created June 5, 2016 10:53
delete all docker container and images on windows
@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
FOR /f "tokens=*" %%i IN ('docker images --format "{{.ID}}"') DO docker rmi %%i
@a5ync
a5ync / InstallNodeAppAsWindowsService.ps1
Created April 20, 2016 01:04
Powershell wrapper over NSSM (Non-Sucking Service Manager), to install Node app as a Windows-Service
#please read the NSSM https://nssm.cc/usage
Function Install-Service {
param(
[Parameter(Mandatory=$true)][string]$NSSMPath,
[Parameter(Mandatory=$true)][string]$serviceName ,
[Parameter(Mandatory=$true)][string]$serviceExecutable ,
[Parameter(Mandatory=$false)][string]$serviceExecutableArgs ,
[Parameter(Mandatory=$false)][string]$serviceAppDirectory ,
[Parameter(Mandatory=$true)][string]$serviceErrorLogFile ,
[Parameter(Mandatory=$true)][string]$serviceOutputLogFile ,