Command(s) | Description |
---|---|
o and O |
insert new line below and above respectively. |
dd |
delete current line |
x |
delete highlighted character |
shift+x |
delete character to left |
dw |
delete a word |
de |
delete to end of word |
/ |
to search, then n or N to go forward and back in results |
This file contains 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
# XCode 5 hides these away: | |
export C_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include" | |
export CPLUS_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include" | |
export LIBRARY_PATH="$(xcrun --show-sdk-path)/usr/lib:$(xcrun --show-sdk-path)/usr/lib/system:$LIBRARY_PATH" | |
and then you can do rbenv install |
This file contains 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
# t1 and t2 are Time objects | |
# t is a class with attributes hours, minutes, and seconds | |
diff = t2 - t1 | |
%w(hours minutes seconds).each do |duration| | |
diff -= (t.send("#{duration}=", (diff / 1.send(duration)).round)).send(duration) | |
end |
This file contains 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
epsilon = .000001 | |
x1 and x2 are equal if (fabs(x1 - x2) < epsilon) |
This file contains 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
Toast.makeText(getActivity().getApplicationContext(), "in onResume", | |
Toast.LENGTH_LONG).show(); |
This file contains 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
// formatting numbers | |
// => "1.2" | |
String.format("%s", new DecimalFormat("#.##").format(1.2)) | |
// => "1.20" | |
String.format("%.2f", 1.2) |
This file contains 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 Post < ActiveRecord::Base | |
has_many :post_tags | |
has_many :tags, through: :post_tags | |
end |
This file contains 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
import Foundation | |
let config = NSURLSessionConfiguration.defaultSessionConfiguration() | |
let userPasswordString = "username@gmail.com:password" | |
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding) | |
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil) | |
let authString = "Basic \(base64EncodedCredential)" | |
config.HTTPAdditionalHeaders = ["Authorization" : authString] | |
let session = NSURLSession(configuration: config) |
This file contains 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
## One way to do it is from the rails console: | |
require 'db/migrate/MIGRATION_FILE_NAME.rb' | |
# if using def change | |
MigrationClass.new.migrate(:down) | |
# if using up or down | |
MigrationClass.up | |
## Another way is using a rake task |
Bash inside of ubuntu image
docker run -it -v /Users:/Users ubuntu bash
On boot
boot2docker up