Skip to content

Instantly share code, notes, and snippets.

View czepluch's full-sized avatar

Jacob Stenum Czepluch czepluch

  • epoch73
  • Copenhagen, Denmark
View GitHub Profile
@czepluch
czepluch / photos.rb
Created November 15, 2012 22:08
File not assigned
#/model/user.rb
attr_accessible :name, :first_name, :last_name, :email, :password, :password_confirmation, :remember_me,
:provider, :uid, :photos_attributes
has_many :photos
accepts_nested_attributes_for :photos
#/model/photo.rb
class Photo < ActiveRecord::Base
event=button.fnf1 FNF1
action=/etc/acpi/actions/toggle-touchpad.sh "%e"
<a href="#" data-dropdown="drop" class="button dropdown">Dropdown Button</a><br>
<ul id="drop" data-dropdown-content class="f-dropdown">
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
@czepluch
czepluch / application.html.haml
Created December 9, 2013 23:47
Can anyone tell me why the dropdown button menu does not show?
!!! 5
%html{:lang => "en"}
%head
%meta{:charset => "utf-8"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"}
%title
=content_for?(:title) ? yield(:title) : "Analuk"
= stylesheet_link_tag "application"
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<title>
Analuk
</title>
<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" />
class PostsController < ApplicationController
before_filter :authenticate_user!
def new
@post = Post.new
end
def create
@user = User.find(params[:user_id])
<% if current_user == @user %>
<h2>Tilføj et indlæg:</h2>
<%= simple_form_for([@user, @user.posts.build], :html => { :class => 'form-horizontal'}) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :title, :required => true, :autofocus => true %>
<%= f.input :description, :required => true %>
<%= f.input :location, :required => true %>
<%= f.input :photo %>
@czepluch
czepluch / _post.html.erb
Last active January 2, 2016 10:49
Autocompletion does not work. I have followed every step in this guide https://github.com/ankane/searchkick, but no luck.
# views/posts/_post.html.erb
<% @posts.sort_by(&:created_at).reverse.each do |p| %>
<div class="panel panel-default">
......
</div>
<% end %>
I want to sort the data by uid(this set only has one uid), and then be able to choose only to get answers or questions grouped by uid.
[#<Response id: 37, question: "Region", answer: "Other Asian country", date: "2015-02-04", count: nil, created_at: "2015-02-04 12:39:34", updated_at: "2015-02-04 12:39:34", uid: "1423053574502", quiz_id: 1>, #<Response id: 38, question: "Profession", answer: "Neurologist", date: "2015-02-04", count: nil, created_at: "2015-02-04 12:39:34", updated_at: "2015-02-04 12:39:34", uid: "1423053574502", quiz_id: 1>, #<Response id: 39, question: "Experience with increased L-dopa dose/frequency cau...", answer: "Yes", date: "2015-02-04", count: nil, created_at: "2015-02-04 12:39:34", updated_at: "2015-02-04 12:39:34", uid: "1423053574502", quiz_id: 1>, #<Response id: 40, question: "Azilect's perceived efficacy compared to entacapone...", answer: "Less efficacious", date: "2015-02-04", count: nil, created_at: "2015-02-04 12:39:34", updated_at: "2015-02-04 12:39:34", uid: "1423053574502"
@quiz.responses.group(:uid).all.each {|uid, responses| puts "hello i'm #{uid} and my first response was: "}
=> [#<Response id: 46, question: "Region", answer: "South Korea", date: "2015-02-04", count: nil, created_at: "2015-02-04 12:42:03", updated_at: "2015-02-04 12:42:03", uid: "1423053723649", quiz_id: 3>, #<Response id: 55, question: "Region", answer: "Other Asian country", date: "2015-02-04", count: nil, created_at: "2015-02-04 12:43:40", updated_at: "2015-02-04 12:43:40", uid: "1423053820457", quiz_id: 3>, #<Response id: 73, question: "Region", answer: "Hong Kong", date: "2015-02-16", count: nil, created_at: "2015-02-16 13:31:47", updated_at: "2015-02-16 13:31:47", uid: "1424093507276", quiz_id: 3>]