Skip to content

Instantly share code, notes, and snippets.

View nightcrawler-'s full-sized avatar

Frederick Nyawaya nightcrawler-

View GitHub Profile
@nightcrawler-
nightcrawler- / gist:46a33978c90899a5b5db90714168353a
Created May 10, 2020 07:59
Fast scroll RecyclerView params
app:fastScrollEnabled="true"
app:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
app:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
app:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
app:fastScrollVerticalTrackDrawable="@drawable/line_drawable"
@nightcrawler-
nightcrawler- / status-bar.kt
Created May 10, 2020 07:07
Fucntion to switch the status bar and nav bar colors on open/close navigation drawer
//TODO: Frederick, until this is figured out, just dont, functionality trumps subtle color shade differences and jarring changes
//BG: This gives a uniform background color and content color when drawer is open on +10 devices,
// without it, sattus bar retains light theme..and 'up' navigation is shot
//DEAD CODE ALERT
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// binding.drawerLayout.addDrawerListener(object : ActionBarDrawerToggle(
// this,
// binding.drawerLayout,
// binding.toolbar,
@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
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- / 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,
@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
// 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- / 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

@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- / 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