Skip to content

Instantly share code, notes, and snippets.

View jnx's full-sized avatar
🎅

Christian Hjalmarsson jnx

🎅
View GitHub Profile
@jnx
jnx / dynamic_title_rails.html.erb
Created February 1, 2024 08:34 — forked from rzzo/dynamic_title_rails.html.erb
Simple to set a page title dynamically Ruby on Rails. Set page title with ternary operator
<!-- Set page title with ternary operator -->
<!-- application layout -->
<title><%= content_for?(:page_title) ? yield(:page_title) : default_page_title %></title>
<!-- view -->
<% set_page_title(@page_title) %>
<!-- application helper -->
def set_page_title(title)
@jnx
jnx / Exiftool Canonize
Created February 23, 2021 07:49 — forked from jmuspratt/mediaName
exiftool : rename files in current dir to YYYY-MM-DD-HH-MM-SS-1.ext
# Rename image and MOV files according to EXIF capture date, using YYYY-MM-DD-HH-MM-SS.ext
format.
# Files shot within the same second get copy number added (-1,-2, etc.).
# Video files require a different, so we run exiftool 3 times:
# 1. Exclude MOV files and rename the image files with <CreateDate>.
# 2. Target MOV files and rename them with MediaCreateDate (for iPhone videos).
# 3. Target MOV files and rename them with DateTimeOriginal (for Fuji camera videos).
# Requirements: install the package manager Homebrew (http://brew.sh), then install exiftool (type brew install exiftool in Terminal.app).
# Now open Terminal.app, cd to the relevant directory, and run the command.
@jnx
jnx / express_in_electron.md
Created October 15, 2018 13:33 — forked from maximilian-lindsey/express_in_electron.md
How to run Express inside an Electron app

How to run Express inside an Electron app

You can run your Express app very easily inside your Electron app.

All you need to do is to:

  • place all the files of your Express app inside a new app folder in your_electron_app\resources\app
  • reconfigure the app.js file
  • refactor some relative pathes in your Express app
@jnx
jnx / nginx-config.conf
Created January 3, 2018 08:07 — forked from konovalov-nk/nginx-config.conf
Useful nginx SSL hardened (letsencrypt) config for setting up Rails application with Puma webserver
upstream myappdev {
server unix:///home/your_user/git/dev.your.website.com/shared/sockets/puma-dev.sock;
}
# don't forget to add this to server {..} block
# add_header X-Xss-Protection "1; mode=block";
server {
listen 80;
listen 443 ssl http2;
@jnx
jnx / recursive-division.rb
Created November 9, 2017 19:20 — forked from jamis/recursive-division.rb
An implementation of the "Recursive Division" algorithm for maze generation.
# --------------------------------------------------------------------
# An implementation of the "Recursive Division" algorithm. This is a
# kind of fractal maze algorithm, recursively dividing the maze into
# smaller and smaller cells. This algorithm stops at the integer
# boundary, but theoretically the algorithm could continue infinitely
# to smaller and smaller scales.
#
# Note that this algorithm is implemented as a "wall adder", rather
# than a "passage carver", so the meaning of the bits in each cell
# is reversed: instead of the S bit (for instance) meaning "a passage
@jnx
jnx / README.md
Created February 9, 2017 08:40 — forked from Frost/dnsmasq-and-nginx-can-achieve-pow.cx-like-functionality.md
Getting some equivalent of pow.cx using nginx and dnsmasq on non-Apple *NIX

Install nginx and dnsmasq

Using apt-get/dnf/pkg_add/ports/rpm/pacman/whatever...

Add necessary config files

/etc/dnsmasq.d/dev

# /etc/dnsmasq.d/dev
@jnx
jnx / git_aliases.zsh
Created September 13, 2016 08:36
git and git-flow aliases
# GIT / GIT FLOW ALIASES
alias gft="git fetch --tags"
alias gpt="git push --tags"
alias gcm="git checkout master"
alias gmm="git merge master"
alias gcd="git checkout develop"
alias gmd="git merge develop"
gcf() { git checkout feature/$1; }
<!-- /app/views/admin/users/new_invitiations.html.erb -->
<h2>Send invitation</h2>
<%= form_for @user, :url => send_invitation_admin_users_path do |f| %>
<table style='width: 50%'>
<tr>
<td><%= f.label :first_name %></td>
<td><%= f.text_field :first_name %></td>
<tr>
<td><%=@key.split(".").drop(1) %></td>
<td><%= @value%></td>
</tr>
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rubygems'
gem 'minitest'
require 'minitest/autorun'
require 'action_controller/test_case'
require 'miniskirt'
require 'capybara/rails'