Skip to content

Instantly share code, notes, and snippets.

View daystram's full-sized avatar
🏔️

Danny August Ramaputra daystram

🏔️
View GitHub Profile
@daystram
daystram / lidsleep.sh
Created March 5, 2021 20:15
MacBook toggle sleep on lid close script
#!/bin/bash
set -e
FLAG="$HOME/.lidsleep"
if [[ -f $FLAG ]]; then
sudo pmset -a disablesleep 0
rm $FLAG
echo "lidsleep: enabled sleep on lid close"
else
SLOT_FUEL, SLOT_PRODUCT, SLOT_SEED, SLOT_COVER = 1, 2, 4, 5
FUEL_TRESHOLD = 400
INTERVAL = 180
INIT = true
START_CLK = os.clock()
function move(action, count)
count = count or 1 -- defaults param to 1
local ACT = {
["f"] = turtle.forward,
@daystram
daystram / dd.lua
Last active November 21, 2020 07:56
-- wget https://gist.github.com/daystram/1750d01b262e9fe236288bae036bb215/raw/dd.lua
local prog_name = ...
local gists = {
autotree = "https://gist.github.com/daystram/f9eac6357f2ff245af3fb997019b0daf/raw/autotree.lua",
autofarm = "https://gist.github.com/daystram/4fea7e3036383306d21e42fed8e0edb6/raw/autofarm.lua",
automob = "https://gist.github.com/daystram/d14883a5e5b1e6f8cb6021a04a603375/raw/automob.lua",
master = "https://gist.github.com/daystram/9805a84ee8a10f9d21f104f7a9fe8610/raw/master.lua",
devmaster = "https://gist.github.com/daystram/27aa05e5d8c8ef6349b4ec0755a9ee7f/raw/devmaster.lua",
devslave = "https://gist.github.com/daystram/a52fa122e849e559bc15bb83e36b979f/raw/devslave.lua"
}
SLOT_FUEL, SLOT_SAPLING, SLOT_FERTILIZER, SLOT_LOG = 1, 2, 3, 4
FUEL_TRESHOLD = 400
init = true
START_CLK = os.clock()
function refuel(qty)
turtle.select(SLOT_FUEL)
local fuel = turtle.refuel(qty)
turtle.select(SLOT_LOG)
return fuel
up:
@docker-compose pull
@docker-compose up -d
down:
@docker-compose down
pull:
@docker-compose pull
which ssh-agent || ( apk add --update openssh )
eval $(ssh-agent -s)
echo "[init] agent started"
echo "$DEPLOY_KEY" | ssh-add - || true
echo "init] key added"
mkdir -p ~/.ssh
echo "[init] .ssh dir created"
chmod 700 ~/.ssh
echo "[init] dir chmod"
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
export GOPATH=${CI_PROJECT_DIR}/go
mkdir -p ${GOPATH}/src/${GOPROJECT}
mv * ${GOPATH}/src/${GOPROJECT} > /dev/null || true
cd ${GOPATH}/src/${GOPROJECT}
import redis
import time
count = 5000
r = redis.Redis(host='localhost', port=6379, db=0)
line = '{\
"OrderID":"%d",\
"LastTime":"2019-11-14T20:06:48.0202697+07:00",\
import time
import gevent
from websocket import create_connection
from locust import HttpLocust, TaskSet, task
from locust.events import request_success
class UserTaskSet(TaskSet):
@task(1)
// initialization
redisHost := conf.AppConfig.RedisHost
redisConn := &redis.Pool{
Dial: func() (redis.Conn, error) {
return redis.Dial("tcp", redisHost)
},
MaxIdle: 5,
IdleTimeout: 0,
MaxConnLifetime: 0,
}