This file contains 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
// Settings | |
var changeThresholdPct = 1.0; // Notify by voice when the price moves up or down this percentage | |
var beepChangeThresholdPct = 0.25; // Notify with a beep when the price moves up or down this percentage | |
// Scopes | |
var lastPx = self.lastPx; | |
var beepLastPx = self.beepLastPx; | |
if(trades.length!=0){ | |
var currentPx = trades[0].Price; |
This file contains 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
$('#currencies-all tbody > tr').filter((i, v) => (window.parseFloat($(v).find('.market-cap').data('usd')) || 0) < 100000000.0).remove() |
This file contains 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 'uri' | |
require 'net/http' | |
require 'auth0' | |
class Auth0Api | |
def initialize(options = {}) | |
@client_id = options[:client_id] || ENV['AUTH0_CLIENT_ID'] | |
@client_secret = options[:client_secret] || ENV['AUTH0_CLIENT_SECRET'] | |
@domain = options[:domain] || ENV['AUTH0_DOMAIN'] | |
end |
This file contains 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 ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
# Returns a string to be used in log messages. | |
# Concats the object's class name w/ it's id, so we can easely | |
# identify and search for the object in log messages. | |
# | |
# Example: | |
# | |
# user = User.new(id: 25) |
This file contains 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 'open-uri' | |
namespace :geolite2 do | |
desc 'Download the latest Maxmind Geolite2 database and dump it into the tmp folder.' | |
task :update do | |
required_system_bin = [ | |
'curl', | |
'tar', | |
'mkdir', | |
'find', |
This file contains 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
<?php | |
$cep = str_replace('-', '', $POST['id']); | |
$url = 'http://api.postmon.com.br/v1/cep/'.$cep; | |
$handle = curl_init(); | |
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($handle, CURLOPT_URL, $url); |
This file contains 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
# lib/json_serializer.rb | |
class JsonSerializer | |
# Dumps objects to json. | |
# Loads json into specified class. | |
# | |
# e.g: | |
# | |
# class User | |
# serialize :data, JsonSerializer.new(DataObject) | |
# end |
This file contains 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
# app/models/concerns/object_id.rb | |
module ObjectId | |
class ObjectIdReservedErr < StandardError; end | |
class ObjectIdPersistedErr < StandardError; end | |
def self.included(base) | |
base.extend ClassMethods | |
base.send :include, InstanceMethods | |
end |
This file contains 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
# By default, rails expects id's to be a integer | |
# In our app, we store id's as strings. | |
# | |
# To make our life easier, instead of always having to remember this | |
# and explicitly telling rails the id is a string, I'm going to monkey | |
# patch some migrations and AR methods. | |
module CoreExtensions | |
module ActiveRecord | |
module ConnectionAdapters | |
module ReferenceDefinition |