Skip to content

Instantly share code, notes, and snippets.

View denysonique's full-sized avatar

Dennis Prochniak denysonique

View GitHub Profile
@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 }
Titanium.UI.setBackgroundColor('#000')
tabGroup = Titanium.UI.createTabGroup()
win1 = Titanium.UI.createWindow
title:'Tab 1'
backgroundColor:'#fff'
//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;
}
Assuming your username is "username"
$ sudo gpasswd -a postfres username
$ sudo postgres createuser username
require 'mechanize'
require 'shellwords'
agent = Mechanize.new
agent.user_agent_alias = 'Windows IE 7'
page = agent.get('https://online.lloydstsb.co.uk/personal/logon/login.jsp')
login_form = page.forms.first
login_form.send("frmLogin:strCustomerLogin_userID", "1234")
login_form.send("frmLogin:strCustomerLogin_pwd", "secret")
page = agent.submit login_form
ome/dennis/.rvm/gems/ruby-1.9.2-p290/bin/rspec: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:00124c d:00124c TOP
---------------------------
-- C level backtrace information -------------------------------------------
/home/dennis/.rvm/rubies/ruby-1.9.2-p290/lib/libruby.so.1.9(rb_vm_bugreport+0x72) [0xb77100e2]
/home/dennis/.rvm/rubies/ruby-1.9.2-p290/lib/libruby.so.1.9(+0x563a1) [0xb75ea3a1]
require 'Qt4'
include Qt
app = Application.new ARGV
w = MainWindow.new
Label.new('foobar',w)
w.show
app.exec
require 'Qt4'
include Qt
Application.new ARGV do
MainWindow.new do
Label.new 'foobar', self
show
end
exec
end
module Command
class << self
%w[shutdown reboot open close].each do |method_name|
define_method method_name do
lambda do
puts method_name
Thread.new { $selected_client.client_rpc.send(method_name) } #this way does not work
Thread.new { eval("$selected_client.client_rpc.#{method_name}") } #this way does
class Sum : public XmlRpcServerMethod
{
public:
Sum(XmlRpcServer* s) : XmlRpcServerMethod("Sum", s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result)
{
int nArgs = params.size();
double sum = 0.0;
for (int i=0; i<nArgs; ++i)