Skip to content

Instantly share code, notes, and snippets.

View SoldierCoder's full-sized avatar
💭
learning stuff

Ed Drain SoldierCoder

💭
learning stuff
View GitHub Profile
class TagsTasks < ActiveRecord::Migration
def change
create_table :tags_tasks, id: false do |t|
t.belongs_to :tasks, index: true
t.belongs_to :tags, index: true
end
end
end
class HumansController < ApplicationController
def create
human = Human.new(human_params)
if human.save
render json: human, status: 201, location: human
end
end
private
app.controller('PanelController', function() {
this.items = badges;
this.tab = 1;
this.selectTab = function(setTab) {
this.tab = setTab;
};
this.isSelected = function(checkTab) {
return this.tab === checkTab;
@SoldierCoder
SoldierCoder / controller
Last active August 29, 2015 14:05
Brute force -- embedded panel names
app.controller('PanelController', function() {
this.items = badges;
this.tab = 1;
this.selectTab = function(setTab) {
this.tab = setTab;
};
this.isSelected = function(checkTab) {
return this.tab === checkTab;
<section ng-controller="PanelController as panel">
<ul class="nav nav-pills">
<li ng-class="{ active: panel.isSelected(1) }">
<a href="" ng-click="panel.selectTab(1)">Angular</a>
</li>
<li ng-class="{ active: panel.isSelected(2) }">
<a href="" ng-click="panel.selectTab(2)">Rails 3.2-4.0</a>
</li>
<li ng-class="{ active: panel.isSelected(3) }">
<a href="" ng-click="panel.selectTab(3)">RSpec for Rails</a>
which gem
gem () {
typeset result
(
typeset rvmrc
rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc")
if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_
prefix}/.rvmrc" ]]
then
rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc")
gem install slim
Fetching: slim-2.0.2.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
@SoldierCoder
SoldierCoder / gist:5342893
Created April 9, 2013 04:12
My first attempt at trying to get the links from groups page.
require 'rubygems'
require 'mechanize'
require 'pry'
agent = Mechanize.new
page = agent.get('http://www.facebook.com/ed.drain')
page = agent.page.link_with(:href => 'https://www.facebook.com/bookmarks/groups#').click
agent.page.link_with(:href => 'https://www.facebook.com/bookmarks/groups')
page.links.each do |link|
puts link.text
@SoldierCoder
SoldierCoder / gist:4685583
Created January 31, 2013 19:19
I went a little crazy and through lambdas in the mix
def create_a_line(n)
b = f = ""
print_number = true
fizz_or_buzz = lambda {|n, mod_by| (n%mod_by==0) ? true : false }
if fizz_or_buzz.call n, 5
b="Buzz"
print_number = false
end
@SoldierCoder
SoldierCoder / gist:1879177
Created February 21, 2012 21:44
whats wrong with this example?
# spec/models/user_spec.rb
require 'spec_helper'
# I already KNOW I have user with id of 2 and uid of '26954221' and screen_name of 'SoldierCoder'
# these tests all fail. Why?
describe User do
it 'should get the UID' do
@ed = User.find(2)
@ed.uid.should == '26954221'