Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Seven askdaddy

🎯
Focusing
View GitHub Profile
@askdaddy
askdaddy / bin.sh
Created Nov 15, 2021
list all users crontab
View bin.sh
awk -F: '{print $1}' /etc/passwd | xargs -i sudo crontab -u {} -l
View .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
View buffer_io.h
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 Jan 29, 2021 — forked from mebens/example.lua
Doubly linked list in Lua
View example.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 })
View ubuntu-setup-env.sh
#!/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 Dec 24, 2020
ts-loop base on setTimeout
View loop.worker.ts
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 Nov 17, 2020
ubuntu18.04 IDEA中文输入问题(IBUS)
View READ.md

===

问题

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

解决

  • 修改ibus的快捷键防止冲突
  • Help>Edit Custom VM Options... 添加
View 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 Sep 29, 2020
sending-protobuf-messages-with-boostasio
View sending-protobuf-messages-with-boostasio.hpp
#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 Sep 11, 2020
Fetch the OSK authentication key
View smc_read.c
/*
* 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>