Skip to content

Instantly share code, notes, and snippets.

View mikecmpbll's full-sized avatar
🎯
Focusing

Mike Campbell mikecmpbll

🎯
Focusing
  • Skipton, North Yorkshire
View GitHub Profile
4 def import
5 unless params[:file].blank?
6 labels = Array.new
7 IO.foreach( params[:file].tempfile ) do |line|
8 if /;/.match( line )
9 labels << line.split( ';' )
10 elsif /,/.match( line )
11 labels << line.split( ',' )
12 else
13 labels << line
class Task < ActiveRecord::Base
def self.todays_tasks
where(due_date: Date.today.beginning_of_day..Date.today.end_of_day)
end
def self.tomorrows_tasks
where(due_date: Date.tomorrow.beginning_of_day..Date.tomorrow.end_of_day)
end
end
<body id="brands" data-hook="body">
<ul class="letters">
<% ('A'..'Z').each do |letter| %>
<li><%= link_to letter, "#", class: "key-link", data: { letter: letter } %></li>
<% end %>
</ul>
<hr>
<% @brands.each do |key, brands| %>
<ul class="brand-letters">
<li id="letter-<%= key %>" class="key"><%= key %></li>
@mikecmpbll
mikecmpbll / home.rb
Last active August 29, 2015 13:56 — forked from joelbrewer/home.rb
def home
render 'signed_out_home' and return unless signed_in?
current_user.active_subscription? ? load_signed_in_page : redirect_to plans_path
end
app
engines
engine_one
app
models
..etc
engine_two
app
models
..etc
class Widget < ActiveRecord::Base
attr_accessible :name, :snippets, :snippets_attributes, :company_id, :hostname, :first_page, :affiliate_id, :item_defaults, :read_only
has_many :snippets
has_many :permissions, dependent: :destroy
has_many :users, through: :permissions
accepts_nested_attributes_for :snippets
attr_accessor :read_only
def read_only
true
class JTask
# JTask.find()
# Retrieves records from the database file.
# --------------------------------------------------------------------------------
# Eg: JTask.find("test.json", 1) || JTask.find("test.json", first: 10)
# #=> <JTask id=x, ...>
# --------------------------------------------------------------------------------
# See wiki guide for more usage examples...
# https://github.com/adammcarthur/jtask/wiki/find
@mikecmpbll
mikecmpbll / en.yml
Created June 26, 2014 14:00 — forked from smaboshe/en.yml
# Variable substitution works here
foo: "The quick brown %{ animal } jumped over the lazy dog"
# Variable substitution done not work here
# Instead, "%{ animal }" gets rendered
bar: "The quick
brown %{ animal }
jumped over
the lazy dog"
@mikecmpbll
mikecmpbll / example.rb
Last active August 29, 2015 14:04 — forked from anonymous/example.rb
search_all = LOCAL_SETTINGS["single_site_search"]
if params[:ref].present?
spaces = Space.where(id: { params[:ref] }, parent_id: nil })
spaces = spaces.eager_loads(slots: :companies).where(companies: { parent_id: current_company_id }) unless search_all
render partial: 'call_centre_results' and return
end
AppUser.authenticate('ADMIN', '')
AppUser Load (0.9ms) EXEC sp_executesql N'SELECT TOP (1) [AppUsers].* FROM [AppUsers] WHERE [AppUsers].[UserID] = N''ADMIN'' AND [AppUsers].[Password] = N'''' ORDER BY [AppUsers].[UserID] ASC'
=> #<AppUser UserID: "ADMIN", UserName: "Administrator", MenuGroup: "SYS_ADMIN", Password: "", DefaultStoreID: "1", FullRights: true, LastChanged: "2013-10-23 17:59:52", ChangedBy: "ADMIN", Email: "", Phone: "", Deleted: false, CashierID: "", HideCostPrice: false, WebLogin: false, CustomerID: "", DepID: "", NetworkID: "">