Skip to content

Instantly share code, notes, and snippets.

View leon's full-sized avatar

Leon Radley leon

View GitHub Profile
@leon
leon / nginx.conf
Created June 29, 2012 16:34
Nginx PHP-FPM Symfony 2 minimal config
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
@leon
leon / play.conf
Created March 26, 2012 12:27
Upstart script for Play Framework 2.0
# Upstart script for a play application that binds to an unprivileged user.
# put this into a file like /etc/init/play.conf
#
# This could be the foundation for pushing play apps to the server using something like git-deploy
# By calling service play stop in the restart command and play-start in the restart command.
#
# Usage:
# start play
# stop play
# restart play
@leon
leon / README.md
Last active April 21, 2023 07:04
NX tailwind 3 setup

Tailwind 3 has jit mode and purge built in.

So we only need to specify a list of globs to the content prop of the tailwind.config.js

@nrwl/workspace contains a function called createGlobPatternsForDependencies which can generate an array of globs that you can pass to tailwind.

@leon
leon / my.component.txt
Created March 15, 2023 08:10
Angular Wrap Forms component
Template driven forms:
viewProviders: [
{ provide: ControlContainer, useExisting: NgForm }
]
Reactive
viewProviders: [
{ provide: ControlContainer, useExisting: FormGroupDirective }
]
@leon
leon / convert-hrd-to-dds.sh
Created February 16, 2023 16:24
Convert .hdr to .dds
#!/bin/bash
echo "Converting HDR"
# https://github.com/dariomanesku/cmft
SCRIPT_DIR=${0%/*}
HDR_FILE=${1%%.*}
# 8bits 128x128
@leon
leon / CompareTools.plist
Created August 17, 2022 12:32
GitTower VSCode as diff and merge tool - Juli 2022 Edition
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>ApplicationIdentifier</key>
<string>com.microsoft.VSCode</string>
<key>ApplicationName</key>
<string>Visual Studio Code</string>
<key>DisplayName</key>
@leon
leon / README.md
Last active November 30, 2021 07:58
Angular 2 SecureHttp

When communicating with a backend we often need to add an authentication token and csrf-tokens.

Angular doesn't provide http interceptors as it did before, you instead need to create a subclass of http to get what you are looking for.

By using the SecureHttp service instead of the basic http service we can automatically add this to all outgoing requests.

As the backend often speaks json, this service also automatically converts post request body into json and converts response body's into json as well.

@leon
leon / myapp.conf
Created February 22, 2013 08:23
Ubuntu play nginx configuration
# Upstart file to make play app start when server starts
description "PlayFramework 2"
author "Leon Radley <leon@digiplant.se>"
version "1.0"
env USER=myuser
env GROUP=mygroup
env HOME=/home/myuser/app
/*
AngularJS v1.1.5-77ff108
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
(function(M,X,s){'use strict';function jc(){var b=M.angular;M.angular=kc;return b}function o(b,a,c){var d;if(b)if(H(b))for(d in b)d!="prototype"&&d!="length"&&d!="name"&&b.hasOwnProperty(d)&&a.call(c,b[d],d);else if(b.forEach&&b.forEach!==o)b.forEach(a,c);else if(!b||typeof b.length!=="number"?0:typeof b.hasOwnProperty!="function"&&typeof b.constructor!="function"||b instanceof O||ea&&b instanceof ea||Da.call(b)!=="[object Object]"||typeof b.callee==="function")for(d=0;d<b.length;d++)a.call(c,b[d],
d);else for(d in b)b.hasOwnProperty(d)&&a.call(c,b[d],d);return b}function pb(b){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a.sort()}function lc(b,a,c){for(var d=pb(b),e=0;e<d.length;e++)a.call(c,b[d[e]],d[e]);return d}function qb(b){return function(a,c){b(c,a)}}function Ea(){for(var b=$.length,a;b;){b--;a=$[b].charCodeAt(0);if(a==57)return $[b]="A",$.join("");if(a==90)$[b]="0";else return $[b]=String.fro
@leon
leon / IdNumberValidator.java
Last active March 30, 2020 10:42
Swedish Organisation number / SSN validator
package util;
import org.apache.commons.lang3.StringUtils;
public class IdNumberValidator {
// Invalid Result is used as a return value when the test fails
private static final IdNumberValidatorResult invalid = new IdNumberValidatorResult();
public static IdNumberValidatorResult validate(String value) {