This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Author: Juho Teperi <juho.teperi@iki.fi> | |
* 2013 | |
* | |
* Holy shit, PHP is horrible. | |
* | |
* Retrieve a post from PhpBB. | |
* Post is selected by 't' query params which is used to select id from $types array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun.uploadImage = function($files, $event, status) { | |
var def = $q.defer(); | |
if (!$files) return def.promise; | |
status.error = null; | |
status.active = true; | |
status.perc = 0; | |
var req; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var newArray = [{foo: 'bar', ...}, ...]; | |
// This will block the UI thread during the rendering. It will become problem if the array has around 1000 items. | |
self.obsArray(newArray); | |
// This way UI should be responsive during the rendering | |
throttledPush(self.obsArray, newArray); | |
function throttledPush(obsArray, array, items, timeout) { | |
items = items || 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use | |
// ko.bindingHandlers.fooSearch = createAutocomplete({load: ...}); | |
// viewModel.idHere = "123"; | |
// viewModel.objHere = {_id: "123", name: "foo"}; | |
// viewModel.objHere.subscribe(function(val) { ... selected obj! ... }); | |
// | |
// <input type="text" data-bind="value: idHere, fooSearch: objHere"/> | |
function createAutocomplete(override) { | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('fooApp') | |
.factory('Util', function() { | |
var utils = {}; | |
// Would be passed by value if $scope.foo was given directly. | |
// As scope is object it is passed by reference. | |
utils.Pending = function(scope, target) { | |
scope[target] = false; | |
this.start = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint camelcase: false */ | |
/* global $ */ | |
// TODO: multiple items | |
angular.module('fooApp') | |
.factory('autocompleteFactory', function() { | |
var factory = function(overwrites) { | |
return { | |
restrict: 'E', | |
replace: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns seitti.server | |
(:require [org.httpkit.server :refer [run-server]] | |
[clojure.tools.namespace.repl :as ns-tools] | |
[seitti.env :as env] | |
[seitti.handler :as handler])) | |
(def http-app (atom nil)) | |
(defn -main [& args] | |
(reset! http-app (run-server handler/app {:port env/port}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmethod restructure-param :path-params | |
[_ {:keys [lets letks parameters] :as acc}] | |
"restructures path-params by plumbing letk notation. generates | |
synthetic defs for the models. example: | |
:path-params [id :- long name :- string]" | |
(if-let [path-params (:path-params parameters)] | |
(let [schema (fnk-schema path-params) | |
model-name (gensym "path-params-") | |
_ (eval `(def ~model-name ~schema)) | |
coerced-model (gensym)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foobar.core | |
(:require [clojure.core.async :as async :refer [chan go timeout >! alts! alts!! <! <!! close!]])) | |
(defn -main [] | |
(let [running (atom true) | |
num-cars 20 | |
ferry-queue (chan) | |
ferry (chan) | |
intersection (chan) | |
msgs (chan) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint node: true */ | |
var gulp = require('gulp'); | |
var plumber = require('gulp-plumber'); | |
var path = 'app/'; | |
// Common | |
var less = require('gulp-less'); | |
function compileLess() { | |
return gulp.src(path + 'styles/main.less') |