Skip to content

Instantly share code, notes, and snippets.

View justindujardin's full-sized avatar
☂️
You can do it. I believe in you.

Justin DuJardin justindujardin

☂️
You can do it. I believe in you.
View GitHub Profile
@justindujardin
justindujardin / cool-gl.component.ts
Created November 11, 2017 22:07
canvas component
import {
AfterViewInit, Component, ElementRef, OnDestroy, ViewChild
} from '@angular/core';
@Component({
selector: 'cool-gl',
template: `
<canvas #lookupTag></canvas>`
})
export class CoolGLComponent implements AfterViewInit, OnDestroy {
@justindujardin
justindujardin / card.component.ts
Last active November 1, 2017 23:08
How to build a summary/details card view transition in Angular and NativeScript. From: https://youtu.be/hK5oHdq9dx4
@Component({
moduleId: module.id,
selector: 'lol-card',
template: `
<GridLayout [@container]="state$ | async" (tap)="toggle()">
<AbsoluteLayout>
<Image [@image]="state$ | async"></Image>
<Gradient [@gradient]="state$ | async"></Gradient>
</AbsoluteLayout>
</GridLayout>
@justindujardin
justindujardin / tsClassInjectedController.html
Created May 15, 2014 13:20
Using Typescript Classes with Angular Directives
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<meta charset="utf-8">
<title>Using Typescript Classes with Angular Directives</title>
</head>
<body ng-app="yourApp">
<custom-directive ng-click="ctrl.clear()">{{text}}</custom-directive>
</body>
@justindujardin
justindujardin / complexRequireDirective.js
Last active May 26, 2018 16:16
AngularJS Directive require ancestor AND this controller
var app = angular.module('yourApp');
app.directive("parentDirective", function(){
return {
restrict: "A",
controller:function(){
this.test = function(){
console.log("parentController - okay");
}
}
};
@justindujardin
justindujardin / zigzagmixin.less
Created April 7, 2014 21:14
LESS ZigZag Border
/*
border-serrated - a zig zag triangle border with linear gradient
original SASS version: https://gist.github.com/justinmc/9837998
*/
.border-top-serrated(@size, @colorOuter) {
& {
position: relative;
padding-top: @size;
}
&:before {
@justindujardin
justindujardin / socketio-race-client.js
Created March 19, 2014 03:42
Socket.IO: ERROR: "client not handshaken" explanation
/*
A simple socket.io client that will run server side and connect to the above server
repeatedly, for as long as you leave it running.
When the server runs with a low-latency Redis database, you will see nothing but
repeated "Connected" messages in the console. When the server connects to a Redis
data store that has even a modest amount of latency more than the client, you will
see some connections established properly, and others fail with the error:
ERROR: "client not handshaken"
@justindujardin
justindujardin / generate_docs.sh
Created March 17, 2012 20:15
Docco template for filtering out private doc sections
docco -t private_filter.jst private_filter.coffee
@justindujardin
justindujardin / HSLColorBlender.as
Last active September 24, 2015 23:07
Actionscript HSL Color blend texture
public static function hslColorBlendMaterial(target:BitmapData,colorMask:BitmapData,color:uint,darkLuminance:Number=0.0):void
{
Profiler.enter("BitmapFeatureRenderer.colorBlendMaterial");
var hslColorMask:HSL = new HSL();
var hslTarget:HSL = new HSL();
if(colorMask != null && !colorMask.rect.equals(target.rect))
throw new Error("only supports color blending same size textures");
// Calculate a single HSL color for the mask.
HSL.convertRGBToHSL(color,hslColorMask);
@justindujardin
justindujardin / CSharp.xml
Created June 16, 2010 23:48
VSProjectDescription Schema and Xml Examples
<?xml version="1.0" encoding="utf-8" ?>
<VSProjectDescription Name="CSharp" TypeGuid="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
xmlns="http://schemas.dujardinconsulting.com/bsls/2010/VSProjectDescriptionSchema.xsd">
<ConditionlessProperties>
<ProductVersion>8.0.30703</ProductVersion>
<FileAlignment>512</FileAlignment>
</ConditionlessProperties>
<RootElements>
@justindujardin
justindujardin / BingImageQuery.cs
Last active September 4, 2015 14:45
Use LINQ to parse image query results from Google, Bing, and Yahoo search engines.
namespace SilverShorts
{
/// <summary>
/// Implement a Microsoft Bing IImageQuery provider
/// </summary>
public class BingImageQuery : IImageQuery
{
/// <summary>
/// Bing Image Query requires a valid ApiKey
/// See: http://www.bing.com/developer/