Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
set -o errexit
set -e
# Fail fast if we're not on OS X >= 10.6.0.
if [ "$(uname -s)" != "Darwin" ]; then
echo "Sorry, DevDNS requires Mac OS X to run." >&2
exit 1
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"detect_slow_plugins": false,
"file_exclude_patterns":
[
"*.log",
"*.gif",
"*.png",
"*.jpg",
"*.psd",
[
{ "keys": ["ctrl+shift+t"], "command": "delete_trailing_spaces" },
{ "keys": ["ctrl+space"], "command": "exit_insert_mode",
"context":
[
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
},
def payment_received(user.id, amount)
mixpanel.people.track_charge(user.id, amount, {}, nil, '$ignore_time' => true)
mixpanel.track(user.id, 'Payment', 'Action' => 'received', 'Amount' => amount)
end
def payment_refunded(user, amount)
mixpanel.people.track_charge(user.id, -amount, {}, nil, '$ignore_time' => true)
mixpanel.track(user.id, 'Payment', 'Action' => 'refunded', 'Amount' => -amount)
end
def mixpanel
@mixpanel ||= Mixpanel::Tracker.new(MIXPANEL[:token])
end
def user_conversion(user, converted_at = Time.now.in_time_zone('UTC'))
properties = {
'Converted' => converted_at,
'Conversion Delay' => (converted_at.to_date - user.created_at.to_date).to_i
}
mixpanel.people.set_once(user.id, properties, nil, '$ignore_time' => true)
mixpanel.people.set(user_id, properties, nil, '$ignore_time' => true)
mixpanel.people.set_once(user_id, properties, nil, '$ignore_time' => true)
mixpanel.people.unset(user_id, property, nil, '$ignore_time' => true)
mixpanel.people.increment(user_id, { property => value }, nil, '$ignore_time' => true)
mixpanel.people.track_charge(user_id, amount, {}, nil, '$ignore_time' => true)
@daniel-nelson
daniel-nelson / confirm.coffee
Created June 15, 2015 19:31
Bootstrap popover based confirm directive for Angularjs
# Usage:
# <div "ng-repeat"="comment in comments">
# <a class="remove" href="" "pj-confirm"="Really remove?" "popover-placement"="left"
# "on-confirm"="deleteComment" "callback-argument"="comment" "confirm-btn-label"="Yes" "cancel-btn-label"="No">Delete</a>
# </div>
#
# Dependencies:
# jQuery UI (for position function)
# Bootstrap CSS
After adding pubsub (using Pubnub.com) to our application, our headless specs were straight up breaking. Solved by creating a mock that we can trigger within the specs
Coffeescript required by application.js manifest:
class PubsubMock
subscribe: (obj) ->
@channels ||= {}
@channels[obj.channel] ||= []
@channels[obj.channel].push(obj.message)
<% if current_user -%>
<script>
mixpanel.identify('<%= @current_user.id %>');
mixpanel.register(<%= raw JSON.generate(MixHelp.user_supers(@current_user, 'event')) %>);
mixpanel.name_tag('<%= @current_user.display_name %>');
mixpanel.people.set(<%= raw JSON.generate(MixHelp.user_supers(@current_user, 'people')) %>);
</script>
<% end -%>
class ImageWidget < ContentWidget
has_attached_file :image,
:styles => lambda { |a|
{ :thumb => '200x100>',
:display => "#{a.instance.width}x#{a.instance.height}#" }
},
:storage => PAPERCLIP_CONFIG[:storage],
:bucket => PAPERCLIP_CONFIG[:bucket],
:s3_host_alias => PAPERCLIP_CONFIG[:bucket],