Skip to content

Instantly share code, notes, and snippets.

@oniksfly
oniksfly / backup.sh
Created March 11, 2018 14:08
Backup PostreSQL database from docker container
# /bin/bash
echo "Backup script is running"
PG_DOCKER_CONTAINER="postgres"
PG_USERNAME="postgres"
DATABASE="default_database"
HOMEPATH=$(cd ~ && pwd)
COLOR_NORMAL="\033[0m"
@oniksfly
oniksfly / ios_tcpdump.sh
Last active November 28, 2017 20:50
Get TCP dump for iOS device
# Attach iOS device to Mac and create virtual network
# Use real iOS UUID instead placeholder
# It is possible to get UUID with iTunes: just click on `Serial number` field
rvictl -s UUID
# Returns `Starting device UUID [SUCCEEDED] with interface rviX`
# Start dumping traffic
# Use real name of virtual network instead `rviX`
# To stop use `ctrl + C`
sudo tcpdump -i rviX -w ~/ios.pcap
@oniksfly
oniksfly / terminate.sh
Last active August 16, 2017 08:38
Terminate postres DB connections
psql -c "SELECT *, pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'DATABASE_NAME'"
@oniksfly
oniksfly / serp-position-google.js
Last active August 29, 2015 14:26
SERP site position bookmarklet
function getUrlParameter(sParam){var sPageURL = window.location.search.substring(1);var sURLVariables = sPageURL.split('&');for (var i = 0; i < sURLVariables.length; i++) {var sParameterName = sURLVariables[i].split('=');if (sParameterName[0] == sParam) {return sParameterName[1];}}}
var site_url = '';
var message = '';
var $onPageItems = jQuery('#ires .g:not(#imagebox_bigimages)');
var start = getUrlParameter('start');
if (!start) {
start = 0;
} else {
start = parseInt(start);
}
@oniksfly
oniksfly / pager_all.php
Last active August 29, 2015 14:18
Drupal "Show all" pager
// Part of pager_all.module Drupal 7
/**
* Implements hook_custom_theme().
*/
function pager_all_theme() {
return array(
'pager_all' => array(
'variables' => array(),
)
@oniksfly
oniksfly / mysql_drop_all_tables.sh
Last active August 29, 2015 14:17
CLI MySQL drop all tables
mysql -u DB_USER_NAME -p DB_USER_PSWD -Nse 'show tables' DATABASE_NAME | while read table; do mysql -u DB_USER_NAME -p DB_USER_PSWD -e "drop table $table" DATABASE_NAME; done