Skip to content

Instantly share code, notes, and snippets.

View gyk's full-sized avatar

Yukun Guo gyk

  • Hangzhou, China
  • 19:01 (UTC +08:00)
View GitHub Profile
@kizzx2
kizzx2 / with-env.ps1
Last active February 26, 2025 21:11
Run command with environment variables in PowerShell
$ori = @{}
Try {
$i = 0
# Loading .env files
if(Test-Path $args[0]) {
foreach($line in (Get-Content $args[0])) {
if($line -Match '^\s*$' -Or $line -Match '^#') {
continue
}
@mbinna
mbinna / effective_modern_cmake.md
Last active April 25, 2025 22:01
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@jchandra74
jchandra74 / PowerShell Customization.md
Last active January 8, 2025 09:35
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

@iffy
iffy / .gitignore
Last active January 8, 2025 06:32
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
This file has been truncated, but you can view the full file.
/*
* Command line: opannotate --source
*
* Interpretation of command line:
* Output annotated source file with samples
* Output all files
*
* CPU: Intel Ivy Bridge microarchitecture, speed 3.3e+06 MHz (estimated)
* Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (No unit mask) count 100000
*/
@jdh30
jdh30 / MicroKanren.fs
Created February 18, 2017 15:26
MicroKanren ported from Scheme to F#
type Term =
| Var of int
| Pair of Term * Term
| Int of int
let (|Find|_|) s k = Map.tryFind k s
let rec walk (s: Map<_,_>) = function
| Var(Find s t) -> walk s t
| t -> t
@zakirt
zakirt / animated-gif-detect.js
Last active January 12, 2025 22:31
Detecting if GIF file is animated using JavaScript
/**
* @author Zakir Tariverdiev
* @class animatedGifDetect
* @description
* GIF file reader that checks whether GIF image is animated, or not.
* Uses information gathered from the website below:
* http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
*/
(function(window, undefined) {
'use strict';
@sile
sile / time-clocks.md
Last active October 5, 2024 06:13
『Time, Clocks, and the Ordering of Events in a Distributed System』の要約

Time, Clocks, and the Ordering of Events in a Distributed System

http://research.microsoft.com/en-us/um/people/lamport/pubs/time-clocks.pdf の要約。

著者はレスリー・ランポート (Leslie Lamport), 1978年。

分散アルゴリズムの書籍や論文でお馴染みの、分散システムにおけるイベント群の順序や時刻の概念を説明している論文。

! が先頭についている箇所は、要約者による(いい加減な)注釈。

@cddr
cddr / kafka-data
Last active September 21, 2016 09:59
#!/bin/bash
#
# Here's the scenario
#
# You can ssh into some shared environment containing kafka but you need to
# go through a bastion server to get there. How can you easily stream kafka
# data into your local system (e.g. to get test data, gather data from shared
# environments to reproduce a bug etc)
#
# This script can be executed on the bastion. It picks a random mesosslave to