Skip to content

Instantly share code, notes, and snippets.

@nnarhinen
nnarhinen / foo-view.js
Last active December 30, 2015 18:39
My view definition not using Backbone views. Simple and easy, no magic involved. Using plain javascript objects as models and transparency.js for rendering
var fs = require('fs'),
fooTemplate = fs.readFileSync(__dirname + '/templates/foo-template.html'),
_ = require('underscore'),
app = require('../app');
var FooView = module.exports = function FooView(model) {
var self = this;
self.model = model;
self.element = $(fooTemplate);
@nnarhinen
nnarhinen / Gruntfile.js
Last active February 11, 2020 09:39
Support html5 pushState (or angular.js html5mode) in a yeoman (grunt-contrib-connect) application.
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
//MODIFIED: add require for connect-modewrite
var modRewrite = require('connect-modrewrite');
grunt.initConfig({
grunt.initConfig({
///blabla
browserify: {
basic: {
src: ['<%= yeoman.app %>/scripts/main.js'],
options: {
transform: ['brfs']
},
dest: '.tmp/scripts/application.js'
}
@nnarhinen
nnarhinen / some.html
Created November 26, 2013 21:26
Make your plain javascript objects and arrays observable with just jquery, jsfiddle: http://jsfiddle.net/EeGkU/3/
<p>Observable plain javascript objects with jQuery (rendered with transparency.js)</p>
<ul class="items">
<li class="title"></li>
</ul>
<p>Wait for a few seconds and watch the last item in list</p>
@nnarhinen
nnarhinen / foo.conf
Created November 8, 2013 08:00
Upstart script for running node as non-root service
description "Foo application Node.js service"
author "Niklas Närhinen"
setuid foo
start on (local-filesystems and net-device-up)
stop on shutdown
respawn
respawn limit 5 60
@nnarhinen
nnarhinen / scan.bash
Created October 9, 2013 17:57
Scan documents as pdf with gamma correction
#!/bin/bash
#find out scanner model with scanimage -L
scanimage -d hp3900:libusb:003:005 --resolution=600 --mode=Gray > raw.pnm
#gamma correction (fiddle around with the value suitable for your printer)
convert raw.pnm -gamma 0.5 out.pnm
#convert to pdf
gm convert out.pnm out.pdf
{
"name": "ea:user",
"title": "User",
"description": "Shows information about a user",
"available_properties": [
{
"name": "real_name",
"type": "string"
},
{
@nnarhinen
nnarhinen / navigation.cljs
Created October 1, 2013 22:17
Some experimental code for navigation handling with core.async
(ns myapp.main
(:require [jayq.core :refer [on $] :as j]
[cljs.core.async :as async
:refer [<! chan put!]]
[crate.core :as crate])
(:require-macros [cljs.core.async.macros :as m :refer [go alt!]]
[crate.def-macros :refer [defpartial]]))
(def $container ($ :.main-container))
@nnarhinen
nnarhinen / routes.clj
Created September 24, 2013 21:31
Use sessions with compojure
(ns server.routes
(:use compojure.core
server.views
[ring.middleware.json :only (wrap-json-response)]
ring.middleware.session
[ring.util.response :only (response)]
[hiccup.middleware :only (wrap-base-url)])
(:require [compojure.route :as route]
[compojure.handler :as handler]
[compojure.response :as response]))
@nnarhinen
nnarhinen / main.cljs
Last active December 22, 2015 23:29
Todolist application in ClojureScript
(ns cljs_todolist.hello
(:require [crate.core :as crate]
[yolk.bacon :as b]
[yolk.ui :as ui]
[jayq.core :refer [$] :as j])
(:use-macros [crate.def-macros :only [defpartial]]))
(def $content ($ :#content))