Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View hmans's full-sized avatar
🚀
Let's go!

Hendrik Mans hmans

🚀
Let's go!
View GitHub Profile
@hmans
hmans / application.html.slim
Created April 30, 2019 08:06
Rails 6.0 Application Layout using Slim
doctype html
html
head
title My Rails 6.0 App
= csrf_meta_tags
= csp_meta_tag
meta name="viewport" content="width=device-width, initial-scale=1.0"
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
@hmans
hmans / gamedevcheatsheet.md
Last active June 29, 2018 13:26
Game Development Cheat Sheet
@hmans
hmans / app.cr
Created April 25, 2018 18:54
Happy + Crystal = Crappy
require "crappy"
class AppHandler
include HTTP::Handler
include Crappy::Routing
include Crappy::Rendering
def call(context)
crappy do
within "api" do
@hmans
hmans / application.html.slim
Last active October 23, 2018 21:14
Rails 5.2 Application Layout using Slim
doctype html
html
head
title My Rails 5.2 App
= csrf_meta_tags
= csp_meta_tag
meta name="viewport" content="width=device-width, initial-scale=1.0"
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
@hmans
hmans / application.html.slim
Created December 3, 2017 09:32
Rails 5.2 Slim Application Layout
doctype html
html
head
title My Rails 5.2 App
meta name="viewport" content="width=device-width, initial-scale=1.0"
= csrf_meta_tags
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
body
@hmans
hmans / main.coffee
Last active April 19, 2017 10:56
Inferno.js memoization decorator function using NO_OP
memoize = require './memoize'
# By using memoize, the following functional component will only update
# when the props passed into it have changed. Please note that this assumes
# that the actual prop values are immutable objects, since we don't perform
# any deep equality checks.
logPanel = memoize ({log}) ->
h '#log-panel', [
for line in log
@hmans
hmans / about.md
Created April 19, 2017 09:12
Elm-flavoured Incremental Game Framework?

Here's a tiny, but fully functional (ha) incremental game framework. Some notes:

  • Built with CoffeeScript. I like CoffeeScript very much.
  • Inspired by Elm, minus the types, obviously.
  • Uses Inferno.js as its rendering layer. It's extremely fast.
  • main.coffee dispatches to a state object, because games typically employ finite state machines. With a single state, this is unneccessary, of course.

-- Hendrik Mans, hendrik@mans.de

@hmans
hmans / info.md
Last active September 25, 2017 01:23
RESTful Rails Controller, 2017 Edition

This is a RESTful Rails controller, implementing all 7 RESTful actions. In my Rails apps, 9 out of 10 controllers will end up looking like this.

class PostsController < ApplicationController
  load_and_authorize_resource

  def create
    @post.save and redirect_to(@post) or render(:new)
  end
@hmans
hmans / Clicker.elm
Last active January 17, 2018 16:38
Very simple (and unfinished) incremental clicker game written in 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 April 4, 2018 12:33
Notes on learning Elixir and Phoenix

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.