Skip to content

Instantly share code, notes, and snippets.

View 0xjmp's full-sized avatar

Jake Peterson 0xjmp

View GitHub Profile
node(:collection_description) { |product|
if product.collection.present?
collections = YAML.load(view_context(file: Rails.root + "config/collections", formats: [:yml]))
collections[product.collection.name.dasherize]["description"]
end
}
child(:swatch => :active_swatch) do
node(:name){|swatch| swatch.name.titleize}
node(:image_url){|swatch| image_url("products/#{swatch.permalink}.jpg") }
node(:product_url){|swatch| product_url(product.permalink)} << HERE
end
child(:collection_products => :collection_swatches) do
node(:name){|product| product.swatch.name.titleize}
node(:image_url){|product| image_url("products/#{product.swatch.permalink}.jpg") }
node(:product_url){|product| product_url(product.permalink)}
unless address.state_id do
state = Spree::State.where(abbr: address.state_name).first
address.state_id = state.id if state
end
{
products = (
{
"active_swatch" = {
"image_url" = "http://localhost:3000/products/mens/jeans/swatch/dstld/midnight-midnight.jpg";
name = "Midnight Midnight";
};
collection = "Dstld Straight";
"collection_description" = "Raw, straight 12.5 oz untreated denim";
"collection_swatches" = (
Host ipad
User ubuntu
HostName ec2-54-186-137-183.us-west-2.compute.amazonaws.com
Port 2332
IdentityFile "/Users/jsksma2/Developer/Certs/20jeans/20jeans.pem"
{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = close;
"Content-Type" = "application/json; charset=utf-8";
Etag = "\"9d9b48175bb971b9110e35c86964fb77\"";
Server = "thin 1.6.2 codename Doc Brown";
"Set-Cookie" = "_twenty_jeans_store_session=bGFmdWFMQjJZdHkwTGJHQzQrYkgyazlBdkFSejFSZHpha25VNkYzOVdwL0RsdldnMkpqYXMvQlZuRDQ3U09JZ0JKK2pQRDlnZWZGSlFtalNYWWcxOXF3dGRKcnJxb1pNaTVrK3hqbjlIRW5VaVVSUkJiYlRtS3pwam00K2cvSXdZLzUrNDBtQzdRc1dETGVHcGNuRFZwd3hiRUQrQW5CTk5yQVdMRmJxcjRxOEdVVTBTWldiK05BTkt0M3dxaFpqcHcxdVRRMk02MitpSDZLRUFzcXprVkVlZ2EyQi9BMnRnWDV4QnloTkoyREFKSWdQRkM3djJEWnhNUmRpQTlaOS0teFFlNHR6ZmFmbVZhL0toV1o0WitVZz09--c8d7027e51c32741df1e7c6540fd09cc62fdfe09; path=/; HttpOnly";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
Completed 500 Internal Server Error in 1157ms
ActionController::UrlGenerationError - No route matches {:action=>"show", :controller=>"products", :format=>nil, :id=>"slim-raw-jeans-in-midnight"} missing required keys: []:
actionpack (4.0.3) lib/action_dispatch/journey/formatter.rb:39:in `generate'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:601:in `generate'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:631:in `generate'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:667:in `url_for'
actionpack (4.0.3) lib/action_dispatch/routing/url_for.rb:155:in `url_for'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:234:in `call'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:178:in `call'
{
omniauth = {
credentials = CAAGfF53UWn4BABbJz99IzpblwA1ddGoBf4aZAaNbicJiV0763j1RC9AsHZAabCkCrwDLIG31BeaML2R0ahVV5ZALU3ZA2veD32sDAZAsHa5x4qJDDzbBC76zUJXSUZBg4YMrZAZCk3PZBTYuewSCMJBjk8Kj08cPqyOGhfiUpUBgWzt0GlNu8nsezHHCHMylI8WUqtoKtO2dd4c6GH7F3QGqzCNtktHrFlyAZD;
info = {
email = "[email protected]";
"facebook_id" = 100001254454375;
"first_name" = Jake;
gender = male;
id = "<null>";
"last_name" = Peterson;
@0xjmp
0xjmp / DDViewController.m
Created April 21, 2014 20:01
Allocations should always be executed inside of the class initialization method. Specifically for the AVAudioPlayer class, initializing in the - (id)init method and calling -prepareToPlay fully primes the player.
#import "DDViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface DDViewController ()
@property (nonatomic, assign) UIButton *sayButton;
@property (strong, nonatomic) AVAudioPlayer *audioPlayer;
@end
@implementation DDViewController
@synthesize sayButton;
@0xjmp
0xjmp / gist:11156123
Last active August 29, 2015 14:00
The main issue with this method is that it's performing a task ([NSData dataWithContentsOfURL]) on the main thread and is therefore blocking ui actions (such as scrolling) until it has finished loading the image. A secondary issue is that this method doesn't dequeue sufficiently. Dequeuing is a critical factor in increasing a scroll-based class'…
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MemeCell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MemeCell"];
}
// Dequeue subviews
NSInteger tag = 1415;