Skip to content

Instantly share code, notes, and snippets.

@CAFxX
CAFxX / golang_minimize_allocations.md
Last active May 22, 2024 00:58
Minimize allocations in Go

📂 Minimize allocations in Go

A collection of tips for when you need to minimize the number of allocations in your Go programs.

Use the go profiler to identify which parts of your program are responsible for most allocations.

⚠️ Never apply these tricks blindly (i.e. without measuring the actual performance benefit/impact). Most of these tricks cause a tradeoff between reducing memory allocations and other aspects (including e.g. higher peak memory usage, higher CPU usage, lower maintainability, higher probability of introducing subtle bugs). Only apply these tricks if the tradeoff in every specfic case is globally positive.

Protobuf

@funyin
funyin / app_expansion_panel.dart
Created June 13, 2022 22:03
A fix for flutters expansion panel list. Removed header icon and gap between selected panels
import 'package:flutter/material.dart';
const double _kPanelHeaderCollapsedHeight = kMinInteractiveDimension;
const EdgeInsets _kPanelHeaderExpandedDefaultPadding = EdgeInsets.symmetric(
vertical: 64.0 - _kPanelHeaderCollapsedHeight,
);
class _SaltedKey<S, V> extends LocalKey {
const _SaltedKey(this.salt, this.value);
@boatbomber
boatbomber / release.luau
Last active May 22, 2024 00:52
Release workflow using Lune
--[[
release.luau - A Lune script for publishing Roblox games
MPL 2.0 License
(c) 2024, Zack Ovits
usage: lune run release
--]]
-- Lune libraries
local stdio = require("@lune/stdio")
@pyrou
pyrou / docker-compose.yml
Last active May 22, 2024 00:48
Use https://traefik.me SSL certificates for local HTTPS without having to touch your /etc/hosts or your certificate CA.
version: '3'
services:
traefik:
restart: unless-stopped
image: traefik:v2.0.2
ports:
- "80:80"
- "443:443"
labels:
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
@madd0
madd0 / kusto-null-bins
Created April 21, 2020 13:45
Add "empty" bins to a kusto query
let Start=startofday(ago(2d));
let Stop=startofday(ago(1d));
requests
| where timestamp >= Start and timestamp < Stop
| summarize Count=count() by bin(timestamp, 1h)
| union (
range x from 1 to 1 step 1
| mv-expand timestamp=range(Start, Stop, 1h) to typeof(datetime)
| extend Count = 0
)
@mignonstyle
mignonstyle / markdown-cheatsheet.md
Last active May 22, 2024 00:44
Markdown記法 チートシート

Block Elements ## Headers 見出し 先頭に#をレベルの数だけ記述します。 ```

見出し1

見出し2

見出し3

見出し4

見出し5
見出し6
## 見出し2
### 見出し3
#### 見出し4
##### 見出し5
###### 見出し6 ## Block 段落 空白行を挟むことで段落となります。 ```
段落1
(空行)
段落2
``` 段落1 段落2 ## Br 改行 改行の前に半角スペース` `を2つ記述します。 ```
hoge
fuga(スペース2つ)
piyo
``` hoge
fuga piyo ## Blockquotes 引用 先頭に`&gt;`を記述します。ネストは`&gt;`を多重に記述します。 ```
&gt; 引用 &gt; 引用
&gt;&gt; 多重引用
``` &gt; 引用 &gt; 引用
&gt;&gt; 多重引用 ## Code コード `` `バッククオート` `` 3つ、あるいはダッシュ`~`3つで囲みます。 ```
print 'hoge'
``` ```
print 'hoge'
``` ### インラインコード `` `バッククオート` `` で単語を囲むとインラインコードになります。 ```
これは `インラインコード`です。
``` これは `インラインコード`です。 ## pre 整形済みテキスト 半角スペース4個もしくはタブで、コードブロックをpre表示できます ``` class Hoge def hoge print 'hoge' end end
``` class Hoge def hoge print 'hoge' end end ## Hr 水平線 アンダースコア`_` 、アスタリスク`*`、ハイフン`-`などを3つ以上連続して記述します。 ```
hoge
***
hoge
___
hoge
---
``` hoge
***
hoge
___
hoge
--- # Lists ## Ul 箇条書きリスト ハイフン`-`、プラス`+`、アスタリスク`*`のいずれかを先頭に記
@ji6czd
ji6czd / radiko.py
Last active May 22, 2024 00:42 — forked from takuya/test.py
Radikoを聴くためのスクリプトです。元々は認証してプレイリストのURLを取得するものを、ちょっとだけ修正と整理をしてコマンドラインから簡単に聴けるようにしてみました。ffmpegの付属ツールffplayが必要です。HLS形式での配信になり、rtmpdump, swftoolsが不要になりました。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import urllib.request, urllib.error, urllib.parse
import os, sys, datetime, argparse, re
import subprocess
import base64
import shlex
import logging
from sys import argv
@Bluscream
Bluscream / obs_twitch_chat.css
Last active May 22, 2024 00:41
Twitch chat transparent popout for OBS
/*
Twitch chat browsersource CSS for OBS
Original by twitch.tv/starvingpoet modified by github.com/Bluscream
Just set the URL as either one of
- https://www.twitch.tv/%%TWITCHCHANNEL%%/chat?popout=true
- https://www.twitch.tv/popout/%%TWITCHCHANNEL%%/chat
- https://www.twitch.tv/embed/%%TWITCHCHANNEL%%/chat?parent=localhost
And paste this entire file into the CSS box or paste direct import css like
@rodneyrehm
rodneyrehm / full-height-column.css
Created November 16, 2016 11:14
CSS: full height column, allowing fixed-height header and footer and scrollable content
/*
<article class="full-height-column">
<header></header>
<section></section>
<footer></footer>
</article>
*/
.full-height-column {
display: flex;