Last active
November 1, 2017 20:10
-
-
Save Rhernandez513/6e4c59fff7bdd9144389 to your computer and use it in GitHub Desktop.
Scripts in my \~/bin'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
# | |
# md.py - simple script to convert a MarkDown file to HTML | |
# | |
# By Robert David Hernandez https://gist.github.com/Rhernandez513/6e4c59fff7bdd9144389 | |
import sys | |
import mistune | |
with open(sys.argv[1], 'r') as my_file: | |
contents = my_file.read() | |
markdown = mistune.Markdown() | |
print(markdown(contents)) | |
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
# This script rotates the screen and touchscreen input 90 degrees each time it is called, | |
# also disables the touchpad, and enables the virtual keyboard accordingly | |
# | |
# by Ruben Barkow: https://gist.github.com/rubo77/daa262e0229f6e398766 | |
#### configuration | |
# find your Touchscreen and Touchpad device with `xinput` | |
TouchscreenDevice='ELAN Touchscreen' | |
TouchpadDevice='SynPS/2 Synaptics TouchPad' | |
if [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then | |
echo 'Usage: rotate-screen.sh [OPTION]' | |
echo | |
echo 'This script rotates the screen and touchscreen input 90 degrees each time it is called,' | |
echo 'also disables the touchpad, and enables the virtual keyboard accordingly' | |
echo | |
echo Usage: | |
echo ' -h --help display this help' | |
echo ' -j (just horizontal) rotates the screen and touchscreen input only 180 degrees' | |
echo ' -n always rotates the screen back to normal' | |
exit 0 | |
fi | |
touchpadEnabled=$(xinput --list-props "$TouchpadDevice" | awk '/Device Enabled/{print $NF}') | |
screenMatrix=$(xinput --list-props "$TouchscreenDevice" | awk '/Coordinate Transformation Matrix/{print $5$6$7$8$9$10$11$12$NF}') | |
# Matrix for rotation | |
# ⎡ 1 0 0 ⎤ | |
# ⎜ 0 1 0 ⎥ | |
# ⎣ 0 0 1 ⎦ | |
normal='1 0 0 0 1 0 0 0 1' | |
normal_float='1.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,1.000000' | |
#⎡ -1 0 1 ⎤ | |
#⎜ 0 -1 1 ⎥ | |
#⎣ 0 0 1 ⎦ | |
inverted='-1 0 1 0 -1 1 0 0 1' | |
inverted_float='-1.000000,0.000000,1.000000,0.000000,-1.000000,1.000000,0.000000,0.000000,1.000000' | |
# 90° to the left | |
# ⎡ 0 -1 1 ⎤ | |
# ⎜ 1 0 0 ⎥ | |
# ⎣ 0 0 1 ⎦ | |
left='0 -1 1 1 0 0 0 0 1' | |
left_float='0.000000,-1.000000,1.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000' | |
# 90° to the right | |
#⎡ 0 1 0 ⎤ | |
#⎜ -1 0 1 ⎥ | |
#⎣ 0 0 1 ⎦ | |
right='0 1 0 -1 0 1 0 0 1' | |
if [ $screenMatrix == $normal_float ] && [ "$1" != "-n" ] | |
then | |
echo "Upside down" | |
xrandr -o inverted | |
xinput set-prop "$TouchscreenDevice" 'Coordinate Transformation Matrix' $inverted | |
xinput disable "$TouchpadDevice" | |
# Remove hashtag below if you want pop-up the virtual keyboard | |
#onboard & | |
elif [ $screenMatrix == $inverted_float ] && [ "$1" != "-j" ] && [ "$1" != "-n" ] | |
then | |
echo "90° to the left" | |
xrandr -o left | |
xinput set-prop "$TouchscreenDevice" 'Coordinate Transformation Matrix' $left | |
xinput disable "$TouchpadDevice" | |
#killall onboard | |
elif [ $screenMatrix == $left_float ] && [ "$1" != "-j" ] && [ "$1" != "-n" ] | |
then | |
echo "90° to the right" | |
xrandr -o right | |
xinput set-prop "$TouchscreenDevice" 'Coordinate Transformation Matrix' $right | |
xinput disable "$TouchpadDevice" | |
#killall onboard | |
else | |
echo "Back to normal" | |
xrandr -o normal | |
xinput set-prop "$TouchscreenDevice" 'Coordinate Transformation Matrix' $normal | |
xinput enable "$TouchpadDevice" | |
#killall onboard | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
# update__git_repos - A simple script to update git repos within a directory | |
# | |
# By Robert David Hernandez https://gist.github.com/Rhernandez513/6e4c59fff7bdd9144389 | |
# Location where this script is stored in the filesystem | |
# STARTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
# Location of the working directory of the calling shell | |
PARENTDIR=$PWD | |
# Convert from HTTPS to SSH (faster) access for cloned repos | |
# for i in */; do | |
# sed -i 's/https\:\/\/github.com\//git@github.com\:/' "$i/.git/config" | |
# done | |
# Cycles into each directory where the script is called from and updates | |
echo "Script called from $PARENTDIR" | |
for DIR in */; do | |
cd "$DIR" | |
echo "Updating: $DIR" | |
git fetch | |
git pull | |
cd "$PARENTDIR" | |
done | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment