Skip to content

Instantly share code, notes, and snippets.

<% @content.medias.build({:key=>"original"}) %>
<%= form_for(@content, :html => { :multipart => true }) do |f| %>
<div class="field">
<%= f.fields_for :medias do |media| %>
<%= media.file_field :file %>
<%= media.hidden_field :key %>
<% end %>
</div>
<div class="actions">
@bamnet
bamnet / sample.html.erb
Created August 17, 2010 22:02
Concerto 2 HTML5 Markup Examples
<section class="C-full lg">
<header>
<%= back_button "#" %>
<h1>New Screen</h1>
</header>
<div class="C-cont">
<article>
<%= render 'form' %>
</article>
<aside>
icons = Hash.new
@vehicles.each do |v|
if !v.latest_position.nil?
icon = v.icon_id || 0
heading = v.latest_position.heading
if icons.has_key?(icon)
if icons[icon].has_key?(heading)
icons[icon][heading].push(v)
else
icons[icon][heading] = [v]
$("#ul.checkboxlist").find("input[type='checkbox']").live('click', function(){
// something to update the invoice here
console.log($(this).val()); //Should have the value of the checkbox that was clicked
});
@bamnet
bamnet / merge.js
Created November 9, 2011 05:32
Merge objects with combined keys
// Each table is an array [] of objects.
// Object MUST have all keys.
// Objects with matching keys will be merged into one object.
function merge(table1, table2){
keys = ['key', 'note'];
var merged = table1;
for(i in merged){
var obj1 = merged[i];
for(j in table2){
var obj2 = table2[j];
# Get level name of a membership
def level_name
name = (Membership::LEVELS.respond_to?(:key) ? Membership::LEVELS.key(level) : Membership::LEVELS.index(level))
name.to_s.humanize
end
<VirtualHost *:80>
ServerName istaylorswiftsingle.com
DocumentRoot /var/www/istaylorswiftsingle
<Directory /var/www/istaylorswiftsingle>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "Ei02NS05OSBQYXVsIEFtaWNvIFdheSwgU2VjYXVjdXMsIE5KIDA3MDk0LCBVU0E",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJFziVmP33wokRRu0dx8XBfUE",
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "101 Plaza Center, Secaucus, NJ 07094, United States",
"geometry" : {
"location" : {
"lat" : 40.79164149999999,
"lng" : -74.0568873
},
<style id="jsbin-css">
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;