This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Logs to the specified file in the Rails log folder | |
# | |
# Usage: | |
# LogTo.file("tracking-numbers").info "log some data" | |
# or | |
# logger = LogTo.file("tracking-numbers") | |
# logger.info "this is saved in my tracking-numbers log" | |
class LogTo | |
def self.file(name) | |
return Rails.logger if Rails.env.test? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails Concern | |
# models/concerns/nicknameable.rb | |
module Nicknameable | |
extend ActiveSupport::Concern | |
included do | |
def self.nicknames(*args) | |
define_method("nicknames") { args } | |
end | |
nicknames |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def timezone_from_coordinates(lat, long) | |
conn = Faraday.new(url: "https://maps.googleapis.com/maps/api/") | |
res = conn.get("timezone/json") do |req| | |
req.params["location"] = "#{lat},#{long}" | |
req.params["timestamp"] = Time.now.to_i | |
req.params["sensor"] = false | |
end | |
data = JSON.parse res.body | |
data["timeZoneId"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prints a message in the console. | |
# ################## | |
# this is my message | |
# ################## | |
def info(message, char = "#" ) | |
len = `tput cols`.to_i | |
bar = -> { (len/ char.length).times { print char }; print "\n" } | |
(message.length / len).times { |n| message.insert(((n +1 ) * len), "\n") } | |
bar.call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: | |
# safe_path "app/controllers" | |
def safe_path(path = "") | |
File.join(*path.split("/")) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"devDependencies": { | |
"broccoli-asset-rev": "^2.2.0", | |
"ember-cli": "1.13.13", | |
"ember-cli-app-version": "^1.0.0", | |
"ember-cli-babel": "^5.1.5", | |
"ember-cli-bootswatch": "1.13.0", | |
"ember-cli-content-security-policy": "0.4.0", | |
"ember-cli-dependency-checker": "^1.1.0", | |
"ember-cli-emblem": "0.3.1", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
class ExpectedDeliveryDateRow | |
include Helper::Date | |
include KioskDashboardCard::ViewHelpers | |
def initialize(is_deliverd, delivery_date) | |
@is_deliverd = is_deliverd | |
@delivery_date = delivery_date | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Muter | |
def mute_for(minutes = 5) | |
return restore if minutes == 0 | |
Thread.new do | |
mute | |
sleep (minutes * 60) | |
restore | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Extracted from https://code.google.com/p/datejs/source/browse/trunk/src/core.js#761 | |
/** | |
* Converts the value of the current Date object to its equivalent string representation. | |
* Format Specifiers | |
<pre> | |
CUSTOM DATE AND TIME FORMAT STRINGS | |
Format Description Example | |
------ --------------------------------------------------------------------------- ----------------------- | |
s The seconds of the minute between 0-59. "0" to "59" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
namespace :hamlbars do | |
desc "Creates a hamlbars template in app/assets/javascripts/templates" | |
task :template do | |
template = ARGV.last | |
dir = template.rpartition("/").first | |
file = template.rpartition("/").last | |
begin |