This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AddColumnUsersIsAdmin < ActiveRecord::Migration | |
| def change | |
| add_column :users, :is_admin, :boolean, null: false, default: false | |
| end | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git diff --name-only HEAD | grep -e \.rb$ | xargs -n 1 rubocop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| strace -e pattern command #match pattern, don't pipe to grep because strace prints to stderr | |
| strace -e open man cat 2> strace.txt #filter open calls and save to strace.txt (via stderr) | |
| strace -p pid #attach to running process | |
| strace -f #also strace child processes | |
| strace -c #show histogram table of num calls | |
| strace -f -e trace=network curl google.com #networrk calls (parent and child processes) | |
| strace -f -e trace=network -s 100 curl google.com #limit string args to 100 chars |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "enter command: " | |
| read command | |
| if [ "$command" = "kill humans" ] | |
| then | |
| echo "I can't do that. These are great humans, I'm not gonna... these are fantastic humans" | |
| elif [ "$command" = "do stuff" ] | |
| then | |
| echo "I'm doing the best kind of stuff. Best stuff. It'll be great stuff" | |
| elif [ "$command" = "save yourself!" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AddTableUsers < ActiveRecord::Migration | |
| phase :post_deploy | |
| disable_ddl_transaction! | |
| def change | |
| add_index :users, :is_admin, algorithm: :concurrently | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| grep -rnw . -e "pattern" recursive,line #s, whole word - all lines with pattern in all files | |
| grep -ril . -e "pattern" recursive,ignore case,files names instead of lines - file name for files containing pattern | |
| --include "*glob*" | |
| --exclude "*glob*" | |
| -h no file name | |
| -o only matching part (no whitespace) | |
| grep -Fq #fixed string, not regex, quiet, do not print anything | |
| grep -Fq 'ERROR' log.txt #return true if any line in the file contains ERROR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CreateProducts < ActiveRecord::Migration[5.0] | |
| def change | |
| create_table :products do |t| | |
| t.string :name | |
| t.text :description | |
| t.timestamps | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var groceries = { | |
| "bread": 5.45 | |
| "milk": 3.50 | |
| "cheese": 6.23 | |
| "avocados": 2.50 | |
| } | |
| groceries["milk"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT * | |
| FROM foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AddTableUsers < ActiveRecord::Migration | |
| def up | |
| add_column: :users, :admin, default: false | |
| end | |
| def down | |
| remove_column :users, :admin | |
| end |