Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
var fs = require('fs'); | |
var apiKey = "api-key"; | |
var bitcodin = require('bitcodin')(apiKey); | |
var promise = bitcodin.job.getDetails(1); | |
promise.then(function (data) { | |
console.log(data); | |
}); | |
} |
# gem install benchmark-ips | |
# run irb | |
require "benchmark/ips" | |
n = 100_000 | |
# Array#push vs Array#<< | |
# | |
# Results: |
<advancedsettings> | |
<network> | |
<buffermode> 1 </buffermode> | |
<readbufferfactor> 1.5 </readbufferfactor> | |
<cachemembuffersize> 104857600 </cachemembuffersize> | |
</network> | |
</advancedsettings> |
Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
gem 'lograge' # more readable logs | |
gem 'logstash-event' # for logstash json format | |
gem 'mono_logger' # threadsafe logging |
# assumption | |
# model user exist | |
# | |
module AccessTokenHelper | |
APP_NAME = "app name".freeze | |
REDIRECT_URL = "https://host.name/oauth/callback".freeze | |
def token_scopes(scopes) | |
app = Doorkeeper::Application.create!(:name => "MyApp", :redirect_uri => REDIRECT_URL) | |
user = create(:user) |
# An isogram is a word that has no repeating letters, consecutive or non-consecutive. | |
# Implement a function that determines whether a string that contains only letters is an isogram. | |
# Assume the empty string is an isogram. Ignore letter case. | |
is_isogram("Dermatoglyphics") == true | |
is_isogram("aba" ) == false | |
is_isogram("moOse" ) == false # -- ignore letter case | |
def is_isogram(str) | |
return true if str.nil? || str == "" |
require 'date' | |
require 'net/http' | |
require 'active_support/concern' | |
# Module for verifying/creating users from authenticated facebook_token | |
# | |
# This will make a call to FB api and fetch the details of your user and store in your users database table. | |
# | |
# Ideal in use cases where you're clients are logged in/signed up using Facebook and you want to store user details and let your |
module Cache | |
# Placeholder for your redis key prefixes | |
# Serves as a way to identify which prefix keys belongs to which cache key resource | |
# | |
# Usage: | |
# | |
# To create cache key | |
# | |
# Cache::Key.prefix(Cache::Key::PRESENTER, resource) | |
# => "pr:Track:#{track.id}:" |
# run this in rails console | |
require 'benchmark/ips' | |
def track | |
track ||= Track.first | |
end | |
Benchmark.ips do |x| | |
x.report("Module.get_const") { Module.const_get("#{V1}::TrackPresenter").new(track) } |