Skip to content

Instantly share code, notes, and snippets.

def create
@project = Project.new(params[:project])
if @project.valid?
output = Project.myname(@project.project_name)
flash[:notice] = @output
redirect_to projects_url(output)
# render text: @output, location: projects_path(@output)
# redirect_to projects_path
else
render "new"
@thomasstr
thomasstr / form_tag
Created May 24, 2013 18:02
Form tag
<%= form_tag projects_path, method: :post, multipart: true do %>
<%= text_field_tag :project_name %>
<br />
<%= submit_tag :submit, value: "Lag", name: :make_project, class: "btn btn-success" %>
<% end %>
def test
hostname = "10.0.0.4"
username = "root"
password = "xxxxxx"
Net::SSH.start( hostname, username, :password => password ) do|ssh|
result = ssh.exec!('ls -la')
puts result
end
end
// TimeAgo Variables
private static final int SECOND_MILLIS = 1000;
private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
private static final int DAY_MILLIS = 24 * HOUR_MILLIS;
private static final long sAppLoadTime = System.currentTimeMillis();
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private static final String TIME_ZONE = "UTC";
@SuppressLint("SimpleDateFormat")
1.9.3-p392 :014 > Rapns.push
(0.3ms) SELECT COUNT(*) FROM "rapns_apps"
Rapns::App Load (0.2ms) SELECT "rapns_apps".* FROM "rapns_apps"
Rapns::Notification Load (0.5ms) SELECT "rapns_notifications".* FROM "rapns_notifications" WHERE "rapns_notifications"."app_id" IN (1) AND (delivered = 'f' AND failed = 'f' AND (deliver_after IS NULL OR deliver_after < '2013-04-18 05:23:53.736935'))
Rapns::App Load (0.2ms) SELECT "rapns_apps".* FROM "rapns_apps" WHERE "rapns_apps"."id" = 1 LIMIT 1
[2013-04-18 07:23:54] [ERROR] OpenSSL::SSL::SSLError, SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/net-http-persistent-2.8/lib/net/http/persistent/ssl_reuse.rb:70:in `connect'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/net-http-persistent-2.8/lib/net/http/persistent/ssl_reuse.rb:70:in `block in connect'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.
SimpleDateFormat smf = new SimpleDateFormat("dd-MM-YY HH:mm:ss");
smf.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(smf.format(new Date()));
System.out.println(smf.format(new Date(1000*60*10)));
System.out.println(new java.util.Date(1364768456));
#encoding: utf-8
require "rubygems"
require "open-uri"
require "json"
class Gulesider
def getData(data, country_name)
json_profile = "xxx"
json_apikey = "xxx"
@thomasstr
thomasstr / gist:5281879
Created March 31, 2013 20:22
current_cart method for application-controller
def current_cart
Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
cart = Cart.create
session[:cart_id] = cart.id
cart
end
<h2>Ny ordre</h2>
<%= content_tag('div', "There was an error processing your payment: #{@paypal_error}", :class => 'error') if @paypal_error %>
<%= simple_form_for @cc, :as => :creditcard, :url => { :action => 'credit' } do |f| %>
<p>Use the card number provided by your Sandbox account while testing</p>
<label>Card Number</label>
<%= f.input :number %>
<label>Card Type</label>
<%= f.select :brand, Purchase::PAYMENT_TYPES %>
class PurchaseController < ApplicationController
before_filter :require_ssl, :only => [ :index, :credit ]
before_filter :load_card
#belongs_to :cart
BILL_AMOUNT = 1200
def index
#@cart = current_cart
#if @cart.nil?