Skip to content

Instantly share code, notes, and snippets.

@givp
givp / filter.js
Created January 5, 2016 05:18
Angular 1.x number abbreviation filter
// Usage in template: My number is {{ value|abbnumber }}
myApp.filter('abbnumber', function() {
return function(input) {
input = parseInt(input);
if (input >= 10000000) {
return (input / 1000000).toFixed(0) + 'M'
}
@givp
givp / alert.h
Created December 23, 2015 00:49
Simple alert view for Watch OS2 in Objective-C
WKAlertAction *action = [WKAlertAction actionWithTitle:@"OK" style:WKAlertActionStyleDefault handler:^{
// do something after OK is clicked
}];
[self presentAlertControllerWithTitle:@"Oops!" message:@"Something happened." preferredStyle:WKAlertControllerStyleAlert actions:@[action]];
@givp
givp / gist:2320ee150fcebb3c8a7b
Last active April 23, 2018 20:18
AngularJS Ellipsis Filter
// Simple AngularJS template filter for showing ellipses for strings of a given length
//
// USAGE IN TEMPLATE
// <div>{{ obj.lastname | ellipsis:10 }}</div>
// filter
app.filter('ellipsis', function() {
return function(input, total) {
if (input.length > total) {
return (input.slice(0, total) + "...");