Skip to content

Instantly share code, notes, and snippets.

View universal's full-sized avatar

Johannes / universa1 universal

View GitHub Profile
@universal
universal / questionnaires.rb
Created November 25, 2012 16:29
custom table rows for active admin
ActiveAdmin.register Questionnaire do
index do
column :id do |questionnaire|
link_to questionnaire.id, admin_questionnaire_path(questionnaire)
end
column :title do |questionnaire|
link_to questionnaire.title, admin_questionnaire_path(questionnaire)
end
column :csv_export do |questionnaire|
link_to "CSV Export", csv_export_admin_questionnaire_path(questionnaire, :format => :csv)
@universal
universal / link_to.html.erb
Created February 13, 2013 09:34
link_to example
/* line 44, ../../app/assets/stylesheets/application.css.scss */
.blibla, .bliblablub {
background: black;
}
/* line 48, ../../app/assets/stylesheets/application.css.scss */
.bliblablub {
color: white;
}
s_full = "South"
tests = [
["Some text with S", "S", "South", "Some text with South"],
["Some text with S/wrong", "S/wrong", "Something wrong", "Some text with Something wrong"],
["Some text with S/wrong", "S", "South", "Some text with S/wrong"]
]
def match(where, what, replace)
where.gsub(/\b#{Regexp.quote(what)}(\s|\z|$)/, replace + '\1')
end
#!/bin/bash
# Favicon and Apple Touch Icon Generator
#
# This bash script takes an image as a parameter, and uses ImageMagick to convert it to several
# other formats used on modern websites. The following copies are generated:
#
# * apple-touch-icon-114x114-precomposed.png
# * apple-touch-icon-57x57-precomposed.png
# * apple-touch-icon-72x72-precomposed.png
@universal
universal / signed_params_helper.rb
Last active December 15, 2015 12:09
signed params helper for rspec
module SignedParamsHelper
def signed_params!
controller(described_class) { before_filter { params.permit! } }
end
end
describe UsersController
controller(UsersController) do
before_filter :permit_all_params!
def permit_all_params!
params.permit!
end
end
end
public class MyClass
{
public static void main(String args[])
{
System.out.println("Hello World".hashCode());
}
}
=> -862545276
@universal
universal / quote.txt
Last active December 16, 2015 13:39
two cats - problem descriptions
I have two cats. One of them is black, the other is white. Both are fine, but when someone tries to feed the white one the black one will suddenly burst into flames". Can you see the reason for the cat incineration? Neither can we see the reason for your error, since we have no idea about your {insert your language/framework here} cats. Add code, provide a short example.
<p>
<b>Comment:</b>
<%= comment.body %>
</p>
<p>
<%= link_to 'Destroy Comment', [comment.post, comment],
:confirm => 'Are you sure?',
:method => :delete %>
</p>