Skip to content

Instantly share code, notes, and snippets.

View iandark's full-sized avatar
:electron:

Derkian Afonso iandark

:electron:
  • Juiz de Fora, Brazil
View GitHub Profile
@iandark
iandark / backup-redis-rdb.sh
Created January 18, 2022 05:07
Backup redis into rdb file
#!/bin/bash
set -e
##
# Path for the original RDB file
##
rdbPath=/var/lib/redis
rdbFile=dump.rdb
@iandark
iandark / smart-git.sh
Last active February 1, 2022 14:18
You might think this is a git mirror script, but it's not — it's just a backup script.
#!/bin/bash
# Hey, this is not a mirroring script, but it might taste good for what you need.
# This shell script reads a CSV file, where you can pass an origin repository and makes a backup into another repository.
# Lines of CSV file with 'All branchs' checked (x) will push all origin branches into the backup repository.
# If you pass another value different from ¨x¨, it will push only non-existing branches on the backup repository.
#
# The expected format of the CSV file is below.
#
# +--------------------------------------------+-----------------------------------------------+-------------+
@iandark
iandark / README.md
Last active April 11, 2022 14:40 — forked from Calinou/README.md
Increase NVIDIA power limit with the proprietary driver on Linux, from 200W to the maximum 216W on a GeForce GTX 1080

Instructions

  • Save nvidia-tdp.service and nvidia-tdp.timer to /etc/systemd/system.
  • Run sudo systemctl daemon-reload && sudo systemctl enable nvidia-tdp && sudo systemctl start nvidia-tdp to apply immediately and on future boots.
@iandark
iandark / xcode-fix.txt
Created April 21, 2022 18:34
Fixing xcode update stuck
1. Open Activity Monitor, search for appstoreagent and stop/quit the process.
2. The Launchpad Xcode Icon should have changed from Installation to Waiting.
3. Long press the Xcode Icon and press the X to delete it.
Nothing will actually happen, so I am not entirely sure if this step is actually needed,
but just to be sure, I wanted to mention it.
4. Restart your MacBook.
System process daemons that are system-wide provided by mac os x are described by launchd preference files that can be showed with the command:
$ sudo ls -all /System/Library/LaunchDaemons/
Third party process daemons that are system-wide provided by the administrator are described by preference files that can be showed with the command:
$ sudo ls -all /Library/LaunchDaemons/
Launch Agents that are per-user provided by mac os x usually loaded when the user logs in. Those provided by the system can be found with:
$ sudo ls -all /System/Library/LaunchAgents/
Launch Agents that are per-user provided by the administrator and usually loaded when the user logs in. Those provided by the system can be found with:
@iandark
iandark / DisablingCleanMyMacHealthMonitor.txt
Created April 26, 2022 03:23
Disabling CleanMyMac X HealthMonitor process
Go to:
/Applications/CleanMyMacX.app/Contents/Library/LoginItems/CleanMyMac X Menu.app/Contents/Library/LoginItems/CleanMyMac X HealthMonitor.app/Contents/MacOS/CleanMyMac X HealthMonitor
Then add to CleanMyMac X HealthMonitor '.old'
and force quit it again in activity monitor
@iandark
iandark / stylus_google_translate.css
Last active July 12, 2024 05:38
Google translate dark mode - Stylus
/* ==UserStyle==
@name google translate dark mode
@version 20220201.13.28
@namespace userstyles.world/user/kedouvv
@description 为谷歌翻译 web 添加深色模式
@author kedouvv
@license GNU GENERAL PUBLIC LICENSE Version 3
==/UserStyle== */
@-moz-document domain("translate.google.cn"),
@iandark
iandark / replace-text-multiple-files.sh
Created June 12, 2022 14:14
shell - replace text inside multiple files
#!/bin/bash
for f in *.extensionFile; do
sudo sed -i 's/old-text/new-text/g' "$f"
done
@iandark
iandark / smart-ip-python.py
Created July 11, 2022 02:13
Python - Get IP and location
import requests
from requests.exceptions import HTTPError
import json
try:
response = requests.get('https://ipinfo.io')
response.raise_for_status()
jsonResponse = response.json()
print(json.dumps(jsonResponse, indent=4, sort_keys=True, ensure_ascii=False))
except HTTPError as http_err:
@iandark
iandark / smart-work.sh
Last active July 11, 2022 15:43
Execute process
#!/bin/bash
## This script can be used to be executed for whatever you want, as you need. In my case, I put this script to run every reboot, and at 8 pm,
## so whenever I have to work, the applications related to my work will be opened/closed.
## There's another version of this script for python. You can check on: https://gist.github.com/iandark/b0ddf75569de060bc44ed3c79e27e395
execute_process()
{
nameProcess=$1
isExecutingCmd="pgrep -x $nameProcess"