Skip to content

Instantly share code, notes, and snippets.

@obliviusm
Last active October 29, 2020 08:28
Show Gist options
  • Save obliviusm/1db21a87c32afb32ca39 to your computer and use it in GitHub Desktop.
Save obliviusm/1db21a87c32afb32ca39 to your computer and use it in GitHub Desktop.
Commands
Rake
  1. rake -T -A Run from your Rails home directory to see all the tasks that rake knows about. Yours must be in that list for rake to run it.
  2. http://stackoverflow.com/questions/12409544/how-to-disable-rack-mini-profiler-temporarily
  3. run rails in production mode lacaly: bundle exec rake assets:clean && bundle exec rake assets:precompile && bundle exec rails s -e production_local
  4. bundle exec rake konacha:serve
  5. rake time:zones:all - all available time zones
Git
  1. Reset all changes after last commit in git First reset the changes git reset HEAD --hard then clean out everything untracked git clean -fd
  2. Removing multiple files from a Git repo that have already been deleted from disk git ls-files --deleted -z | xargs -0 git rm
  3. Pull A Git Branch from Remote http://www.wetware.co.nz/2009/07/pull-a-git-branch-from-remote/
  4. Multiple GitHub Accounts & SSH Config http://stackoverflow.com/questions/3225862/multiple-github-accounts-ssh-config
  5. get a list of git branches git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)' http://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
  6. Force Git to overwrite local files on pull http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull
  7. Git Clean: Delete Already-Merged Branches http://stevenharman.net/git-clean-delete-already-merged-branches
  8. remove untracked files git clean -f -n http://stackoverflow.com/questions/61212/how-do-i-remove-local-untracked-files-from-my-current-git-branch
  9. Stop tracking changes in file git update-index --assume-unchanged <file-name> http://stackoverflow.com/questions/936249/how-to-stop-tracking-and-ignore-changes-to-a-file-in-git
Ruby
  1. Prettier, user friendly printing of Ruby objects to_yaml http://vitobotta.com/prettier-more-user-friendly-printing-ruby-objects/#sthash.qWy59q5T.dpbs
  2. start simple http server ruby -run -ehttpd . -p8000
Postgres - hot to set up pg for rails
  1. sudo apt-get update. Install pg and dependencies sudo apt-get install postgresql postgresql-contrib libpq-dev
  2. chnage config file subl /etc/postgresql/9.4/main/pg_hba.conf to grant full access
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
  1. Create super user role in psql (same login as in system):
$ psql -U postgres
postgres=# create role obliviusm with login encrypted password 'pass';
postgres=# \du
postgres=# alter role obliviusm with superuser;
  1. PostgreSQL add or create a user account and grant permission for database http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/
  2. PostgreSQL - creating and dropping roles http://articles.slicehost.com/2009/5/7/postgresql-creating-and-deleting-roles
  3. Trying to set up postgres for ror app fe_sendauth: no password supplied http://stackoverflow.com/questions/12452073/trying-to-set-up-postgres-for-ror-app-getting-error-fe-sendauth-no-password
  4. If database is locked by another process just restart the server: sudo service postgresql restart
MySQL
  1. Instruction https://gist.github.com/operatino/392614486ce4421063b9dece4dfe6c21
  2. Commands: brew install mysql@5.7, brew link mysql@5.7 --force
  3. mysql -uroot
  4. sudo killall mysqld
PSD
  1. Convert Photoshop Drop Shadows to CSS3 Box & Text Shadows http://www.melanieceraso.com/psd-to-css3/#sthash.D3ElzRJT.Y0bLVC0L.dpbs
RVM
  1. http://cheat.errtheblog.com/s/rvm
  2. error setting certificate verify locations http://stackoverflow.com/questions/3160909/how-do-i-deal-with-certificates-using-curl-while-trying-to-access-an-https-url
Heroku
  1. show last pushes to heroku heroku releases -a hengage-staging
Bundle
  1. capybara webkit build error: thoughtbot/capybara-webkit#846 sudo apt-get install libqt5webkit5-dev, http://stackoverflow.com/questions/23703864/cmake-not-working-could-not-exec-qmake sudo apt-get install qt-sdk
  2. coffee rails error: sudo apt-get install nodejs
Bash
  1. recursively delete all files of a specific extension in the current directory: find . -name "*.lnk" -type f -delete . Show list first: find . -name "*.lnk" -type f
  2. load constants source .env
  3. Show all files (hidden too) with sizes du -sch .[!.]* * |sort -h or find . -maxdepth 1 -mindepth 1 -type d -exec du -hs {} \;
  4. expose localhost to the internet ./ngrok http 3000. result Forwarding http://1170cb30.ngrok.io -> localhost:3000
  5. find pid that uses port 9292 lsof -wni tcp:9292
  6. ls -ltr show list of files with dates sorted by modified date
  7. my internal ip address ip route get 8.8.8.8 | awk '{print $NF; exit}'
  8. open folder in GUI from terminal: gnome-open .
Rails
  1. send dummy mail:
ActionMailer::Base.mail(
  from: "info@tutor24.ch", 
  to: "lucí@hotmail.com <ms@rademade.com>", 
  subject: "Test", 
  body: "Test"
).deliver_later
Docker
  1. cannot stop container permission denied ubuntu:
sudo aa-status
sudo systemctl disable apparmor.service --now
sudo service apparmor teardown
sudo aa-status
docker-compose down
sudo systemctl enable apparmor.service --now

https://forums.docker.com/t/can-not-stop-docker-container-permission-denied-error/41142/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment