Skip to content

Instantly share code, notes, and snippets.

Hendrik Mans hmans

Block or report user

Report or block hmans

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hmans
hmans / application.html.slim
Created Dec 3, 2017
Rails 5.2 Slim Application Layout
View application.html.slim
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 / 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.

@losinggeneration
losinggeneration / main.lua
Last active Oct 13, 2016
A Löve2D main.lua bootstrap file for Moonscript. This loads main.moon during development so moonc isn't required. It also has the nice side effect of automatically being overwritten when moonc is run so the game is ready to be distributed.
View main.lua
--[[
DO NOT MAKE CHANGES TO THIS FILE!
This file will purposefully overwritten when moonc is run. However it provides
an easy way to do Moonscript development without having to use moonc to compile
to Lua.
]]--
--[[
License (MIT)
@hmans
hmans / application.html.slim
Last active Dec 14, 2018
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
View fullbackup.sh
# create a /backups directory
mkdir /backups
# tar everything except system directories (and the backups directory itself)
tar -cvpf /backups/fullbackup.tar --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups .
@hmans
hmans / gist:4492893
Last active Oct 7, 2016
A common environment variable for Ruby version switchers?
View gist:4492893

bash-it and ohmyzsh are two popular frameworks for extending the functionality of Bash and ZSH, respectively. One of their features is a built-in themeing system, and both implementations already try to integrate with some (but not all) Ruby version switchers to display the currently active Ruby as part of the shell prompt. At least in bash-it's case, this integration appears to have started out supporting RVM only, with support for rbenv and rbfu added later. This results in unfortunate code like this example.

We've recently agreed to use .ruby-version instead of switcher-specific files (.rbfu-version, .rbenv-version etc.), maybe we can also find a simple common name for an environment variable containing the currently selected Ruby (including patchlevel)?

Right now, the two alternatives I'm seeing are:

  1. Implementing switcher-specif
@frostney
frostney / gist:4402499
Created Dec 28, 2012
Rudimentary Entity-Component-model in CoffeeScript
View gist:4402499
class Entity
componentList = {}
constructor: (@name = @constructor.name) ->
get: (componentName) ->
if componentName
componentList[componentName]
else
Object.keys componentList
View Gemfile
source 'https://rubygems.org'
# Bundler 1.2.0 allows for specifying the required Ruby version in the Gemfile,
# so let's do that here.
ruby '1.9.3'
# Rails, obviously.
gem 'rails', '3.2.8'
# I love HAML.
You can’t perform that action at this time.