Skip to content

Instantly share code, notes, and snippets.

Avatar

Chao Guo jeffguorg

View GitHub Profile
@jeffguorg
jeffguorg / inplace
Last active Aug 6, 2021
inplace function in zsh
View inplace
#!/usr/bin/env zsh
inplace() {
COMMAND="$1"
FILEPATH="$2"
set -x
OUTPUT="$(bash -c "${COMMAND} '${FILEPATH}'")"
RET=$?
if [ $RET -eq 0 ]; then
echo -n "$OUTPUT" >! "${FILEPATH}"
@jeffguorg
jeffguorg / CMakeLists.txt
Last active May 28, 2021
CMakeLists.txt for lazybones like me
View CMakeLists.txt
cmake_minimum_required(VERSION 3.3.0)
project(blablabla VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 20)
#include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
#conan_basic_setup()
#include_directories(${CONAN_INCLUDE_DIRS})
#link_directories(${CONAN_LIB_DIRS})
@jeffguorg
jeffguorg / baseX.go
Last active Oct 14, 2022
baseX encoding - 演示用任意字符集合编码数据
View baseX.go
package baseX
import (
"errors"
"math"
)
type Encoder struct {
encodeMap []rune
decodeMap map[rune]int
@jeffguorg
jeffguorg / controller.go
Last active Nov 28, 2020
dbus counter demo
View controller.go
package main
import (
"fmt"
"log"
"os"
"os/signal"
"strings"
"sync"
"syscall"
@jeffguorg
jeffguorg / fancy-index.xslt
Last active Jun 14, 2022
nginx fancy index
View fancy-index.xslt
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>
<html>
<head>
@jeffguorg
jeffguorg / daemon.py
Last active Sep 12, 2018
an asyncio daemon pattern
View daemon.py
import asyncio
import queue
ioloop = asyncio.get_event_loop()
def timer(interval=5):
def wrapper(func):
async def runner(*args, **kwargs):
while True:
asyncio.ensure_future(func(*args, **kwargs))