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
# To check if a directory exists in a shell script you can use the following: | |
if [ -d "$DIRECTORY" ]; then | |
# Control will enter here if $DIRECTORY exists. | |
fi | |
#Or to check if a directory doesn't exist: | |
if [ ! -d "$DIRECTORY" ]; then |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
del %windir%\system32\spool\printers\* | |
net stop spooler | |
net start spooler |
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
git push origin --delete <branch-name> |
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
# in excel: file->import->CSV file | |
require 'csv' | |
# write csv | |
CSV.open("file.csv", "wb") do |csv| | |
csv << ["row", "of", "CSV", "data"] | |
csv << ["another", "row"] | |
# ... | |
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
require 'csv' | |
csv_text = File.read('filename.csv') | |
csv = CSV.parse(csv_text, :headers => true) | |
csv.each do |row| | |
Model.create!(row.to_hash) | |
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
-- FOR MySQL -disable safemode | |
SET SQL_SAFE_UPDATES = 0; | |
-- for example remove all older than '2014-10-01' | |
DELETE FROM `base-name`.`table-name` WHERE `table-name`.`date-field` < '2014-10-01'; |
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
directory_name = "name" | |
Dir.mkdir(directory_name) unless File.exists?(directory_name) | |
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
require 'yaml' | |
$db_file = 'filename.yaml' | |
def load_data | |
text = File.read 'db.yaml' | |
return YAML.load text | |
end | |
def store_data hash |
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
The argument mode points to a string beginning with one of the following | |
sequences (Additional characters may follow these sequences.): | |
``r'' Open text file for reading. The stream is positioned at the | |
beginning of the file. | |
``r+'' Open for reading and writing. The stream is positioned at the | |
beginning of the file. | |
``w'' Truncate file to zero length or create text file for writing. |
OlderNewer