$ rails g model User
belongs_to
has_one
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
#!/bin/bash | |
$PARENTDIR = 'parent_dir here' | |
#Get a list of dirs/files in parent directory, pipe to egrep and select only directories then pipe to awk to get the 9th field (directory name). Check your shell to make sure $9 is actually the directory name | |
DIRS=`ls -l $MYDIR | egrep '^d'`| | awk '{print $9}' | |
# Loop through our directories |
#!/bin/bash | |
provider=virtualbox | |
# Loop over boxes | |
for box in ~/.vagrant.d/boxes/*; do | |
# Create provider directory to contain files | |
mkdir $box/$provider/ |
Useful One-Line Scripts for Perl Jan 28 2012 | version 1.08 | |
-------------------------------- ----------- ------------ | |
Compiled by Peteris Krumins (peter@catonmat.net, @pkrumins on Twitter) | |
http://www.catonmat.net -- good coders code, great reuse | |
Latest version of this file is always at: | |
http://www.catonmat.net/download/perl1line.txt |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Basic HTML5 Template</title> | |
<link href="stylesheets/style.css" rel="stylesheet" type="text/css" media="screen" /> | |
<script src="example.js"></script> | |
</head> | |
<body> |
File.open "file.json", "w+" do |file| | |
file.puts Hash.to_json | |
end | |
#This writes a whole string to a file (string is the output of method mypage.makePage) | |
File.open("/Users/sebastianzeki/Desktop/MyRubyHTML.html", 'w') { |file| file.write(mypage.makePage)} | |
File.open("/path/to/file").each { |line| | |
puts line | |
} |
RUBY! | |
n.b. Class/module index at lower left in ruby-doc explanation pages (cf. Time, Math, etc.) | |
****************************************************************************************** | |
http://ruby-doc.org/core-2.1.2/ | |
Searchable list of methods | |
http://ruby-doc.org/core-2.1.2/String.html |
#A truck load of code snippets | |
#################################################################################################################################################################################### | |
#################################################################################################################################################################################### | |
#################################################################################################################################################################################### | |
################################################ System tasks ###################################################################################################################### | |
#################################################################################################################################################################################### | |
################################################################################### |
R to python useful data wrangling snippets | |
The dplyr package in R makes data wrangling significantly easier. | |
The beauty of dplyr is that, by design, the options available are limited. | |
Specifically, a set of key verbs form the core of the package. | |
Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. | |
Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. | |
The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package). | |
dplyr is organised around six key verbs |