Skip to content

Instantly share code, notes, and snippets.

View nightcrawler-'s full-sized avatar

Frederick Nyawaya nightcrawler-

View GitHub Profile
@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- / 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- / gist:cfd57a8031284c35d2fb473978c8d291
Created May 12, 2020 17:34
Get version name from build.gradle
VERSION_NAME=`grep -oP 'versionName "\K(.*?)(?=")' ./${APP_FOLDER}/build.gradle`
@nightcrawler-
nightcrawler- / rspec_model_testing_template.rb
Created September 29, 2020 10:34 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@nightcrawler-
nightcrawler- / db.rake
Created October 17, 2020 05:47 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@nightcrawler-
nightcrawler- / capybara cheat sheet
Created November 9, 2020 18:49 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@nightcrawler-
nightcrawler- / available-space.sh
Last active November 10, 2020 08:30
View folder sizes on bash
apt-get install ncdu
# ncdu to show, is interactive, will see for each file
# du -h for files
# dh -h for available
@nightcrawler-
nightcrawler- / gist:0667911c8d589a76d82da9ea82332cf4
Created November 10, 2020 23:45 — forked from caok/gist:4065758
Deploy from a git tag with capistrano
ref: http://nathanhoad.net/deploy-from-a-git-tag-with-capistrano
Deploy from a Git tag with Capistrano
Are you using Capistrano and Git and want to easily deploy from Git tags? It couldn't be simpler
Using Git, tag a new release:
git tag -a 09.10.02.01 -m "Tagging a release"
You can use git tag to list your tags:
@nightcrawler-
nightcrawler- / Count Code lines
Created November 15, 2020 05:57 — forked from amitchhajer/Count Code lines
Count number of code lines in git repository per user
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n
@nightcrawler-
nightcrawler- / StringUtil.java
Created April 26, 2021 12:37
Increment String in Java in a similar manner as Ruby's String#next
/**
* Utilities method for manipulating String.
* @author zemian 1/1/13
*/
public class StringUtils {
/** Calculate string successor value. Similar to Ruby's String#next() method. */
public static String next(String text) {
// We will not process empty string
int len = text.length();