Skip to content

Instantly share code, notes, and snippets.

View askdaddy's full-sized avatar

Seven Chan askdaddy

  • Internet
View GitHub Profile
@askdaddy
askdaddy / bin.sh
Created November 15, 2021 03:00
list all users crontab
awk -F: '{print $1}' /etc/passwd | xargs -i sudo crontab -u {} -l
@askdaddy
askdaddy / .bash_profile
Created October 18, 2021 07:57
bash profile
#!/bin/bash
#### https://gist.github.com/hernamesbarbara/1937937
export TERM=xterm-color
export CLICOLOR=1
export GREP_OPTIONS='--color=auto'
# export LSCOLORS=Exfxcxdxbxegedabagacad
export LSCOLORS=gxfxcxdxbxegedabagacad # Dark lscolor scheme
# Don't put duplicate lines in your bash history
export HISTCONTROL=ignoredups
@askdaddy
askdaddy / buffer_io.h
Created February 7, 2021 07:18
asio+protobuf
bool writeDelimitedTo(
const google::protobuf::MessageLite& message,
google::protobuf::io::ZeroCopyOutputStream* rawOutput) {
// We create a new coded stream for each message. Don't worry, this is fast.
google::protobuf::io::CodedOutputStream output(rawOutput);
// Write the size.
const int size = message.ByteSize();
output.WriteVarint32(size);
@askdaddy
askdaddy / example.lua
Created January 29, 2021 09:46 — forked from mebens/example.lua
Doubly linked list in Lua
require("list")
local a = { 3 }
local b = { 4 }
local l = list({ 2 }, a, b, { 5 })
l:pop()
l:shift()
l:push({ 6 })
l:unshift({ 7 })
#!/bin/bash
set -e
SSHD_LISTEN_ADDRESS=127.0.0.1
SSHD_PORT=2222
SSHD_FILE=/etc/ssh/sshd_config
SUDOERS_FILE=/etc/sudoers
# 0. update package lists
@askdaddy
askdaddy / loop.worker.ts
Created December 24, 2020 03:49
ts-loop base on setTimeout
export const fps: number = 10;
export const interval = fps > 0 ? 1000 / fps : 1000 / 30;
function _run(current: number, delta: number) {
console.log(`_run at ${current} + delta: ${delta}`);
// TODO do something here.
for(let i=0; i< 499999 ;++i){
let a = new Date().getTime() + i;
}
@askdaddy
askdaddy / READ.md
Created November 17, 2020 09:23
ubuntu18.04 IDEA中文输入问题(IBUS)

===

问题

输入3个汉字后不能继续输入,此时甚至不能切换输入法

解决

  • 修改ibus的快捷键防止冲突
  • Help>Edit Custom VM Options... 添加
@askdaddy
askdaddy / boost.cmake
Created October 15, 2020 04:28
boost cmake
include(ExternalProject)
include(GNUInstallDirs)
set(BOOST_CXXFLAGS "")
if (WIN32)
set(BOOST_BOOTSTRAP_COMMAND bootstrap.bat)
set(BOOST_BUILD_TOOL b2.exe)
set(BOOST_LIBRARY_SUFFIX -vc140-mt-1_63.lib)
else()
set(BOOST_BOOTSTRAP_COMMAND ./bootstrap.sh)
@askdaddy
askdaddy / sending-protobuf-messages-with-boostasio.hpp
Created September 29, 2020 02:58
sending-protobuf-messages-with-boostasio
#include "boost/asio.hpp"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
// https://stackoverflow.com/questions/4810026/sending-protobuf-messages-with-boostasio
using ::boost::asio::ip::udp;
int main() {
PlayerInfo message;
@askdaddy
askdaddy / smc_read.c
Last active September 11, 2020 08:22
Fetch the OSK authentication key
/*
* smc_read.c: Written for Mac OS X 10.5. Compile as follows:
*
* gcc -Wall -o smc_read smc_read.c -framework IOKit
*/
#include <stdio.h>
#include <IOKit/IOKitLib.h>