Skip to content

Instantly share code, notes, and snippets.

View nightcrawler-'s full-sized avatar

Frederick Nyawaya nightcrawler-

View GitHub Profile
@nightcrawler-
nightcrawler- / rename-seq.sh
Created March 31, 2020 07:56
Rename all PNG files in directory sequentially from 1, pad to x length
a=1
for i in *.png; do
new=$(printf "%04d.png" "$a") #04 pad to length of 4
mv -i -- "$i" "$new"
let a=a+1
done
@nightcrawler-
nightcrawler- / get-files.sh
Created April 2, 2020 16:58
Gets all files listed in res-urls and structures them the same way in the local folder
wget -x -nH -i res-urls
@nightcrawler-
nightcrawler- / get-files.sh
Created April 2, 2020 16:58
Gets all files listed in res-urls and structures them the same way in the local folder
wget -x -nH -i res-urls
@nightcrawler-
nightcrawler- / rails-seed.rb
Created April 3, 2020 16:08
Load seeds from a json file
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
# Seed file:
# /home/frederick/Dev/data/legacy-medexam
@nightcrawler-
nightcrawler- / psql-error-fix.md
Created April 13, 2020 13:08 — forked from AtulKsol/psql-error-fix.md
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

// Gets the version code -- number of git tags to this end
def getVersionCode = { ->
try {
def code = new ByteArrayOutputStream()
exec {
commandLine 'git', 'tag', '--list'
standardOutput = code
}
return code.toString().split("\n").size()
}
@nightcrawler-
nightcrawler- / download-apply-ktlint.sh
Created April 14, 2020 17:15
Download ktlint and apply to current project
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.36.0/ktlint &&
chmod a+x ktlint &&
sudo mv ktlint /usr/local/bin/
./ktlint --android applyToIDEA
@nightcrawler-
nightcrawler- / check_github_repo_size
Created May 1, 2020 20:08 — forked from dingzeyuli/check_github_repo_size
Check the size of a github repo before downloading
# http://webapps.stackexchange.com/questions/39587/view-estimated-size-of-github-repository-before-cloning
# tested on macOS
echo https://github.com/torvalds/linux.git | perl -ne 'print $1 if m!([^/]+/[^/]+?)(?:\.git)?$!' | xargs -I{} curl -s -k https://api.github.com/repos/'{}' | grep size
# output:
# "size": 1746294,
for i in {1..141}
do
curl --header "Content-Type: application/json" \
--request POST \
--data '{"content_id":"r4xa8y35","checked_answers":"wg8sfxa2zda4","name":null}' \
https://strawpoll.com/api/poll/vote
done
@nightcrawler-
nightcrawler- / perm.sh
Created May 6, 2020 11:08
When trying to use a downloaded key file, change permissions (ssh access)
chmod 400 ~/.ssh/ecs.pem