Skip to content

Instantly share code, notes, and snippets.

@pollingj
pollingj / elixir_packages.md
Created March 24, 2021 17:59
Useful Elixir Packages for Standard Web projects
@pollingj
pollingj / elixir.monit
Last active May 28, 2019 11:18
Basic Elixir / Phoenix monit conf
check process {{app_name}} MATCHING "{{app_name}}.sh"
start program = "/bin/su - {{ deployer_user }} -c '{{app_dir}}/bin/{{app_name}} start'"
stop program = "/bin/su - {{ deployer_user }} -c '{{app_dir}}/bin/{{app_name}} stop'"
@pollingj
pollingj / timex_date_json.ex
Created April 6, 2016 15:09 — forked from arjan/timex_date_json.ex
Automatically encode Timex datetimes as ISO in JSON
defimpl Poison.Encoder, for: Timex.DateTime do
use Timex
def encode(d, _options) do
fmt = Timex.format!(d, "{ISO}")
"\"#{fmt}\""
end
end
@pollingj
pollingj / facebook-connect-cordova-adapter.js
Last active May 1, 2017 07:35
Ember Torri - PhoneGap Facebook Plugin
import Ember from "ember";
export default Ember.Object.extend({
open: function(authentication){
var userId = authentication.userId;
var token = authentication.accessToken;
var store = this.get('store');
return new Ember.RSVP.Promise(function(resolve, reject){
Ember.$.ajax({
type: "POST",
# == Paperclip without ActiveRecord
#
# Simple and lightweight object that can use Paperclip
#
#
# Customized part can be extracted in another class which
# would inherit from SimplePaperclip.
#
# class MyClass < SimplePaperclip
# attr_accessor :image_file_name # :<atached_file_name>_file_name
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require "rubygems"
require 'bundler'
require 'bubble-wrap/media'
Bundler.require
Motion::Project::App.setup do |app|
class LocationsController(val swagger:Swagger) extends HullCityPlanApiStack with JacksonJsonParsing with JacksonJsonSupport {
implicit val jsonFormats = DefaultFormats+ new ObjectIdSerializer
var locationService = new LocationService()
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true)
...
}
@pollingj
pollingj / gist:5849509
Created June 24, 2013 11:46
Scalatra Command
abstract class LocationsCommand[S](implicit mf: Manifest[S]) extends ModelCommand[S] with JsonCommand {}
class CreateLocationCommand extends LocationsCommand[Location] {
protected implicit val jsonFormats = DefaultFormats
val name: Field[String] = asString("name").notBlank.minLength(3)
val jobs: Field[Int] = asInt("jobs").greaterThan(0)
val coordinates: Field[List[Coordinate]] = asType[List[Coordinate]]("coordinate")
}
package uk.co.cd4i.cityplan.domain.mongo
import java.util.Date
import com.novus.salat.annotations._
import com.novus.salat.dao.SalatDAO
import com.mongodb.casbah.Imports._
import com.novus.salat.global._
case class Milestone (
@Key("_id") id: Object = new ObjectId,
@pollingj
pollingj / gist:5336799
Created April 8, 2013 13:36
Gocardless Preauth
return GoCardless.new_pre_authorization_url amount: Settings.max_variable_direct_debit_amount, name: order.name, interval_unit: "month", interval_length: 12, state: member.id,
user: {
first_name: member.first_name,
last_name: member.last_name,
email: member.email,
billing_address1: member.correspondence_address_line_1,
billing_address2: member.correspondence_address_line_2,
billing_town: member.correspondence_address_city,
billing_postcode: member.correspondence_address_postcode
}