Skip to content

Instantly share code, notes, and snippets.

View leon's full-sized avatar

Leon Radley leon

View GitHub Profile
@leon
leon / TruncateHtmlExtension.php
Created June 2, 2012 11:25
Symfony 2 Twig Extension that truncates html and preserves tags
<?php
/**
Truncate Html string without stripping tags
register in Resources/config/services.yml with:
services:
truncatehtml.twig.extension:
class: Radley\TwigExtensionBundle\Extension\TruncateHtmlExtension
tags:
- { name: twig.extension }
@leon
leon / test.yml
Created March 1, 2020 17:51
Nrwl NX github actions
name: Test develop and feature branches
on:
push:
branches:
- develop
- "feature/*"
jobs:
test:
@leon
leon / auth.state.ts
Created April 1, 2018 17:55
NGXS auth state
import { Router } from '@angular/router';
import { Action, Selector, State, StateContext, Store } from '@ngxs/store';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase';
import { take, tap } from 'rxjs/operators';
import {
CheckSession,
LoginWithFacebook,
@leon
leon / aframe-map-controls.js
Created October 7, 2017 15:18
Aframe Map Controls
/* global AFRAME THREE */
if (typeof AFRAME === 'undefined') {
throw new Error('Component attempted to register before AFRAME was available.');
}
var radToDeg = THREE.Math.radToDeg;
/**
* Example component for A-Frame.
@leon
leon / index.html
Last active May 11, 2017 11:55
Click bug in d3 v4 and zoom
<!DOCTYPE html>
<meta charset="utf-8">
<svg width="960" height="500"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height"),
transform = d3.zoomIdentity;;
@leon
leon / localstorage.service.ts
Created February 25, 2017 16:22
Angular LocalStorageService
import { Injectable } from '@angular/core';
@Injectable()
export class LocalStorageService {
public localStorage: any;
constructor() {
if (!localStorage) {
throw new Error('Current browser does not support Local Storage');
@leon
leon / secure-http.service.ts
Created December 30, 2016 18:47
Angular Secure HTTP Service (JWT)
import {
Http,
ConnectionBackend,
Headers,
Request,
RequestOptions,
RequestOptionsArgs,
Response,
RequestMethod,
} from '@angular/http';
@leon
leon / secure-http.ts
Created November 14, 2016 14:39
secure-http angular2
import { isString } from 'lodash';
import {
Http,
ConnectionBackend,
Headers,
Request,
RequestOptions,
RequestOptionsArgs,
Response,
RequestMethod,
@leon
leon / Grunt.scala
Last active September 3, 2016 02:23
Playframework 2.2 Grunt Runner
import sbt._
import Keys._
import java.net._
import java.io.File
import play.PlayRunHook
/*
Grunt runner should be in project directory to be picked up by sbt
*/
object Grunt {
@leon
leon / .bash_aliases
Created August 30, 2016 07:42
Bash alias "npmd" installs both dependency and TypeScript defintion files in one go
#
# Install Both Library and TypeScript defintion files in one go
#
npmd() {
#do things with parameters like $1 such as
npm install --save $1
npm install --save-dev @types/$1
}
alias npmd=npmd