Skip to content

Instantly share code, notes, and snippets.

@evan-007
evan-007 / twet.rb
Last active January 1, 2016 21:49
@username to links
<div class="clearfix top-space small"></div>
<div class="row">
<%= render :partial => 'shared/left_nav' %>
<div class="panel panel-default col-md-8 text-left">
<div class="pull-left">
<h4>Twets</h4>
</div>
<div class="clearfix"></div>
require 'nokogiri'
require 'open-uri'
puts "Enter a word"
@word = gets.chomp!
@key = 'api-key-goes-here'
@type = 'learner'
page = Nokogiri::XML(open("http://www.dictionaryapi.com/api/v1/references/#{@type}/xml/#{@word}?key=#{@key}"))
#!/usr/bin/env ruby
require 'koala' # gem install koala --no-ri --no-rdoc
# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "groups", "photos" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
group_filtering_words = ['ruby']
image_path = 'image.png' #change to your image path
message = 'My Cool image.' # your message
@evan-007
evan-007 / Gemfile
Created March 31, 2014 22:14 — forked from jancel/Gemfile
source 'https://rubygems.org'
gem 'rails', "3.2.10"
# omitted
group :stage, :production do
gem 'pg'
gem 'unicorn'
end
@evan-007
evan-007 / gist:3637b27dbc28952b06bf
Created May 16, 2014 12:38
Angular on Rails book possible issues
page 34:
refactoring into a partial isn't explicitly mentioned. Maybe mention that if you just drop the block on page 34 into the existing ```dashboard.html```, then the submit button needs to have params passed into it:
<input type="submit" class="btn btn-sm btn-primary" ng-click="showShareBox=!showShareBox;share(recipient, article)"
ng-disabled="shareForm.$invalid" value="Share">
Page 36
Earlier in the book, the routes namespace resources :shares under :api. The controller needs to be created in app/controllers/api/shares_controller.rb, right? Otherwise throws uninitialized constant API error. FYI, sample app does not namespace this controller/route, contrary to the book.
//code school approach
app.controller('LibraryController', function(){
this.books = getBooks //some function that gets an array
});
//in the view
<div ng-controller="LibraryController as libraryCtrl">
<ul>
Angular form post
Started PUT "/api/v1/articles/3" for 127.0.0.1 at 2014-06-02 07:18:52 +0900
Processing by Api::V1::ArticlesController#update as HTML
Parameters: {"title"=>"puy98y89y", "body"=>"asdfasdfsdfds\nkjlj", "id"=>"3", "categories"=>[{"name"=>"OOP", "id"=>6}], "category_ids"=>[2, 3, 4], "article"=>{"id"=>"3", "title"=>"puy98y89y", "body"=>"asdfasdfsdfds\nkjlj"}}
form:
<form name="newArticleForm" ng-submit="newArticleForm.$valid && postArticle(activeArticle)" novalidate>
<label>Article Title</label>
lrwxr-xr-x 1 evan admin 36 Jun 14 18:09 gulp -> ../lib/node_modules/gulp/bin/gulp.js
$ which gulp
/usr/local/bin/gulp
$ gulp
[18:22:17] Local gulp not found in ~/thinkful_projects/angular/unit2/angular-weather-app
[18:22:17] Try running: npm install gulp
$ npm install gulp
.factory('owmNearby', ['owmRequest', '$interpolate', 'OWM_LAT_LNG_PATH',
function(owmRequest, $interpolate, OWM_LAT_LNG_PATH) {
return function(lat, lng) {
var path = $interpolate(OWM_LAT_LNG_PATH)({
lat : lat,
lng : lng
});
return owmRequest(path);
}
}])
@evan-007
evan-007 / gist:38c70da8a3dd6b856940
Last active August 29, 2015 14:02
f-f-ff-factory
//factory returns entire API response, controller is responsible for parsing the return value
.factory('CapitalData', function(API_AUTH, $http, $q, SEARCH_PATH){
return function(countryId, capital){
var defer = $q.defer();
$http.get(SEARCH_PATH+'&name_equals='+capital+'&country='+countryId+API_AUTH)
.success(function(data){
defer.resolve(data);
});
return defer.promise;