Skip to content

Instantly share code, notes, and snippets.

Avatar

Hendrik Mans hmans

View GitHub Profile
@hmans
hmans / Clicker.elm
Last active Jan 17, 2018
Very simple (and unfinished) incremental clicker game written in Elm.
View Clicker.elm
module Clicker exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Time exposing (Time, second)
-- MODEL
@hmans
hmans / elixir_phoenix_notes.md
Last active Apr 4, 2018
Notes on learning Elixir and Phoenix
View elixir_phoenix_notes.md

Notes on learning Elixir and Phoenix

Just some assorted notes I've made while digging into Phoenix, Elixir and friends. I'm coming from a strong Rails background, so many of these will refer to features from that framework.

Views / Templates

Biggest difference from Rails?

Unlike Rails, where rendering is almost always performed by a template file, the responsibility of rendering a response in Phoenix lies with a view module (that typically corresponds to the current controller module.) This view module will typically offer a whole bunch of render functions (matching different parameters, first and foremost the template name.) Templates (found in web/templates/) will directly compile into such functions.

@hmans
hmans / application.html.slim
Created Nov 8, 2016
Rails 5.0 Application Layout, Slim-style
View application.html.slim
doctype html
html
head
title My App
meta name="viewport" content="width=device-width, initial-scale=1.0"
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
= csrf_meta_tags
body
@hmans
hmans / Disabling Rails generators you don't need.md
Last active Oct 11, 2016
Disable some Rails generators you don't need to run all the time
View Disabling Rails generators you don't need.md

Disable some Rails generators you don't need to run all the time

Reasoning: the Rails default is to generate a separate .coffee (or .js) and .scss file for each controller you add to your application. This may not be what you need. Adding the following lines to your development environment's configuration file will prevent this from happening:

# In config/environments/development.rb
config.generators.stylesheets = false
config.generators.javascripts = false
config.generators.helper      = false
View fizzbuzz.ex
defmodule FizzerBuzzer do
def go do
go(1)
end
def go(num) when num == 101 do
end
def go(num) do
cond do
@hmans
hmans / gist:cd5e2e989ceff7ff163a
Last active Aug 29, 2015
Ruby Configuration Thingy
View gist:cd5e2e989ceff7ff163a
class ConfigurationProxy
attr_reader :data
def initialize
@data = {}
end
def method_missing(method, *args, &blk)
if args.any? || block_given?
if block_given?
@hmans
hmans / gist:cf18d182c51fb9191df6
Created Jun 29, 2014
PostgreSQL Large Object Data Store for Dragonfly
View gist:cf18d182c51fb9191df6
# This is a Dragonfly data store using PostgreSQL Large Objects. It appears to work fine,
# but I ended up using a different solution in my project. Anyway, here you go.
#
class PostgresDataStore
def write(content, opts={})
data_oid = store_lo(content.data)
meta_oid = store_lo(Marshal.dump(content.meta))
"#{data_oid}/#{meta_oid}"
end
View EndlessSpace.cs
using UnityEngine;
using System.Collections;
public class EndlessSpace : MonoBehaviour {
public GameObject tile;
public GameObject player;
private float width, height;
private Vector3 offset, up, right, down, left;
@hmans
hmans / application.html.slim
Last active Apr 14, 2020
Application layout for Rails (4 and 5), Slim style.
View application.html.slim
doctype html
html
head
title My App
meta name="viewport" content="width=device-width, initial-scale=1.0"
= stylesheet_link_tag "application", media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag "application", 'data-turbolinks-track' => true
= csrf_meta_tags
body
@hmans
hmans / gmail.css
Created Oct 2, 2013
A user stylesheet for Google Mail that hopefully makes the whole thing slightly less terrible.
View gmail.css
/* This is a simple user stylesheet for the current version of Google Mail.
I think it makes Gmail's design slightly less terrible. Use it with your
favorite user stylesheet plugin or the excellent MailPlane client.
-- Hendrik Mans <hendrik@mans.de> */
/* Mails */
tr.zA {
height: 1.65em;
}
You can’t perform that action at this time.