This README would normally document whatever steps are necessary to get the application up and running.
Things you may want to cover:
-
Ruby version
-
System dependencies
// Write a function that takes an object. The object contains a left, right and operator properties. The left and right properties are numbers. The operator property is a string. The function should return the result of the operation. The function should return null if the operator is not one of the following: +, -, *, /. | |
// Example: | |
// calculate({ left: 1, right: 2, operator: '+' }) // 3 | |
// calculate({ left: 1, right: 2, operator: '-' }) // -1 | |
// calculate({ left: 1, right: 2, operator: '*' }) // 2 | |
// calculate({ left: 1, right: 2, operator: '/' }) // 0.5 | |
// calculate({ left: 1, right: 2, operator: '%' }) // null |
require 'ostruct' | |
def send_mail(to:, from:, subject:, body:) | |
puts "Sending mail to: #{to}" | |
puts "From: #{from}" | |
puts "Subject: #{subject}" | |
puts "Body: #{body}" | |
end | |
module FormBot |
def permutations(day_hours, missing_days, target) | |
results = [] | |
values = (0..day_hours).to_a | |
size = missing_days | |
puts target | |
permuts = values.repeated_permutation(size).to_a | |
permuts.each do |permut| | |
if permut.inject(:+) == target.to_i | |
results.push(permut.join(',')) | |
end |
Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.
Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.
As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.
Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.
class MyJob < ActiveJob::Base | |
queue_as :urgent | |
rescue_from(NoResultsError) do | |
retry_job wait: 5.minutes, queue: :default | |
end | |
def perform(*args) | |
MyService.call(*args) | |
end |
<body onload='setInterval(onkeydown=d=>{ | |
for(d=d||5,(e=d.keyCode)&&(d=e%2?e%3?-1:1:5) | |
,t="",d=c-d,e=a|b<<d,0>d|a&b<<d&&(a=e=parseInt((a|b<<c) | |
.toString(d=32).replace(/v/,""),d),b=new Date%22?1:3) | |
,c=d,i=1;31>i;)O.innerHTML=t+=".#"[1&(1<<30|e). | |
toString(2)[i]]+(i++%5?"":"\n")},666,a=0,b=3,c=32)'> | |
<pre id=O> |
" Leader | |
let mapleader = " " | |
set nocompatible " be iMproved, required | |
set backspace=2 | |
set noswapfile " no swapfile | |
set ruler " show the cursor position all the time | |
set nowritebackup | |
set autowrite |
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH=/Users/simonpeterdamian/.oh-my-zsh | |
# Set name of the theme to load. Optionally, if you set this to "random" | |
# it'll load a random theme each time that oh-my-zsh is loaded. | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
# ZSH_THEME="robbyrussell" |
module ObjectTracker | |
module ClassMethods | |
def track_method(method_name) | |
alias_method :"#{method_name}_without_tracking", method_name | |
define_method :"#{method_name}_with_tracking" do |*splat| | |
params = self.class.instance_method(:"#{method_name}_without_tracking").parameters.collect(&:last) | |
self.send(:"#{method_name}_without_tracking", *splat) # do method first | |
self.track_event!(method_name, Hash[*(params.zip(splat).flatten)]) # then track | |
end | |
alias_method method_name, :"#{method_name}_with_tracking" |