Skip to content

Instantly share code, notes, and snippets.

View adammcarth's full-sized avatar

Adam McArthur adammcarth

View GitHub Profile
class UserSession < Authlogic::Session::Base
def remember_me_for
3.months
end
end
@adammcarth
adammcarth / edit.html.erb
Last active December 10, 2015 00:38
NoMethodError - Ruby on Rails
<!-- Someone can visit http://localhost:3000/profiles/my-permalink and this page will display (this part is working fine!). -->
<h2>Edit your profile, <%= @user.first_name %>.</h2>
<%= form_for @user, :html => { :class => "form-horizontal"} do |f| %>
<%= f.label :first_name, "Your First Name" %>
<%= f.text_field :first_name %>
<%= f.submit "Update Profile" %>
<% end %>
module.exports = function(server) {
var request = require("supertest");
it("[GET] /", function(done) {
request(server).get("/").expect(200, done);
});
it("[GET] /posts", function(done) {
request(server).get("/posts").expect(200, done);
});
apache:
install: '1'
settings:
user: www-data
group: www-data
default_vhost: true
manage_user: false
manage_group: false
sendfile: 0
modules:
gulp.task("concat:js", function() {
// Loop through each JS collection and run a seperate concat task
Object.keys(collections.js).forEach(function(name) {
gulp.src(collections.js[name])
.pipe(concatJS("collections/" + name + ".js"))
.pipe(gulp.dest(paths.dest.javascript));
});
});
var gulp = require("gulp");
var collections = require("./collections");
gulp.task("concat-css", function() {
Object.keys(collections).forEach(function(name) {
gulp.src(collections[name])
.pipe(plugins.concatCSS("collections/" + name + ".css"))
.pipe(gulp.dest("assets/stylesheets"));
});
});
# Save the answer into a variable called 'num'.
num = input("How many underscores do you want, yo?: ")
# Multiply "_" by the amount specified before...
underscores = "_" * int(num)
# Print out the smiley face!
print("^" + underscores + "^")
@adammcarth
adammcarth / deploy.sh
Created February 20, 2015 14:15
Deploys code from a GitHub repository to an ec2 instance (or any linux-based VPS).
#!/usr/bin/env bash
source ~/.rvm/scripts/rvm
rvm use
#`deploy.sh` v0.0.1 by Adam McArthur.
# Deploys code from a GitHub repository to an ec2 instance.
# It is reccommended that the current user can use "sudo" without a password [you might need to use sudo from inside this script],
# See: http://askubuntu.com/questions/235084/how-do-i-remove-ubuntus-password-requirement#answer-235088
##### SETTINGS [Change Me] #####
#!/usr/bin/env sh
source ~/.rvm/scripts/rvm
rvm use 2.2.0
app_name="App"
apps_dir="/var/www"
github_username="adammcarth"
git_repo="filthy_parrot"
app_install_commands="bundle install"
function truncate(string, words) {
var max_chars = 6 * parseInt(words);
var words_array = string.split(" ");
var index = parseInt(words) - 1;
var truncated = words_array.slice(0, index).join(" ");
if ( truncated.length > max_chars ) {
truncated = string.slice(0, max_chars) + "...";
} else if ( truncated === string ) {
truncated = string;