Skip to content

Instantly share code, notes, and snippets.

@liuxinyu95
liuxinyu95 / init.lua
Last active June 10, 2022 05:59
Resume Emacs Key bindings for Outlook/Word in OS X
--- Emacs key bindings for Outlook/Word
print("Resume Emacs bindings over outlook/word")
function isKeyStroke(event, modifiers, chars)
return event:getFlags():containExactly(modifiers) and event:getCharacters(true) == chars
end
function targetApp()
local app = hs.application.frontmostApplication()
@dhb52
dhb52 / MacOS-ms-office.lang.md
Last active November 24, 2019 16:39
macOS MS-Office languages settings
  1. add config
defaults write com.microsoft.Word AppleLanguages '("zh-Hans-CN")'
defaults write com.microsoft.Excel AppleLanguages '("zh-Hans-CN")'
defaults write com.microsoft.Powerpoint AppleLanguages '("zh-Hans-CN")'
defaults write com.microsoft.errorreporting AppleLanguages '("zh-Hans-CN")'
defaults write com.microsoft.Outlook AppleLanguages '("zh-Hans-CN")'
defaults write com.microsoft.onenote.mac AppleLanguages '("zh-Hans-CN")'
defaults write com.microsoft.Office365ServiceV2 AppleLanguages '("zh-Hans-CN")'
@tony612
tony612 / multi.go
Last active June 30, 2022 12:38
grpc one connection vs multiple connections (one: 13.8s, multi: 17s)
package main
import (
"log"
"os"
"sync"
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
@marwei
marwei / how_to_reset_kafka_consumer_group_offset.md
Created November 9, 2017 23:39
How to Reset Kafka Consumer Group Offset

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@roblogic
roblogic / istats
Last active December 2, 2021 13:59
istats - bash script to get various statistics from numerical data on stdin
#!/bin/bash
# iStats - get various statistics from numerical data on stdin
# aka "incredibly easy Stats" aka. "Stats for idiots" ;)
# fork of "jstats2" https://gist.github.com/roblogic/da238766f5e645ddfb7290b06b1f80f0
set -e # Exit immediately on error
# set -x # Debug
usage="<input-stream> | istats"
# Create temporary file
WORK=$(mktemp /tmp/$(basename $0).XXXXX) || exit 1
@sergeyklay
sergeyklay / CMakeLists.txt
Last active April 6, 2024 18:52
CMakeLists.txt for PHP-extension. This CMake file is just for syntax highlighting in CLion.
cmake_minimum_required(VERSION 3.5)
project(extname
VERSION 1.0.0
LANGUAGES C)
message(STATUS "Begin cmaking of PHP extension ...")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING
@BretFisher
BretFisher / docker-for-mac.md
Last active May 23, 2024 22:25
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@jdeathe
jdeathe / docker-cron-example.md
Last active December 1, 2022 05:01
How to install/run Cron in a Docker Container

How to install/run Cron in a Docker Container

Example crontab entry for testing

  • Append a timestamp to the log file every minute /var/log/cron.
  • Append "tick" and "tock" in alternate minutes to /var/log/cron.
* * * * * /bin/date --rfc-3339=seconds >> /var/log/cron
*/2 * * * * /bin/echo 'tick' >> /var/log/cron
@willurd
willurd / web-servers.md
Last active June 17, 2024 09:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ralphschindler
ralphschindler / code-complete-stub-generator.php
Last active March 14, 2020 20:52
IDE code-completion stub generation script that utilizes reflection. (Primary use would be for extension stubs.)
<?php
define('T', ' ');
define('N', PHP_EOL);
$functions = array();
$classes = array();
$constant_prefix = 'X_';
$php = '<?php' . N;