Skip to content

Instantly share code, notes, and snippets.

View andreaseriksson's full-sized avatar

Andreas Eriksson andreaseriksson

View GitHub Profile

New project

mix phoenix.new phoenix_experiments

Create DB

mix ecto.create

Start server

mix phoenix.server

Start console

alias FlowCreatorTest.Repo
alias FlowCreatorTest.Customer
import Ecto.Query
Repo.insert(%Customer{email: "[email protected]", customer_fields: %{"foo_id" => "123"} })
Repo.all(from c in Customer, where: fragment("?->>'foo_id' ilike ?", c.customer_fields, "123"))
Repo.one(from c in Customer, where: fragment("?->>? ilike ?", c.customer_fields, "foo_id", "123"))
@andreaseriksson
andreaseriksson / Install react
Last active December 22, 2015 15:23
Webpack starter project
npm init
npm install --save react react-dom
npm install --save [email protected] react-router@latest
npm install --save redux react-redux
npm install --save redux-thunk
npm install --save-dev redux-devtools redux-logger
npm install --save-dev babel-loader babel-core babel-preset-es2015 babel-preset-react
npm install --save-dev extract-text-webpack-plugin
npm install --save lodash string moment
require 'sidekiq/api'
# get a handle to the default queue
default_queue = Sidekiq::Queue.new
# clear the queue
Sidekiq::Queue.new.clear
# get a handle to the mailer queue
mailer_queue = Sidekiq::Queue.new("mailer")
@andreaseriksson
andreaseriksson / my_component.js.jsx
Last active August 29, 2015 14:23
React component boilerplate
var MyComponent = React.createClass({
propTypes: {
/*
Here we can provide validation for each prop the component will receive.
This also provides a self-documenting reference for how the component
should be used, and what props it needs to be passed in.
*/
arrayProp: React.PropTypes.array,
boolProp: React.PropTypes.bool,
<h1>{{firstName}} {{lastName}}</h1>
<dl>
<dt>Email</dt>
<dd>{{email}}</dd>
<dt>Title</dt>
<dd>{{title}}</dd>
</dl>
@andreaseriksson
andreaseriksson / formated-date.js
Created March 31, 2015 09:57
Formated date-helper
/* global moment:true */
import Ember from 'ember';
export function formattedDate(date, format) {
return moment(date).format(format);
}
export default Ember.Handlebars.makeBoundHelper(formattedDate);
@andreaseriksson
andreaseriksson / Brocfile.js
Created March 31, 2015 09:53
Ember twitter bootstrap
app.import('bower_components/bootstrap/dist/css/bootstrap.css');
@andreaseriksson
andreaseriksson / gist:8347354a1153fc49f677
Created March 10, 2015 17:45
Create hash from array
a = ["a", "b", "c", "d"]
h = Hash[a.map {|x| [x, 1]}]