Skip to content

Instantly share code, notes, and snippets.

View paulcsmith's full-sized avatar

Paul Smith paulcsmith

View GitHub Profile
@paulcsmith
paulcsmith / gist:7472916
Created November 14, 2013 19:34
My key bindings for pairing with someone using VIM
" Type jj in insert mode to escape to command mode
:imap jj <Esc>
" Type j; in insert mode to escape to command mode with a : already typed
:imap j; <Esc>:
" Type ;w in insert mode to escape to command mode with :w already typed
:imap ;w <Esc>:w
" Use semicolon instead of colon. Don't have to hit shift now
map ; :
module Colleague::Classes
class CitizenshipStatus
include Processor
def process_field(value)
AlienStatus.find_code( value )
end
end
end
@paulcsmith
paulcsmith / gist:4a9c014b5702e10ab904
Created January 14, 2015 22:42
SkyLabels Start SASS template
.sky-label {
input, textarea { /* How the input looks without focus or text */ }
label { /* How the input looks without focus or text */ }
}
.sky-label-focused, .sky-label-has-text {
input, textarea { /* How the inputs look while focused or with text (and blurred) */ }
label {}
}
defmodule AnnouncementChannelTest do
use ConstableApi.TestWithEcto, async: false
alias Phoenix.Socket
alias Phoenix.Socket.Message
alias ConstableApi.Repo
alias ConstableApi.Announcement
alias ConstableApi.AnnouncementChannel
test "announcements:index returns announcements with ids as the key" do
@paulcsmith
paulcsmith / gist:08f9763fb88290e3f7ea
Created February 26, 2015 19:56
Elixir module doc from readme
@moduledoc File.read!("README.md")
@paulcsmith
paulcsmith / test_helper.exs
Last active June 22, 2016 17:22
Longer backtrace/stacktrace in Erlang/Elixir
# Works great in test/test_helper.exs
:erlang.system_flag :backtrace_depth, 50
@paulcsmith
paulcsmith / gist:dcb8adb3749cfec00960
Created March 11, 2015 21:01
Nicer looking type
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
@paulcsmith
paulcsmith / comment_view.ex
Last active August 29, 2015 14:17 — forked from jeregrine/comment_view.ex
Rendering JSON with views
defmodule MyApp.CommentView do
use MyApp.Web, :view
@attributes ~W(id name inserted_at)
def render("index.json", %{data: comments}) do
for comment <- comments, do: render("show.json", %{data: comment})
end
def render("show.json", %{data: comment}) do
comment
@paulcsmith
paulcsmith / gist:2615513d0602915fb98b
Created March 19, 2015 21:27
Complex Ecto Queries with joins and deep preload
def with_sorted_comments do
from a in Announcement,
left_join: c in assoc(a, :comments),
left_join: u in assoc(c, :user),
order_by: [asc: c.inserted_at],
preload: [:interests, :user, comments: {c, user: u}]
end
"<?xml version=\"1.0\" encoding=\"utf-8\"?><cfdi:Comprobante xsi:schemaLocation=\"http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd\" version=\"3.2\" folio=\"22\" LugarExpedicion=\"NOGAL 10 , SAN JOSE DE LOS CEDROS, 05200, DELEGACION CUAJIMALPA, DISTRITO FEDERAL, MEXICO\" NumCtaPago=\"NO IDENTIFICADO\" TipoCambio=\"1.00\" Moneda=\"Peso Mexicano\" fecha=\"2014-01-29T20:41:07\" sello=\"gO/DyxBs7kneK2dRySKmKshc1ddFXj+XcoPUrlgHYNyGeeuXGHW81URpiy20wIMpUmtZf8yne+5+jHMTqachVghB4IRkJwUNiFNPmc5K/vxiY/VWzalzQtrkBKZh7LWs/yrinvoiP1H4h8t/yOsiw+8NRwSDfcV6g70b3jnZRKg=\" formaDePago=\"PAGO EN UNA SOLA EXHIBICION\" noCertificado=\"00001000000301474075\" certificado=\"MIIEdzCCA1+gAwIBAgIUMDAwMDEwMDAwMDAzMDE0NzQwNzUwDQYJKoZIhvcNAQEFBQAwggGKMTgwNgYDVQQDDC9BLkMuIGRlbCBTZXJ2aWNpbyBkZSBBZG1pbmlzdHJhY2nDs24gVHJpYnV0YXJpYTEvMC0GA1UECgwmU2VydmljaW8gZGUgQWRtaW5pc3RyYWNpw7NuIFRyaWJ1dGFyaWExODA2BgNVBAsML0FkbWluaXN0cmFjacOzbiBkZSBTZWd1cmlkYWQgZGUgbGEgSW5mb3JtYWNpw7NuMR8wHQYJKoZIhvcNAQkBFhBhY29kc0BzYXQuZ29iL