Skip to content

Instantly share code, notes, and snippets.

class MyFunc
constructor: ->
@name = "default name"
return "Hello from MyFunc(). this.name = " + @name
$get: ->
@name = "new name"
"Hello from MyFunc.$get(). this.name = " + @name
app = angular.module("app", [])
@pkrnjevic
pkrnjevic / gist:6348746
Created August 27, 2013 01:35
Sample angular service using CoffeeScript class.
class ThumbService
constructor: (@$log, @$q, @$resource, @mainService) ->
console.log "ThumbService: constructor called"
@url = @mainService.url(true)+"rest/thumbs/:value/:count"
@thumbs_url = @$resource @url
@sf = []
@lines = []
@thumbs = []
@thumb_size = 150
@max_thumbs = 200
@pkrnjevic
pkrnjevic / fsevents_windows.go
Last active March 24, 2024 10:15
Windows USN Journal sample in Go based on Jeffrey Richter's superb MSDN Journal article. A work in progress, intended to provide similar API to go.fsevents.
//
// File: fsevents_windows.go
// Date: October 29, 2013
// Author: Peter Krnjevic <pkrnjevic@gmail.com>, on the shoulders of many others
//
// This code sample is released into the Public Domain.
//
package fsevents
import (
. $topsrcdir/browser/config/mozconfig
export MOZ_APP_NAME=securebrowser
export MOZ_APP_DISPLAYNAME=SecureBrowser
mk_add_options MOZ_APP_NAME=securebrowser
mk_add_options MOZ_APP_DISPLAYNAME=SecureBrowser
ac_add_options --enable-application=browser
mk_add_options MOZ_OBJDIR=c:/mozilla-objs-msvc
@pkrnjevic
pkrnjevic / catfile.go
Last active March 10, 2016 03:20
One way to concatenate a lot of files quickly (352k in 2m48sec) ... inspired by http://randyzwitch.com/gnu-parallel-medium-data/
// catfile.go
// one possible way to concatenate files quickly
// inspired by http://randyzwitch.com/gnu-parallel-medium-data/
// runtime on mb pro15 (late 2013): 352k files concatentaed in 2m48sec
//
package main
import (
@pkrnjevic
pkrnjevic / stringify.json
Last active June 12, 2017 19:18
Gist showing how to JSON.stringify objects with circular references. Useful when dumping Express requests or dom.
// Note: cache should not be re-used by repeated calls to JSON.stringify.
var cache = [];
JSON.stringify(req, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
package main
import (
"flag"
"log"
"net/http"
"strings"
)
// FileSystem custom file system handler
@pkrnjevic
pkrnjevic / traverse_node.go
Created January 29, 2021 23:17 — forked from xeoncross/traverse_node.go
Simple DOM node traversal in golang using a very useful collector/matcher function
package main
import (
"bytes"
"fmt"
"io"
"strings"
"unicode"
"golang.org/x/net/html"