Skip to content

Instantly share code, notes, and snippets.

@alkema
alkema / deploy.rb
Created July 9, 2011 20:01
Capistrano task for a Node.js app with github Forever and NPM.
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
https://en.wikipedia.org/wiki/List_of_kings_of_Sparta
http://sparta-dion.herokuapp.com/
irb(main):003:0> reload!; puts MerchantDirectory::Activity.fully_provisionable.count
Reloading...
Creating scope :published. Overwriting existing method MerchantDirectory::Activity.published.
Creating scope :published. Overwriting existing method MerchantDirectory::Profile.published.
(143.1ms) SELECT DISTINCT COUNT(DISTINCT `merchant_directory_activities`.`id`) FROM `merchant_directory_activities` INNER JOIN merchant_directory_variants ON merchant_directory_variants.merchant_activity_id = merchant_directory_activities.id INNER JOIN merchant_directory_availability_rules ON merchant_directory_availability_rules.merchant_variant_id = merchant_directory_variants.id WHERE (merchant_directory_activities.confero_id IS NOT NULL) AND (merchant_directory_variants.advance_product_id is null) AND (merchant_directory_variants.price IS NOT NULL) AND (merchant_directory_variants.duration < 86400) AND (merchant_directory_availability_rules.start_date is not NULL) AND (merchant_directory_availability_rules.end_date is not
@alkema
alkema / queries.rb
Last active December 15, 2015 03:21
irb(main):004:0> reload!; puts MerchantDirectory::Activity.fully_provisionable.count
Reloading...
(265.5ms) SELECT DISTINCT COUNT(DISTINCT `merchant_directory_activities`.`id`) FROM `merchant_directory_activities` INNER JOIN merchant_directory_variants ON merchant_directory_variants.merchant_activity_id = merchant_directory_activities.id INNER JOIN merchant_directory_availability_rules ON merchant_directory_availability_rules.merchant_variant_id = merchant_directory_variants.id WHERE (merchant_directory_activities.confero_id IS NOT NULL) AND (merchant_directory_variants.price IS NOT NULL) AND (merchant_directory_variants.duration < 86400) AND (merchant_directory_availability_rules.start_date is not NULL) AND (merchant_directory_availability_rules.end_date is not NULL) AND (merchant_directory_availability_rules.valid_days != '[]') AND (merchant_directory_availability_rules.start_time is not null)
9655
irb(main):005:0> MerchantDirectory::Variant.where('merchant_directory_variants.duration > 86400').update_
[2015-11-29 02:46:27 +0000] Starting
[2015-11-29 02:46:28 +0000] Error!
[2015-11-29 02:46:28 +0000] error message: --- &1 !ruby/object:Faraday::Response
on_complete_callbacks: []
env: !ruby/struct:Faraday::Env
method: :put
body: !ruby/hash:Hashie::Mash
error: !ruby/hash:Hashie::Mash
booking_rule: false
message:
@alkema
alkema / Gemfile
Created March 20, 2012 01:53
vcr-page-rankr.rb
source 'https://rubygems.org'
gem 'vcr'
gem 'fakeweb'
gem 'PageRankr'
<!DOCTYPE html>
<html>
<head>
<title>Demo Overherd</title>
<script type="text/javascript" src="http://stampede-corporate-2012.tb.nonwebdev.com/javascripts/jquery-1.5.1.min.js"></script>
</head>
<body>
<link href="http://ymssz4ew.frozencdn.net/stylesheets/live.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="/jquery.overherd.js"></script>
<script type="text/javascript">
class Comment < ActiveRecord::Base
default_scope :order => 'created_at DESC'
belongs_to :marked_entry
belongs_to :user
has_many :participants, :through => :marked_entry
def self.reply_copy
'## Reply above this line in order to comment via email ##'
end
@alkema
alkema / coffescript-jquery-ajax-poller.js
Created December 13, 2011 22:45
coffescript-jquery-ajax-poller
jQuery ->
getFeeds = ->
keywordId = $("#keyword").attr("data-id")
$.get("/keywords/#{keywordId}/feeds.html", (data)->
if jQuery.isEmptyObject(data)
setTimeout(getFeeds, 5000)
else
$('#feeds').html(data)
)
$ -> setTimeout(getFeeds, 1000)
@alkema
alkema / widget.rb
Created November 25, 2011 18:11
testing ruby object for attribute presence/absence
class Widget
attr_accessor :circumference
attr_accessor :colour
attr_accessor :mass
def initialize(attributes)
attributes.each do |key, value|
m = "#{key}=".to_sym
self.send(m, value) if self.respond_to?(m)
end