Skip to content

Instantly share code, notes, and snippets.

View biggora's full-sized avatar
💭
I may be slow to respond.

Aleksejs Gordejevs biggora

💭
I may be slow to respond.
View GitHub Profile
@biggora
biggora / kid.js
Created March 22, 2017 20:21
Signed token for Docker registry
var bluebird = require('bluebird');
var crypto = require('crypto');
var forge = require('node-forge');
var fs = require('fs');
var data = {};
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
function base32encode(value) {
<?php
// config params
$conf = file_get_contents("/path/to/config.json");
// query string params
$qstr = $_GET;
// API params
$apiurl = "https://www.google.com";
@biggora
biggora / get_ip.php
Created May 18, 2016 18:06
Simple method to get user IP address in PHP
<?php
function getUserIP()
{
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
@biggora
biggora / centos_tools.sh
Last active March 26, 2016 20:04
centos
## Remove Old Kernels ##
## Fedora 21/20/19/18/17/16, CentOS, Red Hat (RHEL) ##
yum install yum-utils
## Package-cleanup set count as how many old kernels you want left ##
package-cleanup --oldkernels --count=2
## Add ifconfig ##
yum install net-tools
## Add nginx ##
@biggora
biggora / cent-os.sh
Last active March 6, 2016 20:40
CentOS default
#
sudo yum install net-tools mc wget
sudo yum groupinstall "Development Tools"
sudo yum install kernel-devel
# add the latest nginx
# touch /etc/yum.repos.d/nginx.repo
# [nginx]
# name=nginx repo
# baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
@biggora
biggora / remove-docker-containers.sh
Created February 12, 2016 18:25
How to remove unused Docker containers and images
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q) # or docker ps -q -a | xargs docker rm
# Delete all images
docker rmi $(docker images -q)
# delete all untagged images
docker rmi $(docker images | grep “^<none>” | awk ‘{print $3}’)
@biggora
biggora / remove_crw.cmd
Created February 10, 2016 20:16 — forked from xvitaly/remove_crw.cmd
Remove telemetry updates for Windows 7 and 8.1
echo Uninstalling KB3075249 (telemetry for Win7/8.1)
start /w wusa.exe /uninstall /kb:3075249 /quiet /norestart
echo Uninstalling KB3080149 (telemetry for Win7/8.1)
start /w wusa.exe /uninstall /kb:3080149 /quiet /norestart
echo Uninstalling KB3021917 (telemetry for Win7)
start /w wusa.exe /uninstall /kb:3021917 /quiet /norestart
echo Uninstalling KB3022345 (telemetry)
start /w wusa.exe /uninstall /kb:3022345 /quiet /norestart
echo Uninstalling KB3068708 (telemetry)
start /w wusa.exe /uninstall /kb:3068708 /quiet /norestart
@biggora
biggora / dumps.sh
Last active December 13, 2015 14:52
# Dumping the database structure for all tables with no data
# Dumping the MySQL
mysqldump -d -h localhost -u root -pmypassword databasename > dumpfile.sql
# Dumping the SQlite
sqlite3 databasefile.db .sch > dumpfile.sql
# Dumping the PostgreSQL
pg_dump --schema-only databasename > dumpfile.sql
#!/bin/bash
# NodeJS, NPM, Nginx
sudo apt-get update
sudo apt-get install nodejs-legacy npm nginx-extras -y
# RabbitMQ
sudo echo "deb http://www.rabbitmq.com/debian/ testing main" > /etc/apt/sources.list.d/rabbitmq.list
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc
@biggora
biggora / examples.sh
Created August 7, 2015 08:32
Bash commads
# split string by space
# awk -F " " '{print $7}'
# example: show banned ip
cat /var/log/fail2ban.log | grep Ban | awk -F " " '{print $7}'
# count unique value
# sort | uniq -c | sort -nr
# example: count banned unique ip
cat /var/log/fail2ban.log | grep Ban | awk -F " " '{print $7}' | sort | uniq -c | sort -nr