Skip to content

Instantly share code, notes, and snippets.

Avatar

CJ sonicblis

View GitHub Profile
View gist:32f65c4a2c1ae32a4f5cebf08d049467
### Keybase proof
I hereby claim:
* I am sonicblis on github.
* I am chrisjo (https://keybase.io/chrisjo) on keybase.
* I have a public key ASAB0rA0qkj-MBZK_MiEZIj4-o-gdPFPlIGe4pZ3brUZqgo
To claim this, I am signing this object:
View focusWhen Directive
app.directive('focusWhen', function($timeout, $parse) {
return {
link: function(scope, element, attrs) {
var model = $parse(attrs.focusWhen);
scope.$watch(model, function(value) {
if(value === true) {
$timeout(function() {
element[0].focus();
});
}
@sonicblis
sonicblis / asHtml.js
Last active Oct 1, 2015
directive for binding to content editable elements
View asHtml.js
app.filter('html', function ($sce) {
return function (val) {
return $sce.trustAsHtml(val);
};
});
@sonicblis
sonicblis / constrainDate.js
Last active Aug 29, 2015
DateTime Picker constraint directive
View constrainDate.js
app.directive('constrainDate', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, elem, attrs, ngModelCtrl) {
var dRegex;
if (attrs.contrainDate){
dRegex = new RegExp(attrs.constrainDate);
}
ngModelCtrl.$parsers.splice(0, 0, function patternCheck (value) {
@sonicblis
sonicblis / WebApiConfig.cs
Created Dec 25, 2013
Simple camel case formatter change
View WebApiConfig.cs
var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();