Skip to content

Instantly share code, notes, and snippets.

View artgon's full-sized avatar

Arthur Gonigberg artgon

View GitHub Profile
@artgon
artgon / channels.clj
Created December 22, 2014 21:08
Playing around with channels
(ns channels.core
(:require [clojure.core.async :as async :refer [chan go >! <!!]])
(:gen-class))
(def sum (atom 0))
(defn summing [start end loops]
(let [c (chan loops)
piece (/ end loops)]
(dotimes [i loops]

Keybase proof

I hereby claim:

  • I am artgon on github.
  • I am artgon (https://keybase.io/artgon) on keybase.
  • I have a public key whose fingerprint is 5B49 09A4 9D2D C3E2 690D A9F2 5796 F37D 400B D302

To claim this, I am signing this object:

@artgon
artgon / ObjectifyScalatraAdapter.scala
Created October 6, 2013 01:11
Async Scalatra Objectify
/**
* For each action we map to the Scalatra equivalent block parameter
* though we are still bound to the HttpServletRequest and Response
* currently.
*/
sortedActions.foreach(action => {
def scalatraFunction(route: String) = action.method match {
case Options => options(route)_
case Get => get(route)_
@artgon
artgon / gist:5825602
Created June 20, 2013 19:00
Route description and auth enforcement
angular.module("crazyhorse").config(function ($routeProvider) {
'use strict';
$routeProvider.when('/login', {
templateUrl: 'users/login.html',
controller: 'LoginController',
resolve: {
organization: ['OrganizationService', function (OrganizationService) {
return OrganizationService.resolveOrganization();
@artgon
artgon / gist:5818849
Created June 19, 2013 22:54
lineman output
Running "sass:compile" (sass) task
Verifying property sass.compile exists in config...OK
Files: app/css/main.scss -> generated/css/app.sass.css
Options: loadPath=["vendor/components/foundation/scss","app/css","vendor/css"]
Reading app/css/main.scss...OK
Writing generated/css/app.sass.css...OK
Syntax error: Invalid CSS after " @media ": expected "{", was "#{$small} {"
on line 153 of /Users/artg/dev/matygo/crazyhorse/vendor/components/foundation/scss/foundation/components/_grid.scss
from line 10 of /Users/artg/dev/matygo/crazyhorse/vendor/components/foundation/scss/foundation.scss
from line 67 of standard input
about
abuse
acme
ad
admanager
admin
ads
adsense
adult
adwords
@artgon
artgon / gist:5136878
Last active December 14, 2015 19:29
Parallel collections -- a thing. Results: ..... Series took 100402ms. ..... Parallel took 12868ms.
import scala.collection.parallel.immutable.ParRange
object Parallel extends App {
val bigSet = 1 to 500
val start = System.currentTimeMillis()
bigSet.foreach { i =>
Thread.sleep(200)
if (i % 100 == 0) print(".")
}
actions resource ("courses") policies(
~:[OrganizationAdminPolicy] -> ~:[BadAuthorizationResponder] only ("create", "update", "delete"),
~:[OrganizationUserPolicy] -> ~:[BadAuthorizationResponder] only ("show", "index")
)
actions resource ("concepts") policies (
~:[CourseAdminPolicy] -> ~:[BadAuthorizationResponder] only ("create", "delete"),
~:[CourseInstructorPolicy] -> ~:[BadAuthorizationResponder] only ("update"),
~:[CourseStudentPolicy] -> ~:[BadAuthorizationResponder] only ("show", "index")
)
"be marked completed as done with concurrent requests" in {
var q1, q2 = new FreeFormQuestion()
inTransaction {
q1 = FreeFormQuestionDao.saveOrUpdate(new FreeFormQuestion("is this the real life?", middle.id))
q2 = FreeFormQuestionDao.saveOrUpdate(new FreeFormQuestion("is this just fantasy?", middle.id))
}
val system = ActorSystem("testSystem")
val sarActor = system.actorOf(Props(new Actor {
protected def receive = {
@artgon
artgon / gist:3112158
Created July 14, 2012 17:08
api test
art-macbook:matygo artg$ time curl -v localhost:8081/courses -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"title":"a","description":"2","subject":"","organizationId":1}' -b cookies.txt
* About to connect() to localhost port 8081 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 8081 (#0)
> POST /courses HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8081
> Cookie: MatygoSession=Oixh2Gnrj6E95L497o9ZMw00A6DDMK0YjXCxCSv6RubXQw6SGTV0BYibww4cEmzh
> Content-Type: application/json
> Accept: application/json