$vehicle_providers = PeriodicUpdater.new(:period => 120){ VehicleWizardClient.get_providers }
$vehicle_providers.start
sleep(3) # make sure the first call completes before use
$vehicle_providers.get #=> [{:provider => ...}]
- # if it's a Fleet provider but not virtual provider | |
- # refactor: have a flag on provider that indicates that there is additional info in Fleet database | |
- update_driver(params) if (provider.fleet_provider?(booking_channel.bit_mask) && driver && need_update_driver?(params)) | |
- | |
- set_driver_tags(params) | |
- | |
+ info = RideDriverInfo.fetch(self,params) | |
+ params[:driver_phone_number] = info.driver_phone_number | |
+ params[:can_call_driver] = info.can_call_driver | |
+ params[:driver_photo_enabled] = info.driver_photo_enabled |
class CachedMethod | |
def initialize(name, cache_args={:expires_in => 1.minute},&method) | |
@name = name | |
@action = method | |
@cache_args = cache_args | |
end | |
def self.get(name,cache_args,&method) | |
cache = new(name,cache_args,&method) | |
cache.get | |
end |
before_install: | |
- ssh-keygen -t rsa -f ~/.ssh/id_rsa_2 -P "" | |
- touch ~/.ssh/authorized_keys | |
- cat ~/.ssh/id_rsa_2.pub >> ~/.ssh/authorized_keys | |
- eval `ssh-agent` | |
- ssh-add ~/.ssh/id_rsa_2 | |
cache: bundler | |
language: ruby | |
script: | |
- bundle exec rake # you'll want capistrano-spec |
https://gist.github.com/atmos/6631554
Another question after seeing this blog post about deploying: is the knowledge of whether a particular application is "locked" for deployment maintained in Heaven?
One of the cool things about separating the logic of the actual deployment out from the API is that we can have two modes. One is work-flow friendly and the other is "do as I say right fucking now." The work-flows basically just save us from doing a bunch of manual shit day in and day out.
Locking and unlocking is just another endpoint separate from deployment that throws a bit of info about the app into a data store and whether it's locked or unlocked dictates other functionality of the system. If you deploy a branch, the application is locked in that environment until you unlock it, deploy master, or merge a pull request. We also have a variety of checks that rely heavily on the GitHub API. We ensure stuff like branches that are deployed have master merged into them, auto-merging master for people if pos
so you did the original work on adding rollout and the features class wrapper for it
in discussing our various feature flag capabilities, I realized our current solutions weren't very uniform or adequate (mainly the provider_feature_bitmasks and the system_configs)
and I needed to add fleet level feature flags that werent related to any booking channel
so I added this:
# app/resourceful_api/resourceful_actions.rb | |
# Requires #params, #render, Presenters::Api | |
module ResourcefulAction | |
def presents_json_endpoints(service, *actions) | |
respond_to :json | |
actions.each do |action| | |
define_method action do | |
resp = Presenters::Api.call(service,action, params) | |
render :json => resp, :status => resp[:status] |
require 'open-uri' | |
require 'zlib' | |
require 'yajl' | |
(1..24).to_a.reverse.each do |i| | |
gz=open("http://data.githubarchive.org/2014-03-14-#{i}.json.gz") rescue nil; | |
next if gz.nil?; | |
js = Zlib::GzipReader.new(gz).read; | |
Yajl::Parser.parse(js) do |event| |
#!/usr/bin/env ruby | |
gem 'google_drive', '~>0.3.7' | |
require "google_drive" # see: https://github.com/gimite/google-drive-ruby | |
require 'optparse' | |
require 'tempfile' | |
option_parser = OptionParser.new do |o| | |
o.banner = "Usage: './bin/download_from_drive 'Google Drive Title'. Outputs CSV data on stdout." | |
o.on('-u USER') do |u| | |
$user = u | |
end |