Skip to content

Instantly share code, notes, and snippets.

View count0ru's full-sized avatar

Dmitry Nagovitsin count0ru

View GitHub Profile
@count0ru
count0ru / main.go
Created August 9, 2018 12:36
remove duplicates in golang
package main
import (
"fmt"
)
func removeDuplicatesFromSlice(s []string) []string {
m := make(map[string]bool)
for _, item := range s {
if _, ok := m[item]; ok {
@count0ru
count0ru / tmux ssh agent
Created August 7, 2018 11:56
tmux ssh agent
setenv USERID `id -u`
if ($?prompt) then
set sshagentcount = `ps x | grep -c ssh-agent`
if !($sshagentcount > 1 ) then
eval `ssh-agent -s`
else
setenv SSH_AGENT_PID `pgrep -u $USERID ssh-agent`
@ sshagentsocknum = $SSH_AGENT_PID - 1
setenv SSH_AUTH_SOCK `find /tmp -maxdepth 2 -name agent.$sshagentsocknum |& grep -v "Permission denied"`
endif
@count0ru
count0ru / get_meta.sls
Last active June 28, 2018 09:39
saltstuff
#!py
import salt.utils.http
def run():
ret = salt.utils.http.query('http://169.254.169.254/openstack/2012-08-10/meta_data.json', decode=True)
return ret['dict']
/* This jenkins job builds locally and deploys {master}@{booking} to {test-deploy-target} for {bp} project (applying {bp} config)
*/
pipeline {
agent any
options {
timestamps()
ansiColor('xterm')
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-deployer__test-deploy-target', keyFileVariable: 'SSH_KEY_FILE')])
@count0ru
count0ru / .gitconfig
Created January 12, 2018 14:52
pretty git logs
[alias]
lg1 = log --graph --pretty=format:'%C(bold red)%h%Creset -%C(bold yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) %C(bold yellow)%d%C(reset) - %C(white)%s%C(reset) %C(cyan)- %an%C(reset)%C(bold green)(%ar)%C(reset)' --all
lg3 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
- source_labels: [__address__]
regex: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}).*'
target_label: __address__
replacement: 'ip-$1-$2-$3-$4.eu-west-2.compute.internal'
action: replace
@count0ru
count0ru / app-deploy.yaml
Created December 12, 2017 20:09
stekov deployments
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: django-service-boilerplate
spec:
replicas: 1
template:
metadata:
labels:
clickhouse-exporter-discovery:
module.run:
- name: consul.catalog_register
- node: mynode
- address: mynode
- service: clickhouse_exporter
- service_address: {{ salt['network.interfaces']()['ens3']['inet'][0]['address'] }}
- service_port: 9116
- service_id: {{ grains['id'] }}
- consul_url: http://consulhost:8500
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY" [75/167]
set-environment -g 'SSH_AUTH_SOCK' ~/.ssh/ssh_auth_sock
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# set window split
bind-key - split-window -v