shell Best way to make a shell script daemon? I wanted to run a shell script as a daemon, and I was exploring SO as usual, and one of the answers that I found interesting and that fits my use case was: (./install.sh &) & Ref: to the original question here [http://stackoverflow.com/questions/3430330/best-way-to-make-a-shell-script-daemon] .
postgres Postgresql: How to find pg_hba.conf file using Mac OS X To find the postgresql config file we can use the locate command. Type the following in your terminal: locate pg_hba.conf Or else: If you have a postgres server running on your machine, you can find the config directory using the following command ps aux | grep postgres which would
postgres Dump PostgreSQL without owner and privileges If you ever wanted to dump your postgres development database without the owner and the privileges, then you just need to run the following command: pg_dump database_name -O -x > output_file
phoenix Start Phoenix app with cowboy server on different port To run phoenix app on a custom port other than port 4000, tweak your config file for respective environment(dev/prod/test) to the following: config :my_app, MyApp.Endpoint, http: [port: {:system, "PORT"}], Then from the terminal: $ PORT=4001 mix phoenix.server $ PORT=4002 mix phoenix.server Enjoy.!
ruby Problem installing puma on OS X with openssl When installing puma on OSX 10.11 El Capitan, if you are facing issues compiling mini_ssl.c fatal error: 'openssl/bio.h' file not found. all you need to do is to specify --with-opt-dir You can make this applicable for all your Gemfiles: bundle config build.puma --with-opt-dir=/usr/
mac Run Multiple Skype clients on Mac OS X? Just run the following command in terminal: open -na /Applications/Skype.app --args -DataPath /Users/$(whoami)/Library/Application\ Support/Skype2
rails Creating tables and problems with primary key in Rails If you run into the following error when running a migration in your legacy Rails app with MySQL 5.7 or above rake aborted! "Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL:" the fix is by monkey patching the MySQL Adapter using the following code. # lib/
git Easy way pull latest of all git-submodules Often large projects have dependencies on many other 3rd party libraries. Each library can be a separate repo that can be brought into the dependant project as a submodule. During development, if ever you want to just go grab the latest version of every dependant submodule, type in the following
ubuntu Hibernate not working 15.04 To know your swap partition, run swapon -s. Let's say it reports /dev/sda5. Open /etc/default/grub and find the line with GRUB_CMDLINE_LINUX_DEFAULT=. This is the list of kernel command line options GRUB will pass to Linux. Add resume=/dev/sda5, so the line GRUB_CMDLINE_
ruby Pundit for authorization with Rspec Rails Authorization is one of the important feature of any web app. With rails you can leverage the power of all those wonderful open source gems that are available to you or you can code your own authorization module. The most commonly used gems for authorization are Pundit [http://github.com/
meteor Manually insert users from seed file with accounts-password One of the easiest way to seed users/admin-user into the system is by running the following on the server when it starts: Meteor.startup(function() { if (Meteor.users.find().count() === 0) { Accounts.createUser({ username: 'test', email: '[email protected]', password: 'password' }); } });
postgres Postgres could not connect to server $ psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? The reason for the issue is because a pid file was blocking postgres from starting up. To fix it: rm /usr/local/
ruby Ruby: delete multiple hash keys Returns a hash that includes everything but the given keys. hash = { a: true, b: false, c: nil} hash.except(:c) # => { a: true, b: false} hash # => { a: true, b: false, c: nil} This is useful for limiting a set of parameters to everything but a few known toggles: @person.update(params[
git “bin/rails: No such file or directory” w/ Ruby 2 & Rails 4 on Heroku Rails apps with version 4 or above has some files under the bin folder namely bundle, rails, rake, setup, spring. But since I had bin folder gitignored, these files dint make it to heroku. To fix this: Remove bin from ~/.gitignore Run bundle install or rake rails:update:bin Commit
shell SET GOPATH environment variable on Ubuntu? Just add the following lines to ~/.bashrc export GOROOT=/usr/lib/go export GOPATH=$HOME/go export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
ruby Calling View helper methods from Controller / Model in Rails Recently I was researching a way to use link_to inside my Rails 3 controller, and learned about the method view_context. So if you ever want to access view helper methods from controller / models in rails 3 you have to use view_context method. Example view_context.link_to
til Email notification when someone logs in via SSH To setup email notification, login to your server as root. Edit .bashrc vim .bashrc add the following line at the end, changing "ServerName" to the host-name of your server and "[email protected]" to your own email address. echo 'ALERT - Root Shell Access (Server-name) on:' `date` `who` | mail
til How do I make --no-ri --no-rdoc the default for gem install? If you are deploying to a server, or you do not want to wait around for rdoc and ri to install for each gem, you can disable them for gem installs and updates. Just add the following line to your ~/.gemrc or /etc/gemrc: gem: --no-rdoc --no-ri or gem: --no-document
til How to update git remotes To list the existing remotes, we can use the following command: git remote -v #View existing remotes origin https://github.com/user/repo.git (fetch) origin https://github.com/user/repo.git (push) Use the following command to set the remote to a new end point. git remote set-url origin