Skip to content

Instantly share code, notes, and snippets.

@banyek
banyek / vimrc.vim
Last active November 4, 2020 12:20
"
" Do not forget to create ~/.vim directory
"
set nocompatible " behave VIM not VI
set number " Line numbering
autocmd BufWritePre *.pp :%s/\s\+$//e " White spaces
autocmd BufNewFile,BufRead *.pp set filetype=ruby " ruby syntax highlight for puppet
autocmd BufNewFile,BufRead *.cf set filetype=yaml " yaml syntax highlight for cloudformation
autocmd BufNewFile,BufRead *.toml set filetype=dosini " ini syntax highlith for rust's toml files
DELIMITER $$
DROP PROCEDURE IF EXISTS duplicate_rows$$
CREATE PROCEDURE duplicate_rows (IN tablename VARCHAR(255), IN times INT)
BEGIN
SET @statement = CONCAT(CONCAT(CONCAT(CONCAT("INSERT INTO ",tablename)," SELECT * FROM "),tablename),";");
PREPARE stmt FROM @statement;
WHILE times > 0 DO
SELECT times as "Remaining";
EXECUTE stmt;
SET times = times - 1;
#!/usr/bin/env python
from logentries import LogentriesHandler
import pymysql
import os
import logging
from ManageCluster import ManageAuroraCluster as mc
@banyek
banyek / homerseklet.c
Created December 8, 2017 22:36
Reads City - Temp pairs from file, sorts, and write out
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define MAX_TEMP 100
#define NAME_LEN 128
struct city_data{
char name[128];
int temp;
@banyek
banyek / vector.py
Last active December 2, 2017 22:37
#!/usr/bin/env python
def scalar(a, b):
acc = 0
for num in range(len(a)):
acc += a[num] * b[num]
return acc
def vectorial(a, b):
c = [None] * 3
@banyek
banyek / vector.c
Last active December 2, 2017 22:38
vektor.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int scalar(int *v1, int *v2, int len){ // parameterek: a ket osszeszorzando vektorra mutato pointerek,
// es a ket vektor dimenzioszama
int acc = 0; // az akkumulatorba 0-t teszunk
for(int i=0; i < len; i++) { // ezzel a ciklussal vegiglepkedunk a vektorokon
acc += v1[i] * v2[i]; // az akkumulator ertekehez hozzaadjuk a ket tomb i-edik elemeinek a szorzatat
}
@banyek
banyek / hashpw.py
Created November 29, 2017 20:09
To replace pw to pw hashes in an ansible playbook
#!/usr/bin/env python
"""
This script replaces plain text passwords with sha512 encrypted passwords in
ansbile playbooks - when a lot of users created at once.
There are few known limitations:
- When a line contains the string begins with 'password:' the script will replace the rest
of the line with the hash
- A plain text password shouldn't contain '
- If a password already hashed, the hash will be treated as plain text
@banyek
banyek / gist:a1a7073d85324fe829a313c6459a426e
Created April 26, 2016 20:15
look into mysql queries
tcpdump -i ens2f1 -s 0 -l -w - dst port 3306 | strings
openssl genrsa -out bodhisattva.key 2048
openssl req -new -x509 -key bodhisattva.key -out bodhisattva.cert -days 3650 -subj /CN=bodhisattva
all: build
deps:
GOPATH=$(shell pwd) go get github.com/go-sql-driver/mysql
GOPATH=$(shell pwd) go get github.com/koding/logging
GOPATH=$(shell pwd) go get gopkg.in/ini.v1
build: deps
GOPATH=$(shell pwd) go build -v -x binlogstreamer.go
linux: deps
GOPATH=$(shell pwd) GOOS=linux go build -v -x binlogstreamer.go
darwin: deps