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
<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>
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
@mikecmpbll
mikecmpbll / totp
Last active October 29, 2015 14:23 — forked from jurisgalang/totp
Ruby implementation of the Time-Based One-Time Password (TOTP) Algorithm described at http://tools.ietf.org/html/rfc6238
[jgalang@rashomon:~/Code/skunkworks/2fa]
∴ ruby totp_demo.rb
Time(sec) Time (UTC format) Value of T(Hex) TOTP Mode OK
------------------------------------------------------------------------------------------
59 1970-01-01 00:00:59 0000000000000001 94287082 SHA1 ✔
59 1970-01-01 00:00:59 0000000000000001 46119246 SHA256 ✔
59 1970-01-01 00:00:59 0000000000000001 90693936 SHA512 ✔
1111111109 2005-03-18 01:58:29 00000000023523EC 07081804 SHA1 ✔
1111111109 2005-03-18 01:58:29 00000000023523EC 68084774 SHA256 ✔
@mikecmpbll
mikecmpbll / _form.html.haml
Created October 27, 2015 16:45
trying to embed erb inside yml locale file
.form-actions
- if params[:action] == "new"
= button_tag type: "submit", class: "btn btn-success btn-cons",
id: "submit" do
= fa_icon "check"
%span &nbsp;Create
= link_to courses_path, class: "btn btn-danger btn-cons" do
= fa_icon "close"
%span &nbsp;Cancel
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
print "Enter an integer number to be calculated as factorial: "
Integer(gets) rescue print "Hey, that's not an integer! Enter an integer, please: "
n = gets.to_i
def factorial n
n > 1 ? n * factorial(n - 1) : 1
end
puts "Factorial of number #{n} is #{factorial(n)}"
@mikecmpbll
mikecmpbll / code
Last active August 29, 2015 14:18 — forked from baditaflorin/code
#!/usr/bin/env ruby
# encoding: utf-8
require 'savon'
require 'csv'
startDate = Date.new(2004, 01, 01)
stopDate = Date.today
csvHeaders = ['numar', 'numar_vechi', 'data', 'institutie', 'departament',
'categorie_caz', 'stadiu_procesual', 'obiect', 'data_modificare','nume','calitate_parte','solutie']
@mikecmpbll
mikecmpbll / console
Last active August 29, 2015 14:04 — forked from anonymous/console
1.9.3p392 :002 > Postcode
=> Postcode(id: integer, postcode: string, long: decimal, lat: decimal, address: string, bias: string, data: text, tries: integer, updated_at: datetime, created_at: datetime)
1.9.3p392 :003 >
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: "">
@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