Skip to content

Instantly share code, notes, and snippets.

@dthomas
dthomas / Doctrine-Multi-Tenancy.md
Created October 24, 2020 17:25 — forked from CarlosEduardo/Doctrine-Multi-Tenancy.md
Multi-Tenancy (tenant) Strategy for Doctrine ORM
@dthomas
dthomas / 100_base.conf
Created January 16, 2020 10:07 — forked from danackerson/100_base.conf
using nginx + lua + redis for redirects and rewrites
# using such a setup requires `apt-get install lua-nginx-redis` under Ubuntu Trusty
# more info @ http://wiki.nginx.org/HttpLuaModule#access_by_lua
http {
lua_package_path "/etc/nginx/include.d/?.lua;;";
lua_socket_pool_size 100;
lua_socket_connect_timeout 10ms;
lua_socket_read_timeout 10ms;
server {

Keybase proof

I hereby claim:

  • I am dthomas on github.
  • I am derick (https://keybase.io/derick) on keybase.
  • I have a public key whose fingerprint is 0BC3 BD86 A91F 0F9D CAB4 3936 3614 9724 F8C3 E64D

To claim this, I am signing this object:

@dthomas
dthomas / note.md
Created April 22, 2016 04:46 — forked from yang-wei/note.md
Vue.js tips and tricks

Notes: All the examples below are only tested on Vue.js 1.0 (above).

Notes: The examples below use ES6 so it's recommended to use browserify or webpack to easily integrate babel.

when or where can we use this.$el

When you need to access DOM attribute, be careful with the lifecycle. Vue.js has a few useful lifecycle hooks.

Let's say we want to scroll our component to the bottom (imagine it's a long list with overflow-y: auto) once it's instantiate.

@dthomas
dthomas / registration.ex
Created November 16, 2015 04:47
Elixir Phoenix
def create(changeset, repo) do
password = Ecto.Changeset.get_field(changeset, :password)
team_name = Ecto.Changeset.get_field(changeset, :name)
changeset = changeset
|> Ecto.Changeset.put_change(:password_digest, crypt_password(password))
repo.transaction(fn ->
case repo.insert(changeset) do
{:ok, user} ->
team = %Team{name: team_name, owner_id: user.id}
@dthomas
dthomas / Range Match
Created December 2, 2014 17:17
Range Matching in Elixir
def grade(marks) do
cond do
marks in 91..100 -> "A+"
marks in 81..90 -> "A"
end
end
@dthomas
dthomas / application_adapter.js
Created September 20, 2014 13:26
Ember JSON API with rails backend
import DS from 'ember-data';
export default DS.ActiveModelAdapter.extend({
host: 'http://api.example.com',
suffix: '.json',
buildURL: function(type, id, record) {
return this._super(type, id, record) + this.get('suffix');
}
});