Skip to content

Instantly share code, notes, and snippets.

View Lokideos's full-sized avatar

George Asfour Lokideos

View GitHub Profile
### Keybase proof
I hereby claim:
* I am lokideos on github.
* I am lokideos (https://keybase.io/lokideos) on keybase.
* I have a public key ASCAdheIJr77ecTcMulXdHO7hs2ETKB6e8p2NZs0GSbC2Qo
To claim this, I am signing this object:
#include "json2.js"
function log (input) {
if(!debug) return;
if(!JSON || !JSON.stringify) return;
var now = new Date();
var output = JSON.stringify(input);
$.writeln(now.toTimeString() + ": " + output);
#include "json_log.js";
// Enable logging
var debug = true;
// Получаем путь к скрипту
var scriptFile = new File($.fileName);
var scriptFolderPath = scriptFile.parent;
// Получаем список файлов в папке со скриптом
var fileList = scriptFolderPath.getFiles(/\.(jpg|psd)$/i);
# Running rake tasks from console
require 'rake'
Rails.application.load_tasks
Rake::Task['my_task'].invoke
# Running rake task with arguments
Rake::Task['my_task'].invoke("arg1", "arg2")
@Lokideos
Lokideos / gist:e8f2981ee8d5a52d8809c1d52179bc6f
Created September 7, 2021 10:15
Open GitHub repository from your terminal
Add the following code to your `.zprofile` file. Now, if you type `github` from the root directory of your project,
your browser will open a new tab with your repository opened on GitHub.
```
github() {
if [ ! -d .git ] && ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "ERROR: This isnt a git directory" && return false
fi
git_url=$(git config --get remote.origin.url)
if [[ $git_url == https://gitlab* ]]; then
@Lokideos
Lokideos / gist:721c92d1942101776ad77067e2fdd4b7
Created August 5, 2021 17:23
Check process using ports on Mac OS
sudo lsof -i -P | grep LISTEN
# Go to the end of the line and switch to insert mode
Shift + A
# Search and replace all occurencies
:%s/(what to search)/(to what replace)/g
# command to delete logs - although you will be force to restart containers
sudo find /var/lib/docker/containers/ -type f -name "*.log" -delete
# make backup file from pg db located on localhost. .dump extension is optional, but desirable
PG_PASSWORD="<your db password>" pg_dump -h localhost -d <your database name> -U <your db user> > <backup file name>.dump
# load backup file to your db to db in docker container
cat <backup file name> | docker exec -i <container name> psql -U <db user> -d <your db name>
@Lokideos
Lokideos / gist:83f12434f50f713fcc9579430ac76696
Last active May 1, 2021 10:23
Old Ruby installations and compatibility problems (MacOS specific)
# If you encounter any old ruby installation/old gem installation problems there is a good chance that it cannot find
# universal-darwin19 file. For this purpose you should create symlink with needed name to currend universal-darwin file
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
ln -sf universal-darwin20 universal-darwin19
# If you encounter any problems with rubygems during old ruby installation reinstall ruby with older rubygems version
# Following command is example for reinstalling ruby 2.3.8 using rvm with older rubygems version (2.6.8)
rvm reinstall 2.3.8 --rubygems 2.6.8
# In order to install gems you need openssl.