Skip to content

Instantly share code, notes, and snippets.

trait ConfigComponent {
type Config
def config: Config
}
trait MySQLStorageComponent extends StorageComponent with ConfigComponent {
type Config <: MySQLConfig
override def storeUser(user: User) { ... }
override def retrieveUser(id: Int): Option[User] = ...
@tuchida
tuchida / async.js
Created October 30, 2012 15:36
async/await in sweet.js
macro async {
case :{ $rest } => {
$rest
}
case :{ $head $rest ... } => {
$head
async: { $rest ... }
}
case :{ var $x:ident = await($yield:ident, $y ...); $rest ... } => {
(function($yield) {
@bbrowning
bbrowning / TorqueBox on Heroku.md
Last active December 9, 2015 16:19
TorqueBox on Heroku

With Heroku's JRuby support you may have already seen that you can run TorqueBox Lite on Heroku. But, that only gives you the web features of TorqueBox. What about scheduled jobs, backgroundable, messaging, services, and caching?

With a small amount of extra work, you can now run the full TorqueBox (minus STOMP support and clustering) on Heroku as well! I've successfully deployed several test applications, including the example Rails application from our Getting Started Guide which has a scheduled job, a service, and uses backgroundable and messaging.

This example uses TorqueBox 3.0.2, but the instructions may work with other TorqueBox versions.

Steps Required

  1. Create a JRuby application on Heroku, or convert an existing application to JRuby. Make sure your application works on JRuby on Heroku before throwing TorqueBox into the mix.
  2. Add th
@nickmain
nickmain / wktest.rkt
Created March 11, 2013 19:24
Embedding WebKit using Racket Objective-C FFI
#lang racket/gui
(require framework)
(require ffi/unsafe)
(require ffi/unsafe/objc)
(ffi-lib "/System/Library/Frameworks/WebKit.framework/WebKit")
(import-class WebView)
(import-class NSURLRequest)
(import-class NSURL)
(import-class NSString)
@mdub
mdub / syslog-injection.sh
Created May 1, 2013 01:25
Redirect STDOUT and STDERR into syslog, using "logger", and bash process substitution
# Redirect STDOUT/STDERR into syslog
exec > >(logger -p user.info) 2> >(logger -p user.warn)
@dkandalov
dkandalov / plugin.groovy
Last active March 7, 2018 16:11
IntelliJ micro-plugin to wrap selected text to the column width (copied from https://github.com/abrookins/WrapToColumn)
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.LangDataKeys
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.SelectionModel
import com.intellij.openapi.editor.actionSystem.EditorAction
@jamesmacaulay
jamesmacaulay / profiles.clj
Last active November 15, 2023 01:18
My ~/.lein/profiles.clj at the moment.
{:user {:dependencies [[org.clojure/tools.namespace "0.2.3"]
[spyscope "0.1.3"]
[criterium "0.4.1"]]
:injections [(require '(clojure.tools.namespace repl find))
; try/catch to workaround an issue where `lein repl` outside a project dir
; will not load reader literal definitions correctly:
(try (require 'spyscope.core)
(catch RuntimeException e))]
:plugins [[lein-pprint "1.1.1"]
[lein-beanstalk "0.2.6"]
@ztellman
ztellman / gist:5603216
Last active May 26, 2019 17:08
an exploration of the memory implications of call-site caching for protocols
;; let's create a simple protocol that just returns a number
user> (defprotocol NumberP (number [_]))
NumberP
;; now we'll create an implementation that always returns '1'
user> (deftype One [] NumberP (number [_] 1))
user.One
;; unsurprisingly, this type only has a single static value, which wraps the '1'
> (-> One .getDeclaredFields seq)
@tonyg
tonyg / mtl2.rkt
Last active December 18, 2015 22:59
From zero to cooperative threads in 15 lines of Racket code (after <http://www.haskellforall.com/2013/06/from-zero-to-cooperative-threads-in-33.html>)
#lang racket/base
(require data/queue)
(provide fork yield done run-threads)
(define current-runqueue (make-parameter #f))
(define (fork thunk)
(enqueue! (current-runqueue) (lambda () (thunk) (done))))
(define (yield)
@malcolmsparks
malcolmsparks / gist:6044878
Last active December 12, 2017 07:13
MQTT example for Clojure core.async
(ns mqtt-insertion.core
(:require [clojure.core.async :refer :all])
(:import (org.eclipse.paho.client.mqttv3
MqttCallback
MqttAsyncClient
MqttConnectOptions
MqttDeliveryToken
MqttException
MqttMessage
MqttTopic