This file contains hidden or 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
package services | |
import ( | |
"github.com/sirupsen/logrus" | |
) | |
type Logger interface { | |
// formatted methods | |
Debugf(format string, args ...interface{}) | |
Infof(format string, args ...interface{}) |
This file contains hidden or 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
from contextlib import ExitStack | |
from functools import partial | |
# In some situation it's needed to care about program termination, explicitly or implicitly (by kill or raising an | |
# exception in the flow), situation likes send a notification on termination. For this purpose we can use contextlib | |
# of Python. Define our callbacks and put our main in an ExitStack. For more information see | |
# https://docs.python.org/3/library/contextlib.html#contextlib.ExitStack | |
def printStars(): |
This file contains hidden or 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
new Date().toISOString().split('.')[0].split('T').join(' ') | |
# "2019-08-31 12:40:44" |
This file contains hidden or 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
sed -i "1s/[A-Z]/\L&/g" FILENAME |
This file contains hidden or 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
ALTER TABLE `test` DROP `id`; | |
ALTER TABLE `test` AUTO_INCREMENT = 1; | |
ALTER TABLE `test` ADD `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; |
This file contains hidden or 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
SEARCH_DIR="/path/to/directory" | |
FORMAT="%Y-%m-%d %H:00:00" | |
find $SEARCH_DIR -newerat "`date -d "-50minutes" +"$FORMAT"`" ! -newerat "`date +"$FORMAT"`" |
This file contains hidden or 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
def removeSimilarKeyFromDictionary(d, key): | |
for s in d.keys(): | |
if key.find(s) != -1: | |
# True with a non-empty list mean the given key is the final key, but it has a candidate on list | |
return True, s | |
elif s.find(key) != -1: | |
# False with a non-empty list mean the iterator key is the final key and its value should sum with | |
# the value of returned key | |
return False, s | |
This file contains hidden or 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
# define alternatives | |
update-alternatives --install /usr/bin/java java /opt/lib/jdk/bin/java 100 | |
update-alternatives --install /usr/bin/javac javac /opt/lib/jdk/bin/javac 100 | |
update-alternatives --install /usr/bin/javaws javaws /opt/lib/jdk/bin/javaws 100 | |
# do config | |
update-alternatives --config java | |
update-alternatives --config javac | |
update-alternatives --config javaws |
This file contains hidden or 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
# install libraries | |
apt install libgtk2.0-0 | |
apt install libgconf-2-4 | |
# install xvfb to run orca as a server without graphical environment | |
apt install xvfb | |
# install electron | |
npm install -g [email protected] --allow-root --unsafe-perm |
This file contains hidden or 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 bash | |
translate() { | |
notify-send "$1" $(trans -no-bidi -b :@fa "$1") | |
} | |
select_and_translate() { | |
translate "$(xclip -out -selection primary)" | |
} |