Skip to content

Instantly share code, notes, and snippets.

@Papipo
Papipo / docker-aliases.sh
Created September 30, 2022 07:22 — forked from jgrodziski/docker-aliases.sh
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #
@Papipo
Papipo / Dock
Created February 18, 2018 12:36
FROM elixir:1.6.1
RUN mix local.hex --force
ENV WORKDIR /app
WORKDIR $WORKDIR
COPY mix.exs mix.lock $WORKDIR/
RUN mix deps.get
RUN mix deps.compile
import React from 'react'
import {
AppRegistry,
StyleSheet,
Button as ButtonN,
Text as TextN,
TextInput as TextInputN,
View as ViewN
} from 'react-native'
# Aggregates are just collections of command functions, which emit events,
# and event handlers, which mutate state.
# In order to hold state, they should be also structs.
# There is no new() function because aggregates aren't supposed to appear
# out of the blue, they are always the result of a command.
# In this case, %OpenAccount{}.
defmodule Bank.Account do
defstruct [:account_number, :balance]
iex(1)> System.cmd("which docker", [])
** (ErlangError) erlang error: :enoent
(elixir) lib/system.ex:552: System.cmd("which docker", [], [])
@Papipo
Papipo / create_projection_versions.ex
Created October 20, 2016 11:05 — forked from slashdotdash/create_projection_versions.ex
Building projections with Ecto using Commanded event handlers
defmodule Projections.Repo.Migrations.CreateProjectionVersions do
use Ecto.Migration
def change do
create table(:projection_versions, primary_key: false) do
add :projection_name, :text, primary_key: true
add :last_seen_event_id, :bigint
timestamps
end
@Papipo
Papipo / occluder-test.js
Created November 13, 2015 12:52
Mithril occlusion culling for variable height elements.
var test = require('tape'),
m = require("mithril"),
occluder = require("lib/occluder");
function template(child) {
return m(".child", {key: child, style: {height: child + "px"}}, child);
}
function view(children, o) {
o = o || occluder();
@Papipo
Papipo / occluder.js
Last active November 11, 2015 14:27 — forked from barneycarroll/occluder.js
Occlusion culling in Mithril
function occluder(){
var fresh = true;
var item = 40;
var offset = 0;
var scroller = window;
var viewport = 0;
return {
scroller : function scrollerConfig( el, init, context ){
if( arguments.length < 2 || !init || fresh ){
function store(opts) {
var list = [];
var local = opts.local;
var remote = opts.remote;
function replace(items) {
if (items.length) {
list = items;
}
return items;
@Papipo
Papipo / model-excerpt.js
Last active October 28, 2015 23:38
Testing cached m.request
var cache = [];
model.latest = function() {
makeRequest().then(replace); // If I put this on the function below, the tests still pass
return function() { // but when using mithril, I would get infinite requests
return cache;
};
};
function makeRequest() {