Skip to content

Instantly share code, notes, and snippets.

View Hammer2900's full-sized avatar
🌲
___

Yevhen Ts. Hammer2900

🌲
___
View GitHub Profile
@Hammer2900
Hammer2900 / toggle-nightlight.sh
Created December 11, 2018 19:01 — forked from kapad/toggle-nightlight.sh
Script to toggle the Gnome nightlight setting.
#!/bin/bash
setting=$(gsettings get org.gnome.settings-daemon.plugins.color night-light-enabled)
if [[ $setting == "true" ]]; then
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled false
else
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
fi
@Hammer2900
Hammer2900 / x11_watch_active_window.py
Created August 12, 2018 07:35 — forked from ssokolow/x11_watch_active_window.py
python-xlib example which reacts to changing the active window
#!/usr/bin/env python
"""python-xlib example which reacts to changing the active window/title.
Requires:
- Python
- python-xlib
Tested with Python 2.x because my Kubuntu 14.04 doesn't come with python-xlib
for Python 3.x.
@Hammer2900
Hammer2900 / youtube_find_relevant.py
Created July 27, 2018 18:45 — forked from idlesign/youtube_find_relevant.py
Finds YouTube videos you're interested in. PyCon US talks finder example.
import re
import requests
API_KEY = 'xxx'
'''Google API (YouTube Data API v3) key from https://console.developers.google.com/apis/.'''
# Put titles you're interested into RELEVANT string:
# one title per line.
RELEVANT = '''
@Hammer2900
Hammer2900 / adapter.py
Created May 13, 2018 20:47 — forked from pazdera/adapter.py
Example of `adapter' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `adapter' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@Hammer2900
Hammer2900 / prototype.py
Created May 13, 2018 20:38 — forked from pazdera/prototype.py
Example of `prototype' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `prototype' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@Hammer2900
Hammer2900 / builder.py
Created May 13, 2018 20:35 — forked from pazdera/builder.py
Example of `builder' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `builder' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@Hammer2900
Hammer2900 / nemo_script_shell.sh
Created April 10, 2018 04:48 — forked from alexklapheke/nemo_script_shell.sh
Template for nautilus/nemo scripts
#!/bin/bash
# Template for Nemo scripts.
# Place in $HOME/.local/share/nemo/scripts/
# For Nautilus: s/NEMO/NAUTILUS/g
export IFS=$'\n'
curpath=${NEMO_SCRIPT_CURRENT_URI#file://}
files=$NEMO_SCRIPT_SELECTED_FILE_PATHS
cd "$curpath"
@Hammer2900
Hammer2900 / i3-gaps-install.sh
Created April 1, 2018 21:18 — forked from aaronsaderholm/i3-gaps-install.sh
Install i3-gaps on Ubuntu 16.04
#!/bin/bash
# Install i3-gaps on Ubuntu 16
set -e
set -x
sudo apt-get update && sudo apt-get -y dist-upgrade && \
sudo apt-get install -y libxcb1-dev libxcb-keysyms1-dev libpango1.0-dev libxcb-util0-dev libxcb-icccm4-dev libyajl-dev libstartup-notification0-dev libxcb-randr0-dev libev-dev libxcb-cursor-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev autoconf xutils-dev dh-autoreconf
mkdir -p $HOME/repos
cd $HOME/repos
@Hammer2900
Hammer2900 / django_settings.py
Last active March 29, 2018 06:56 — forked from bubenkoff/django_settings.py
Utility script which switches the django settings module. Usage: setup_django_settings('myproject.settings')
import os
import sys
from django.utils.importlib import import_module
from django.core.urlresolvers import clear_url_caches
from django.template import context, base, loader
from django.utils import translation
from django.utils.translation import trans_real
@Hammer2900
Hammer2900 / fsm.py
Created February 13, 2018 05:01 — forked from harlowja/fsm.py
FSM
import prettytable
import six
import sys
class FSM(object):
"""A basic state machine."""
def __init__(self, start_state):
self._table = {}