Skip to content

Instantly share code, notes, and snippets.

@Abica
Abica / a_controller.ex
Last active March 18, 2019 03:08
Example serializing an arbitrary elixir structure as xml and returning it from a phoenix endpoint
defmodule WhateverWeb.AController do
use WhateverWeb, :controller
# get "/whatever/:format", WhateverWeb.AController, :some_action
def some_action(conn, %{"format" => "xml"} = _params) do
example_data = %{
name: "Buy Guy",
title: "buyer",
items: [
%{name: "A", cost: 10, qty: 1},
@Abica
Abica / not-lisp.ruby
Created March 27, 2010 09:05
some really hilarious looking ruby that syntactically looks like lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; :RAZZLE_DAZZLE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def #'generate-faux-lisp
method_missing (*lol, &block)
((block. call) unless
(block. nil?))
end)
(you :know, i
@Abica
Abica / gist:318638
Created March 1, 2010 18:25
open grep results in vi
$ cat ~/bin/vigrep
#!/bin/sh
# open all files containing grep results in vi
# usage:
# vigrep term directory/
vi $( grep -R $1 $2 | sed 's/:.*//' | uniq | xargs echo )
@Abica
Abica / build.rb
Created January 3, 2010 12:17
a build script for corona applications
#!/usr/bin/env ruby
# this is a build script for corona iphone applications (www.anscamobile.com)
#
# it will combine all lua files and any images inside an image directory into
# a project that you can then build for a device with the corona simulator
#
# the resulting combined project is put inside the build directory
#
# simply put the file inside your current corona project and run it with
# ruby build.rb