Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
😎
losing my sight, losing my mind, go to the general to save some time

Tom Scott tubbo

😎
losing my sight, losing my mind, go to the general to save some time
View GitHub Profile
>> { :hello => "<span>world</span>" }.to_json
=> "{\"hello\":\"\\u003Cspan\\u003Eworld\\u003C/span\\u003E\"}"
# POST /calls
# POST /calls.json
def create
@call = Call.new(params[:call])
@call.user_id = current_user.id
respond_to do |format|
if @call.save
format.html { redirect_to @call, notice: 'Call was successfully created.' }
format.json { render json: @call, status: :created, location: @call }
def tagged
if current_user
@fb_user = FbGraph::User.me(current_user.fb_token)
@photos_of_you = @fb_user.photos({"limit" => "0"})
@count = @photos_of_you.count
end
render :layout => false
end
respond_to :html, :js
def destroy
@student = User.find(params[:id])
if @student.destroy
render json: { student: @student, student_id: dom_id(@student) }
else
render nothing: true
end
@tubbo
tubbo / macvim_drawer.rb
Created July 9, 2012 12:56
macvim-drawer homebrew formula
require 'formula'
class MacvimDrawer < Formula
homepage 'https://github.com/alloy/macvim'
head 'git://github.com/alloy/macvim.git', :branch => 'split-browser'
def options
[
# Building custom icons fails for many users, so off by default.
["--custom-icons", "Try to generate custom document icons."],
@tubbo
tubbo / _form.html.erb
Created July 11, 2012 14:55 — forked from kunalchaudhari/_form.html.erb
i am using forem gem and i have post model decorator. i would like to make the post taggable and using the act-as-taggable-on gem. but it giving me error that tag_list method is undefine. when i do post = Forem.Post.new and post.tag_list = 'tag1 tag2' in
<%= f.input :text %>
<%= f.input :tag_list %>
<% if params[:reply_to_id] %>
<%= f.hidden_field :reply_to_id, :value => params[:reply_to_id] %>
<% end %>
@tubbo
tubbo / controller.rb
Created July 16, 2012 17:24 — forked from karapetyan/example_from_book
Mass-assigment attr_accessable
class UsersController < ApplicationController
respond_with :html
def create
@user = User.new(params[:user])
if @user.save
respond_with [:admin, @user], notice: "User succesfully created!"
else
redirect_to 'admin/users/new', alert: "User was not created: #{@user.errors.full_messages.join(',')}"
end
@tubbo
tubbo / page.html
Created September 17, 2012 20:04 — forked from JohnBat26/gist:3739436
<div class="span2">
<ul class="nav nav-list well">
<li class="nav-header">Главное меню</li>
<li class="active simple-navigation-active-leaf">
<a href="/tsp/organizations?locale=ru" class="active">Организации</a></li>
<li><a href="/tsp/content/conferences?locale=ru">Конференции</a></li>
<li><a href="/tsp?locale=ru">Мой профиль</a></li>
<li class="nav-header">Система</li>
<li> <a href="/tsp/scheduler?locale=ru">Очередь заданий</a></li>
<li><a href="/tsp/admin?locale=ru">База данных</a></li></ul>
var groupSelect = $('#user_group_id'),
groupSelectField = $('.field.group-select');
groupSelect.children().first().after($('<option></option>').attr('value', 'new').text('<%= t("form.user.new_group") %>'));
groupSelectField.children().last().after($('<form></form>').attr('class', 'inner-form'));
var innerForm = $('.inner-form');
@tubbo
tubbo / user_delivery_agent.rb
Created October 17, 2012 13:33 — forked from shakthimaan/Error
UsersController
class UserDeliveryAgent
def initialize(email)
@email = email
end
def deliver!
if @email.present?
puts "Email: #{@email}"
true
else