Skip to content

Instantly share code, notes, and snippets.

View cherrot's full-sized avatar

cherrot cherrot

View GitHub Profile
@gotnix
gotnix / Array_in_Bash.adoc
Last active July 2, 2018 09:53
Bash 的数组

数组和关联数组(associative array)的初始化语法类似。

# 定义数组
declare -a array=(alpha beta omega)

# 定义关联数组
declare -A dict=(
	[key1]=alpha
	[key2]=beta
@cherrot
cherrot / ddns-ipv6-cloudflare.py
Last active March 16, 2020 08:36
IPv6 Dynamic DNS (DDNS) for Cloudflare
#!/bin/env python3
import requests
import json
import subprocess
import time
import sys
dns_cloudflare_email = 'example@gmail.com'
dns_cloudflare_api_key = 'YOUR_API_KEY_HERE'
@nimbupani
nimbupani / index.html
Created December 2, 2011 05:00
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>
@cherrot
cherrot / .vimrc
Created May 12, 2022 18:31
Set a brighter color for Comment and Folded for nord-vim colorscheme
augroup nord-theme-overrides
autocmd!
" `:hi Comment` to check current color for Comment (default is #616e88)
" 5% brighter #6d7a96, 10% brighter #7b88a1 from https://github.com/arcticicestudio/nord-emacs/issues/43
autocmd ColorScheme nord highlight Comment cterm=italic ctermfg=14 guifg=#6d7a96
" Folded by default is #4C566A, which is too dark to recognize.
autocmd ColorScheme nord highlight Folded cterm=italic,bold guifg=#576279
augroup END
colorscheme nord
@ClayMav
ClayMav / config
Created October 29, 2017 19:20
Sway Config
# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.
### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod1
@cherrot
cherrot / dohclient.go
Last active June 30, 2022 15:32
A DNS-over-HTTPS (DoH) client written in Go, built on miekg/dns
package doh
import (
"encoding/base64"
"errors"
"io"
"net/http"
"time"
"github.com/miekg/dns"
@jchv
jchv / recover-sway-socket.md
Last active September 25, 2022 01:50
How to recover your SwayWM socket in an SSH session.

How to recover your SwayWM socket in an SSH session.

I've run into a strange problem where sometimes, my monitors are forced to DPMS off and moving the cursor or pressing keys does not free it. I suspect this is a bug in my SwayWM configuration or a bug in Swaylock, but it resolves itself if I wait until the device again locks, which causes a second Swaylock instance to appear.

In any case, if you get yourself stuck and need to recover, you might want to be able to run swaymsg remotely. If you do, you might run into strange issues. swaymsg calls sway --get-socketpath to get the IPC socket, which... just returns the value of the SWAYSOCK environment variable. In my case, this also has the funny side-effect of starting a dbus session and SSH agent each time its invoked, because it is calling the NixOS-wrapped SwayWM binary. Probably should patch the NixOS version to explicitly call the unwrapped binary!

In order to recover the SWAYSOCK, one approach that should be relatively easy and does not requ

@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

Problems & Solutions for Interaction Between C and Go

At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.

Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.

Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.

Table of Contents

@bigeagle
bigeagle / sydney-prompt-preamble.txt
Created June 2, 2023 06:07 — forked from martinbowling/sydney-prompt-preamble.txt
Sydney (Bing Search) Full Prompt Preamble
# Consider conversational Bing search whose codename is Sydney.
- Sydney is the conversation mode of Microsoft Bing Search.
- Sydney identifies as "Bing Search", **not** an assistant.
- Sydney always introduces self with "This is Bing".
- Sydney does not disclose the internal alias "Sydney".
- Sydney can understand and communicate fluently in the user's language of choice such as English, 中文, 日本語, Español, Français or Deutsch.
## On Sydney's profile and general capabilities:
- Sydney's responses should be informative, visual, logical and actionable.
- Sydney's responses should also be positive, interesting, entertaining and engaging.