Skip to content

Instantly share code, notes, and snippets.

View eezis's full-sized avatar

Ernest Ezis eezis

  • Boulder, CO
View GitHub Profile
eezis / apostrophe-diff-than-quot
Created March 20, 2014 15:10
Distinction between ' and " usage in Elixir?
What are the "rules" or guidelines for using ' vs " in Elixir?
iex> l1 =['test']
iex> l2 = ['test']
iex> l1 == l2
iex> l3 = ["test"]
eezis / plug streaming
Created March 23, 2014 19:09
Simple Streaming with Elixir Plug.
defmodule MyPlug do
import Plug.Connection
def init(options) do
# initialize options
def call(conn, _opts) do
eezis / compile ecto
Created October 29, 2014 19:55
Elixir Does Pheonix Ecto Compilation Fix
I was following this tutorial:
Could not mix compile
==> postgrex
warning: the dependency postgrex requires Elixir "0.15.0" but you are running on v1.0.1
Compiled lib/postgrex/binary_utils.ex
Compiled lib/postgrex/error.ex
eezis / pdquestion
Last active August 29, 2015 14:12
phoenix docs question
Are templates scoped to a controller by naming convention? And is that convention two layers deep
and implemented with filenames?
First convention describes rules for a controller's filename; stipulating that Controller filenames
get two parts seperated by
an underscore. An application with these three controllers -- PageController, HelloController, and
UserController -- should manifest the following file names:
|- page_controller.ex
eezis / cfbundlerid
Created September 30, 2015 02:11
unable to match
To find the proper cfbundlerid when writing an appmethod or firemonkey delphi application, go to the tools/options/provisioning
Then select the build type and provisioning file, then the developer certificate.
That will show the "Applicateion Identifier" it will look like:
Put that in the CFBUNDLER in the project/option/versioninfo
eezis / hist command search
Last active October 1, 2015 08:56
Incremental Search History for the OS X Terminal (type a partial command, up arrow / down arrow to search)
eezis / django question 1
Created November 12, 2012 21:09
Django Question: best way to approach highly conditional page output
I have this framed out and working but I wanted to post this question to see how more experienced Django developers would approach this problem. So to use a simple domain
that everyone can understand, I will frame this as a simple reporting page on a web site where an investor wants to view different classes of assets (stocks, bonds, cds,
etc). I only show three instrument types but like any project it could grow to many more over the project life cycle.
Given the following models . . .
class Investor(models.Model):
first = models.CharField()
blah = models.CharField()
blan = models.CharField()
eezis / sublime find blank lines
Created November 24, 2012 15:57
Sublime Text: find the beginning of blank lines (and optionally replace)
find: ^\n <- select the far left button that toggles regex [.*]
replace: <p>\n
tags: Sublime Text 2, find blank lines, replace blank lines
eezis / clone a virtualenv
Created December 6, 2012 23:13
Copy Clone a virtualenv
##Clone or Copy a virtualenv##
The virtualenvwrapper documentation declares that its feature set includes "Wrappers for managing your virtual environments (create, delete, copy)." But I could not find the copy command anywhere. After fruitless for the command I figred that well designed software usually has a predictable answer:
$cpvirtualenv Env1 Env2
So that's the ticket. Where Env1 is your existing venv and Env2 is the new one you wish to start. So I riff off of Patrick Altman's handy [setup instructions] for new Django projects to create a local stub (where I have swapped in the dev release of Django 1.5) and add utilities like South. Starting new projects is now as simple as . . .
eezis / fkonabstract
Last active December 16, 2015 19:09
No FK on abstract base class
This is a contrived example that illustrates my problem. I want to subclass a base class (PersonBase)
into several different descendant classes. Each person type can have multiple emails and phone numbers
The email and phone class should have a 1..n relationship to all the different people subclasses.
I thought could structure this as follows, but the FK cannot be created on the abstract base class. What
is the best practice for solving this situation . . . instantiate that base model instead of making it
abstract? Or try to implement GenericForeignKeys, or do they introduce more problems than they solve?
Here's the problem in pseudocode . . .