This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class m130726_082858_yii_category_point extends CDbMigration | |
{ | |
public function up() | |
{ | |
$this->createTable('yii_category_point', array( | |
'category_id'=>'int NOT NULL', | |
'point_id'=>'int NOT NULL', | |
'PRIMARY KEY (`category_id`, `point_id`)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Barcode < ActiveRecord::Base | |
validates_presence_of :code | |
validates_uniqueness_of :code | |
validates_length_of :code, :is => 8 | |
def generate_random_code | |
"#{self.batch}#{self.letters}#{self.numbers}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( !isset( $_GET['batch'] ) ) | |
die("YOU MUST SPECIFY A BATCH PARAMETER"); | |
$batch = $_GET['batch']; | |
$dbc = @mysqli_connect( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ) or die(); | |
$batch_size = 100000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
link_to 'Add to wishlist', spree.wished_product_path({:id => variant.id}), :remote => true, :method => :put |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@wished_product = Spree::WishedProduct.new(params[:wished_product]) | |
@wishlist = spree_current_user.wishlist | |
if @wishlist.include? params[:wished_product][:variant_id] | |
@wished_product = @wishlist.wished_products.detect {|wp| wp.variant_id == params[:wished_product][:variant_id].to_i } | |
else | |
@wished_product.wishlist = spree_current_user.wishlist | |
@wished_product.save | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spree | |
module Core | |
module ProductFilters | |
# Example: filtering by price | |
# The named scope just maps incoming labels onto their conditions, and builds the conjunction | |
# 'price' is in the base scope's context (ie, "select foo from products where ...") so | |
# we can access the field right away | |
# The filter identifies which scope to use, then sets the conditions for each price range | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PHPass | |
def self.itoa64 | |
'./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' | |
end | |
def self.crypt_private(password, setting) | |
output = '*0' | |
if setting[0,2] == output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def signed_in_root_path(resource_or_scope) | |
unless resource.has_role?('refinery') | |
refinery.edit_user_path(resource) | |
elsif respond_to?(:admin_root_path) | |
refinery.admin_root_path | |
else | |
"/" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
data = { | |
status: 200, # Maps to HTTP response codes (200 = OK, 404 = not found) | |
search: { | |
label: 'Apple', | |
image: '', | |
}, | |
data: { | |
demographics: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"status":200,"search":{"label":"Apple","image":""},"data":{"demographics":{"age":{"label":"25 to 35","image":"","zscore":0,"extra":[]},"gender":{"label":"Male","image":"","zscore":0,"extra":[]},"social_grad":{"label":"Middle Class","image":"","zscore":0,"extra":[]},"region":{"label":"London","image":"","zscore":0,"extra":[]},"income":{"label":"Under £5,000","image":"","zscore":0,"extra":[]},"party":{"label":"Labour","image":"https:#images.yougov.com","zscore":0,"extra":[]}},"lifestyle":{"interests":[{"label":"Walking","image":"https:#images.yougov.com","zscore":0,"extra":[],"node_id":1},{"label":"Singing","image":"https:#images.yougov.com","zscore":0,"extra":[],"node_id":1}],"hobbies":[],"sports":[],"dishes":[{"label":"Turkey Twizzlers","image":"","zscore":0,"extra":[{"label":"","image":"","zscore":0}]}],"animals":[]},"personality":{"positive_traits":[],"negative_traits":[],"cat_dog":{"label":"Cat","image":"","zscore":0,"extra":[]},"attitudes":[]},"brands":{"clothing":[],"bank":[{"label":"Natwest","ima |
OlderNewer