Skip to content

Instantly share code, notes, and snippets.

Артёмов Антон greenpeas

Block or report user

Report or block greenpeas

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
@greenpeas
greenpeas / postgresql_process.sql
Created Oct 25, 2018
postgresql process list
View postgresql_process.sql
SELECT a.usename, a.pid, a.application_name, a.backend_start, (NOW()::timestamp - a.backend_start::timestamp) as dif, a.state, a.query
from pg_stat_activity a
@greenpeas
greenpeas / add_route.bat
Last active Aug 8, 2018
Add route for host
View add_route.bat
@echo off
setlocal EnableDelayedExpansion
set myServer=google.ru
for /f "tokens=1,2 delims=[]" %%a IN ('ping -n 1 -w 0 !myServer!') DO (
if "%%b" NEQ "" set ip=%%b
)
rem echo %myServer% ip is %ip%
route delete %ip% MASK 255.255.255.255 192.168.137.1
route add %ip% MASK 255.255.255.255 192.168.137.1
@greenpeas
greenpeas / docker_help.txt
Last active Apr 25, 2018
Вспомогашка по командам докера
View docker_help.txt
Остановить все контейнеры
docker stop $(docker ps -a -q)
Рестарт всех контейнеров
docker restart $(docker ps -q)
Удалить все контейнеры
docker rm $(docker ps -a -q)
Удалить все неиспользуемые образы
@greenpeas
greenpeas / randomp3.php
Last active Apr 23, 2018
Mp3 music randomizer
View randomp3.php
<?php
$dir = './';
$files = scandir($dir);
$list = [];
for ($i = 2; $i < count($files); $i++) {
$ext = substr($files[$i], -3, 3);
if ($ext != 'mp3') {
continue;
}
$newName = md5(uniqid()) . '.' . $ext;
View Docker. Add new project
#!/bin/bash
ROOTPASS='myPasswordDb'
echo "Укажите имя приложения:"
read USERNAME
echo "Укажите домен:"
read DOMAIN
@greenpeas
greenpeas / ip2cidr.php
Last active May 12, 2017
PHP Russia ip ranges parser ripe.db.inetnum to ipset restore file
View ip2cidr.php
<?php
$handle = @fopen("ip.ru.ranges.txt", "r");
$fullNetworks = [];
$fullNetworks[] = "104.192.136.0/21"; // ATLASSIAN PTY LTD
$fullNetworks[] = "69.162.124.226/28"; // uptimerobot.com
$fullNetworks[] = "63.143.42.242/28"; // uptimerobot.com
$fullNetworks[] = "66.249.64.0/19"; // Googlebot
$fullNetworks[] = "66.102.0.0/20"; // Google Inc
@greenpeas
greenpeas / pgsoultgen
Created Jan 13, 2015
Генератор пароля и соли
View pgsoultgen
<?php
// Генерируем соль
$salt = '$2a$10$'.substr(str_replace('+', '.', base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(),mt_rand()))), 0, 22) . '$';
// Шифруем пароль с применением данной соли
$hashed_password = crypt($password, $salt);
View fos_chunk
[[!FormIt?
&hooks=`groupSelector,recaptcha,spam,email,redirect`
&emailTpl=`sentEmailTpl`
&emailSubject=`Сообщение с stav-chip.ru`
&emailTo=`[[+emailAddresses]]`
&emailFrom=`[[+contact_email]]`
&emailSubject = `Сообщение с сайта stav-chip.ru`
&emailFromName = `СтавЧип`
&validate=`contact_name:required,
contact_email:email:required,
View my_iptables_config
# Generated by iptables-save v1.3.5 on Wed Jan 23 15:43:00 2013
*nat
:PREROUTING ACCEPT [39:5343]
:POSTROUTING ACCEPT [2:120]
:OUTPUT ACCEPT [3:196]
-A POSTROUTING -o venet0 -j MASQUERADE
COMMIT
# Completed on Wed Jan 23 15:43:00 2013
# Generated by iptables-save v1.3.5 on Wed Jan 23 15:43:00 2013
*filter
@greenpeas
greenpeas / mssql in php
Created Jul 22, 2014
работа с ms sql в php
View mssql in php
<?php
$server = '88.xxx.xxx.xxx\SQLEXPRESS';
$link = mssql_connect($server, 'db_username', 'db_password');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
mssql_select_db('database_name', $link);
$query_result = mssql_query('SELECT * FROM MenuItems');
You can’t perform that action at this time.