Skip to content

Instantly share code, notes, and snippets.

Avatar

Anatoly Ivanov iAnatoly

View GitHub Profile
@iAnatoly
iAnatoly / respbery_wifi.sh
Created Nov 5, 2019
Fix raspbery pi wifi reconnevct
View respbery_wifi.sh
cp /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown
@iAnatoly
iAnatoly / fix-ubuntu-wifi-on-resume.sh
Created Nov 5, 2019
Fix no wifi on resume in Ubuntu
View fix-ubuntu-wifi-on-resume.sh
# cat > /etc/systemd/wifi-resume.service
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service
@iAnatoly
iAnatoly / swap.sh
Created Oct 14, 2019
oneliner to investigateprocess swap usage
View swap.sh
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
@iAnatoly
iAnatoly / json-to-sqlite.md
Last active Aug 10, 2019
Convert json to a sqlite database for querying
View json-to-sqlite.md

Sometimes, you need to quickly dump a json file into sqlite, just to run some queries on it. This is a two-step process:

1. convert json to csv

cat file.json | jq -r '.data | map([.field1, .field2, .field3] | @csv)| join("\n")' > file.csv

1a. add headers line into your csv file, i.e.

@iAnatoly
iAnatoly / gist:bff5274bd2730b1a4801cdb6cb152fa1
Created Feb 2, 2019
Fixing ubuntu 18.10 lock screen issue
View gist:bff5274bd2730b1a4801cdb6cb152fa1
# the issue is siimple misconfigurations of gdm3
# the solution is to reinstall it, or better yet - switch to lightdm:
sudo apt remove gdm3 && dpkg-reconfigure lightdm
#
# or reinstall gdm3, it is up to you.
View homedot-clone.sh
#!/bin/bash
#
# based off https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/
#
git clone --bare git@github.com:iAnatoly/homedot.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
config checkout
@iAnatoly
iAnatoly / import-hashes.ps1
Last active Jun 19, 2018
How to upload 501M SHA1 hashes into a SQL database
View import-hashes.ps1
# How to upload 501M SHA1 hashes into a SQL database
#
# Based on:
# https://blog.netnerds.net/2015/01/powershell-high-performance-techniques-for-importing-csv-to-sql-server/
# https://gallery.technet.microsoft.com/scriptcenter/Import-Large-CSVs-into-SQL-216223d9
#
# Database variables
$sqlserver = "YOUR_SERVER"
$database = "YOUR_DATABASE"
$table = "YOUR_TABLE"
View tweak.sh
# override DHCP hostname assignment
sudo scutil --set HostName myhostname.domain.local
# tweak network
cat >> /etc/sysctl.conf <<EOF
# OSX default of 3 is not big enough
net.inet.tcp.win_scale_factor=8
# increase OSX TCP autotuning maximums
net.inet.tcp.autorcvbufmax=33554432
net.inet.tcp.autosndbufmax=33554432
@iAnatoly
iAnatoly / generate.sh
Created Jun 15, 2017
Interruptible script generating pre-defined number of random files
View generate.sh
#!/bin/bash
TARGET_FILE_NUM=10000
CURRENT_FILE_NUM=`ls -l | wc -l`
FILES_TO_GENERATE=$((TARGET_FILE_NUM - CURRENT_FILE_NUM))
MAX_FILE_SIZE=8192
FILE_NAME_PREFIX="test_"
if [[ $FILES_TO_GENERATE -lt 0 ]]; then
echo "We already have $CURRENT_FILE_NUM files, no need to generate more"
@iAnatoly
iAnatoly / reclaimWindows10.ps1
Created Jan 7, 2017 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
View reclaimWindows10.ps1
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
You can’t perform that action at this time.