Skip to content

Instantly share code, notes, and snippets.

adenosinew

Block or report user

Report or block adenosinew

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adenosinew
adenosinew / fileExistence.go
Created Apr 1, 2020
[os.IsExist and os.IsNotExist] #go #file
View fileExistence.go
/*
Watch out, os.IsExist(err) != !os.IsNotExist(err)
They are error checkers, so use them only when err != nil, and you want to handle
specific errors in a different way!
Their main purpose is to wrap around OS error messages for you, so you don't have to test
for Windows/Unix/Mobile/other OS error messages for "file exists/directory exists" and
"file does not exist/directory does not exist"
@adenosinew
adenosinew / mytimer.timer
Last active Mar 9, 2020
[Set up timer] #linux
View mytimer.timer
[Unit]
Description=Runs mytimer every hour
[Timer]
OnUnitActiveSec=1h
Unit=mytimer.service
[Install]
WantedBy=multi-user.target
@adenosinew
adenosinew / read_json.py
Created Feb 26, 2020
[read and write a json] #python
View read_json.py
# string:
import json
# json.loads(string)
print ( json.loads(open("in.json","r").read() ) )
dictionary:
import json
# json.load(_io)
print( json.load(open("in.json","r")) )
@adenosinew
adenosinew / simple-timing.go
Last active Feb 24, 2020
[Measuring execution time] #golang
View simple-timing.go
package main
import (
"time"
"fmt"
)
func main() {
start := time.Now()
View lsyncd.conf.lua
# https://klionsec.github.io/2017/11/18/lsyncd/
@adenosinew
adenosinew / deployKeys.sh
Created Dec 18, 2019
[Github Management]
View deployKeys.sh
# https://developer.github.com/v3/guides/managing-deploy-keys/
View checkServiceRunning.sh
systemctl is-active --quiet <service> && echo <service> is running
@adenosinew
adenosinew / cpuStressTest.sh
Last active Nov 27, 2019
[Linux benchmarks]
View cpuStressTest.sh
# Installation
sudo apt-get install stress
yum install stress
# Usage
View findLatestCommit.sh
# https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
git for-each-ref --sort=-committerdate refs/heads/
# Or using git branch (since version 2.7.0)
git branch --sort=-committerdate # DESC
git branch --sort=committerdate # ASC
You can’t perform that action at this time.