Skip to content

Instantly share code, notes, and snippets.

@tkh44
tkh44 / search.scala
Last active August 29, 2015 14:09
this is fun
newOptions += search.map((search: String) => {
val splitString: Array[String] = search.trim.split(" ")
val conjunction = Restrictions.conjunction
for (term <- splitString; disjunction = Restrictions.disjunction; searchString = "%" + term + "%" if term.nonEmpty) {
Array("name", "description") foreach((field) => disjunction.add(Restrictions.like(field, searchString)))
conjunction.add(disjunction)
}
conjunction
@tkh44
tkh44 / typography.scss
Created November 17, 2014 17:53
Some typography options based on material design
$small-phone-width: 321px;
.title,
.subhead,
.display1 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
@tkh44
tkh44 / preload.js
Last active August 29, 2015 14:10
Preload a background image in or use an arbitrary string to do a gmail style first letter with random color.
angular.module('app').directive('preloadBackground', function($document) {
return {
restrict: 'A',
priority: 90,
link: function($scope, $element, $attrs) {
var letter = (s) => s.charAt(0).toUpperCase();
var color = 'rgb(57, 191, 122)';
// uncomment to use please.js
// var color = Please.make_color({
// saturation: 0.7
#!/usr/bin/env node
// This plugin replaces text in a file with the app version from config.xml.
var wwwFileToReplace = "js/build.js";
var fs = require('fs');
var path = require('path');
var rootdir = process.argv[2];
var x = "INIT";
function test() {
var a = arguments[0] === undefined ? x : arguments[0];
return (function () {
var x;
return a;
})();
}
console.log(test());
class Turnip extends PouchDB {
constructor(name, opts, callback) {
super(name, opts, callback);
}
syncRemote(endpoint) {
console.log('syncing: ' + endpoint);
}
}
@tkh44
tkh44 / advanced-search.directive.js
Last active August 29, 2015 14:15
Using es6 classes to create Angular 1.x directives.
const Popover = new WeakMap();
class PackageAdvancedSearch {
constructor($ionicPopover) {
Popover.set(this, $ionicPopover);
this.restrict = 'EA';
//this.templateUrl = 'package/advanced-search.html';
}
@tkh44
tkh44 / stats.json
Created March 11, 2015 04:39
Mavs vs Cavs - 3/10/2015 data
{
"resource": "boxscore",
"parameters": {
"GameID": "0021400948",
"StartPeriod": 1,
"EndPeriod": 10,
"StartRange": 0,
"EndRange": 28800,
"RangeType": 2
},
@tkh44
tkh44 / Job.ts
Created May 12, 2015 05:27
Trying out firebase on the server side with typescript classes.
import Firebase = require('firebase');
const modelRef = new Firebase('urlhere.firebaseio.com');
export class Job {
id:string;
db:Firebase = modelRef.child('jobs');
constructor(private user:string, private inputUri:string, private outputUri:string) {}
@tkh44
tkh44 / interceptor.js
Created May 20, 2015 16:31
example of enabling a interceptor for only one route
Restangular.addFullRequestInterceptor(function authHeaderRequestInterceptor(element, operation, route, url, headers, params, httpConfig) {
if (route === 'secure') {
return {
headers: OAuth.setAccessHeaders(headers)
}
}
});