Skip to content

Instantly share code, notes, and snippets.

// 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")
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
@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 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 / delete_project.html.erb
Created May 25, 2013 13:19
Doesnt get any response from create method
<%= simple_form_for(@del_project, url: :del_project ) do |f| %>
<%#= f.error_notification %>
<div class="form-inputs">
<%= f.input :delete_project, collection: Project.list_domains.split("\n"), prompt: "Velg utviklingssted" %>
<%#= f.input %>
<%= f.button :submit, "Slett", class: "btn btn-danger" %>
</div>
<% end %>
Started POST "/projects" for 127.0.0.1 at 2013-05-25 15:24:16 +0200
Processing by ProjectController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"jaXD4d7Qg+seIiSlbqcm9bF6m7lJ+GsYkGkDVPgM40M=", "project"=>{"project_name"=>"Thomas", "project_pass"=>"928irte"}, "commit"=>"Lag"}
Rendered project/new.html.erb within layouts/application (2.6ms)
Rendered layouts/_messages.html.erb (0.1ms)
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered layouts/_menu.html.erb (3.1ms)
Rendered layouts/_footer.html.erb (0.3ms)
Completed 200 OK in 99ms (Views: 97.4ms | ActiveRecord: 0.3ms)
2013-05-30 10:02:19 [381321/timer] info: signal 11 caught - shutting down
2013-05-30 10:02:19 [381223/watcher] error: worker process exited with 3 - restarting
2013-05-30 10:02:19 [381329/main] always: New Relic local daemon version 1.2.0.257/C+IA started - pid=381329 background=true SSL=false host=gyda.norisp.no
2013-05-30 10:02:19 [381329/main] info: RPM redirect: collector-0.newrelic.com(204.93.223.134) port 0 (0 means default port)
2013-05-30 10:02:19 [381329/timer] error: segmentation violation - stack dump follows .../usr/sbin/nrsysmond[0x404abc]
/lib64/libpthread.so.0[0x3bb0a0f500]
/usr/sbin/nrsysmond[0x536fc4]
/usr/sbin/nrsysmond[0x5374fb]
/usr/sbin/nrsysmond[0x40fe71]
/usr/sbin/nrsysmond[0x410e06]
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3" client="site" method="upgrade">
<name>SM360 Footer</name>
<author>Thomas Stroemme</author>
<authorEmail>thomas@sensemedia.no</authorEmail>
<authorUrl>http://sm360.no</authorUrl>
<copyright>SenseMedia 2013</copyright>
<license>GNU/GPL v2</license>
<version>1.0.0</version>
<description>Footer for SenseMedia website</description>
2013-06-06 10:25:33 [124601/timer] info: signal 11 caught - shutting down
2013-06-06 10:25:33 [124535/watcher] error: worker process exited with 3 - restarting
2013-06-06 10:25:33 [124603/main] always: New Relic local daemon version 1.2.0.257/C+IA started - pid=124603 background=true SSL=false host=gyda.norisp.no
2013-06-06 10:25:34 [124603/main] info: RPM redirect: collector-0.newrelic.com(204.93.223.134) port 0 (0 means default port)
2013-06-06 10:25:34 [124603/timer] error: segmentation violation - stack dump follows .../usr/sbin/nrsysmond[0x404abc]
/lib64/libpthread.so.0[0x3bb0a0f500]
/usr/sbin/nrsysmond[0x536fc4]
/usr/sbin/nrsysmond[0x5374fb]
/usr/sbin/nrsysmond[0x40fe71]
/usr/sbin/nrsysmond[0x410e06]
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :authenticate_admin!
default_scope { where(company_id = current_admin.company_id ) }
end