Skip to content

Instantly share code, notes, and snippets.

View denysonique's full-sized avatar

Dennis Prochniak denysonique

View GitHub Profile
def add_line_item_to_cart
#Get current_cart object
current_cart
quantity = params[:quantity].to_i
id = params[:id].to_i
line_item = LineItem.find(:first, :conditions => {:cartridge_id => id, :cart_id => current_cart.id})
if line_item
line_item.cart_id = current_cart.id
$('document').ready(function() {
// Don't work
$( "#message_number_false" ).click(
function() {
$( "#call_back_text" ).show(100);
});
// Don't work
$( "#message_number_true" ).click(
function() {
@denysonique
denysonique / my_model.rb
Created July 1, 2011 17:14 — forked from mnaser/my_model.rb
Is there a cleaner/simpler way of doing this?
class MyModel < ActiveRecord::Base
after_initialize :setup_defaults
attr_accessor :foo_bar
def setup_defaults
@foo_bar ||= "my default value"
end
end
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*= require layout
*/
@denysonique
denysonique / gist:1099325
Created July 22, 2011 12:10 — forked from nickws/gist:1099324
database.yml
development:
adapter: postgresql
database: emotio-dev
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
//wyświetla wszystkie argumenty, w nawiasie podając ich długość
int dl_napisu(char n[]) {
int i = 0;
while(n[i] != 0)
i++;
return i;
}
@denysonique
denysonique / gist:1489887
Created December 17, 2011 10:26 — forked from mauriciofierrom/gist:1489885
ujs problem
def create
@cart = current_cart
product = Product.find(params[:product_id])
@line_item = @cart.add_product(product.id)
respond_to do |format|
if @line_item.save
format.html { redirect_to(store_url)}
format.js { @current_item = @line_item }
format.xml { render :xml => @line_item, :status => :created, :location => @line_item }
@denysonique
denysonique / gist:2715518
Created May 17, 2012 01:35 — forked from mstarkman/gist:1431342
Unable to access connect-assets jsCompilers
assets = require 'connect-assets'
eco = require 'eco'
assets.jsCompilers.eco =
eco:
match: /\.eco$/
compileSync: (sourcePath, source) ->
eco.compile source
@denysonique
denysonique / 2 - nap_export.rb
Created June 7, 2012 09:08
EXPORTS SQLITE DATA INTO POSTGRESQL
#!/usr/bin/env ruby
# 1283314500 EXPORTS NET-A-PORTER LIVE DATA INTO POSTGRESQL
require "logger"
require "sequel"
#require "pgpass"
require "fileutils"
module NAP
if ! $(psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8); then
psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with template = template0 encoding = 'UTF8';"
psql template0 -c "update pg_database set datistemplate = TRUE where datname = 'template1';"
psql template1 -c "update pg_database set datallowconn = FALSE where datname = 'template0';"
fi