Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View andboson's full-sized avatar
🌴

Andrii Bosonchenko andboson

🌴
  • Cherkasy, UKR \ Alicante, SP
View GitHub Profile
@andboson
andboson / check_line_infiles.sh
Created January 17, 2023 10:43
Search strings in files in dir
#/bin/sh
# read check.txt with strings to find in files in directory 'data'
while read -r line; do
if grep -q -wi "$line" data/* ; then ; else echo "$line - no"; fi;
done <"check.txt"
@andboson
andboson / docker_stats_graphite.sh
Last active September 10, 2022 14:01
Monitor memory of docker container usage in Graphite
# run graphite
docker run \
--name graphite \
--restart=always \
-p 81:80 \
-p 2003-2004:2003-2004 \
-p 2023-2024:2023-2024 \
-p 8125:8125/udp \
-p 8126:8126 \
graphiteapp/graphite-statsd
@andboson
andboson / assign_error.go
Created January 23, 2021 14:55
assign error by reflection
package main
import (
"errors"
"fmt"
"reflect"
)
type TestStruct struct {
E error
@andboson
andboson / checkvpn.sh
Last active March 20, 2020 12:34
check is any pptp-vpn running
#!/bin/bash
# sudo apt install libnotify-bin
vpn=`ifconfig | grep POINTOPOINT`
if [ -z "$vpn" ]
then
notify-send -t 0 "VPN is down";
fi
@andboson
andboson / .zshrc
Last active August 8, 2019 09:00
GOPATH
export GOPATH=`pwd`
export PATH="$PATH:$GOPATH/bin"
echo -e "\033[0;32m CURRENT GOPATH IS: $GOPATH \e[0m"
alias rp='source ~/.zshrc'
@andboson
andboson / xhprof
Created February 3, 2015 15:38
laravel xhprof snip wget http://pecl.php.net/get/xhprof-0.9.4.tgz tar xvf xhprof-0.9.4.tgz php -S localhost:9999
define("XHPROF_ROOT", '/var/www/xhprof-0.9.4');
App::before(function(){
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
});
App::after(function(){
require_once (XHPROF_ROOT . '/xhprof_lib/utils/xhprof_lib.php');
require_once (XHPROF_ROOT . '/xhprof_lib/utils/xhprof_runs.php');
@andboson
andboson / slack.js
Created March 21, 2017 18:06
toggle Slack channels list
var channels = document.querySelector('.channel_list_header_label');
var list = document.querySelector('#channel-list');
channels.addEventListener('click', function(e){
e.preventDefault();e.stopImmediatePropagation();
if (list.style.height != '20px') {
list.style.height = '20px';list.style.overflowY = 'scroll';
} else {
list.style.height = 'auto';list.style.overflowY = 'auto';
}
@andboson
andboson / postgres.sql
Created March 7, 2017 14:41
insert record with random field
insert into cups(reg_id, code, is_enabled, created_at, updated_at )
select
1 as reg_id,
UPPER(substr(md5(''||now()::text||random()::text), 1,8)) as code,
true as is_enabled,
to_date(now()::text,
'YYYY-MM-DD HH24:MI:SS') as created_at,
to_date(now()::text, 'YYYY-MM-DD HH24:MI:SS') as updated_at
from generate_series(1,4000000) on conflict DO NOTHING;
@andboson
andboson / catch_cmd_output.go
Created December 18, 2016 18:50
catch_cmd_output
package main
import (
"io"
"os"
"log"
"os/exec"
)
func main() {
@andboson
andboson / gist:37726aecbfcee90e370ca4085c6bec5e
Last active December 7, 2016 08:58
go redis expired watch
const REFRESH_EXPIRED_MINUTES = 1
// somewhere (maybe in main.go) run: go WatchExpired(); go RefreshExpired();
func WatchExpired() {
services.RClient.ConfigSet("notify-keyspace-events", "Ex")
pub := services.RClient.PubSub()
pub.PSubscribe("__key*__:*")
debug, _ := conf.AppConfig.Bool("debug")