Skip to content

Instantly share code, notes, and snippets.

View minikomi's full-sized avatar
🍕
I like pizza

Adam Moore minikomi

🍕
I like pizza
View GitHub Profile
@minikomi
minikomi / gist:629601
Created October 16, 2010 09:04
Get products in same categories
<% @taxons = @product.taxons
@taxons.find(:all).each do |a|
Product.in_taxons(a).each do |product|
%>
<p>
<%= product.name %>
</p>
<% end %>
<% end %>
var add_image_handlers = function() {
$('ul.thumbnails li').eq(0).addClass('selected');
$('ul.thumbnails li a').click(function() {
$("#main-image").data('selectedThumb', $(this).attr('href'));
$('ul.thumbnails li').removeClass('selected');
$(this).parent('li').addClass('selected');
return false;
}).hover(
function() {
require "sinatra"
require "coffee-script"
get '/js/:scriptname' do
coffee params[:scriptname].intern
end
get "/" do
"<script src='/js/test'></script>"
end
@minikomi
minikomi / gist:924979
Created April 18, 2011 08:18
Redirection for unfound assets to dropbox for padrino
error 404 do
link = "http://dl.dropbox.com/u/#{dropboxid}/#{public_folder}"+request.path_info
uri = URI.parse(link)
response = nil
Net::HTTP.start(uri.host, uri.port) { |http|
response = http.head(uri.path.size > 0 ? uri.path : "/")}
if response.code == "200"
redirect link
else
redirect '/' #any place you like, can be 404 page.
フレームワークを作る。
s - "script"
d - "database"
e - "template"
c - "css"
padrino g project blog -s jquery -d activerecord -e haml -c sass
cd blog
bundle install
$(document).ready ->
###
place-holder for animation loop
###
animate = ""
###
set canvas to a variable
###
canvas = document.getElementById("canvas")
@minikomi
minikomi / gist:1094800
Created July 20, 2011 11:34 — forked from jsmpereira/gist:1094024
Padrino pagination
#
# Adapted from http://pastebin.com/FL5KeQQH
#
# As mentioned on the link above put this on app/helpers/pagination.rb
# and you can use in your view
#
# =will_paginate @posts
#
# I'm also using this https://gist.github.com/837683
#
@minikomi
minikomi / _map.html.haml
Created July 26, 2011 08:46
Rough google maps partial
#map_canvas{:style=>"width: 400px; height: 400px"}
%script{:type => "text/javascript", :src=>"http://maps.google.com/maps/api/js?sensor=false"}
= javascript_include_tag 'map'
:javascript
$(document).ready(function(){mappit("#{address}")});
@minikomi
minikomi / _map.html.haml
Created July 26, 2011 08:50
Rough google maps partial
#map_canvas{:style=>"width: 400px; height: 400px"}
%script{:type => "text/javascript", :src=>"http://maps.google.com/maps/api/js?sensor=false"}
= javascript_include_tag 'map'
:javascript
$(document).ready(function(){mappit("#{address}")});
@minikomi
minikomi / gist:1146043
Created August 15, 2011 11:06
sql from sales => prefectures (unique)
request:
@sales = Sale.includes([{:shop => :prefecture},:brands])
.order('finish DESC').where("finish > ?", Date.today)
.joins(:shop => { :city => :prefecture })
.select('sales.*, DISTINCT prefecture.id')
"Sale Load (62.0ms) SELECT "sales"."id" AS t0_r0, "sales"."title" AS t0_r1, "sales"."description"
AS t0_r2, "sales"."invite" AS t0_r3, "sales"."shop_id" AS t0_r4, "sales"."start" AS t0_r5, "sales"."finish"
AS t0_r6, "sales"."created_at" AS t0_r7, "sales"."updated_at" AS t0_r8, "shops"."id" AS t1_r0, "shops"."name"