Skip to content

Instantly share code, notes, and snippets.

View dmgl's full-sized avatar
🎯
Focusing

Galochkin D.D. dmgl

🎯
Focusing
  • Russia, Saint-Petersburg
View GitHub Profile
@dmgl
dmgl / first_start_pi_instructions.txt
Last active January 11, 2018 09:38
First start RaspberryPi instructions
sudo raspi-config # set hostname; ssh, vnc enable; spi enable
sudo leafpad /etc/ssh/sshd_config # set port, listen
sudo apt-get update && sudo apt-get upgrade
sudo apt-get purge bluej scratch greenfoot
rm -rf ~/oldconffiles/ ~/oldconffiles/Scratch
rm -rf ~/Documents/*
sudo dpkg-reconfigure locales
@dmgl
dmgl / how_referer_header_works.py
Last active September 11, 2019 12:20
How HTTP referer works
#!/usr/bin/env python
# save this file and run `python how_referer_header_works.py`
# to stop you can use commnad `lsof -i tcp:9999` and kill pid
# usage: make public post on any site with hlink href http://0.0.0.0:9999 and click on it
# or `curl 0.0.0.0:9999 --referer google.com -H "X-Something: Yeah-yeah-yeah"`
# see output of script with headers section (custom referer)
@dmgl
dmgl / idle.py
Last active January 30, 2020 16:16
How to launch Idle from virtualenv
#!/usr/bin/env python
from idlelib.PyShell import main
if __name__ == '__main__':
main()
@dmgl
dmgl / make_repo_instructions.txt
Last active May 18, 2020 21:26
Instructions for making git repo
# Create a bare repository on the server side.
cd ~/Projects; sudo -u pi mkdir -m 770 project.git
cd project.git; sudo -u pi git --bare init --shared=group
# From client side the developer’s project must be pushed into the new bare server repository:
# First, create a new local git repository and add all files within this folder.
cd dir_with_files; git init; git add .; git commit -m "creation repo"
git remote add origin ssh://pi@address:port/home/pi/Projects/project.git
# Check origin
@dmgl
dmgl / pc.orig
Last active September 8, 2020 16:40 — forked from jonschoning/pc.laptop
Modify /usr/share/X11/xkb/symbols/pc to swap CTRL to ALT key.
default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {
key <ESC> { [ Escape ] };
// The extra key on many European keyboards:
key <LSGT> { [ less, greater, bar, brokenbar ] };
// The following keys are common to all layouts.
key <BKSL> { [ backslash, bar ] };
@dmgl
dmgl / update-resolv-conf.sh
Last active September 8, 2020 16:41 — forked from janvojt/update-resolv-conf.sh
Script for updating DNS configuration after openvpn creates a new virtual network interface for forwarding traffic into VPN (place /etc/openvpn/scripts)
#!/usr/bin/env bash
#
# Parses DHCP options from openvpn to update resolv.conf
# To use set as 'up' and 'down' script in your openvpn *.conf:
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
#
# Used snippets of resolvconf script by Thomas Hood <jdthood@yahoo.co.uk>
# and Chris Hanson
# Licensed under the GNU GPL. See /usr/share/common-licenses/GPL.
@dmgl
dmgl / dmgl_google_translate.py
Last active September 8, 2020 16:47
Google-translate in console (~/.local/bin/dmgl_google_translate.py)
#!/usr/bin/python3
import sys
import requests
def translate(string, from_language="auto", to_language="auto"):
headers = {"User-Agent":"Mozilla/4.0 (compatible; MSIE 6.0; \
Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; \
@dmgl
dmgl / dmgl_switch_layout.py
Created September 8, 2020 16:51
Switch layout by CapsLock (added to startup)
#!/usr/bin/env python3
import subprocess
from pynput import keyboard
# Switch layout - Disable
# Compose key - Disable
# ⌘ key behavior - Shortcut Overlay
# Caps Lock bevahior - Disable
@dmgl
dmgl / application_list_current.txt
Last active September 8, 2020 16:53
My linux application list
dmgl@metal:~$ ls /usr/share/applications | awk -F '.desktop' ' { print $1}' -
4kvideodownloader
apport-gtk
assistant-qt5
bamf-2.index
bluetooth-sendto
ca.desrt.dconf-editor
catfish
cheese
@dmgl
dmgl / get_tracks.js
Last active September 9, 2020 09:59
Get file csv with vk music tracks
var links,thisLink;
var myCsv;
links = document.getElementsByClassName('audio_row_content _audio_row_content');
for (let item of links) {
title = item.getElementsByClassName('audio_row__title_inner _audio_row__title_inner').item(0).innerText
performer = item.getElementsByClassName('audio_row__performers').item(0).innerText
console.log(performer + " - " + title)