Skip to content

Instantly share code, notes, and snippets.

@pulsation
pulsation / gist:3853211
Created October 8, 2012 15:50
[Enyo+Cordova] Taking a picture with a phone and send it to a REST service such as a CouchDB database.
navigator.camera.getPicture(
function (imageData) {
var request = new enyo.Ajax({
url: "http://my_server_address:5984/mobility_camera_test/",
method: "POST",
handleAs: "json",
contentType: "application/json",
postBody: '{"image": "' + imageData + '"}'
});
request.go({});
@pulsation
pulsation / closure_inheritance.js
Last active December 11, 2015 16:09
Experimenting with javascript closures: inheritance
mynamespace = window.mynamespace || {};
mynamespace.Parent = function (param) {
var _privateProperty = param;
return {
getTwice : function () {
return _privateProperty * 2;
}
@pulsation
pulsation / gist:6114018
Created July 30, 2013 15:30
Is the use of "val that = this" correct?
package eu.pulsation.alarmsandbox
import android.accounts.{AccountAuthenticatorActivity, AccountManager}
import android.os.Bundle
import android.app.Activity
import android.widget.{Button, EditText}
import android.view.View.OnClickListener
import android.view.View
import android.accounts.Account
@pulsation
pulsation / replication_task.json
Last active December 21, 2015 17:49
CouchDB replication task that works with views, to be put in _replicator database.
{
"_id": "replication_task",
"source": "https://user:pass@example.iriscouch.com:6984/source-database",
"target": "target-database",
"user_ctx": {
"user": "admin",
"roles": [
"_admin"
]
},
@pulsation
pulsation / hash_accu.scala
Last active December 22, 2015 20:08
Accumulate hash values using Scala
val myHashList = List("at work" -> 7, "at home" -> 5, "at david's" -> 3)
val myNewValue = "at home" -> 1
myHashList :+ myNewValue groupBy (_._1) map {case (k, v) => (k, v.map(_._2).sum)} toList
// List(at home -> 6, at work -> 7, at david's -> 3)
@pulsation
pulsation / rss_dc.scala
Created September 20, 2013 13:13
Use scala.xml._ to parse atom rss according to dublin core namespaces
package rss
import scala.xml._
class Feed(val url: String) {
def downloadItems(): List[Item] = {
val root = XML.load(url)
(root \\ "item").map(buildItem(_)).toList
}
def buildItem(node: Node): Item = {

Tic Tac Toe !

To play Tic Tac Toe ! with Cypher queries.

wargames
@pulsation
pulsation / wssetoken.php
Last active August 29, 2015 14:10 — forked from borisguery/wssetoken.php
Test WSSE token
#!/usr/bin/env php
<?php
function wsse_header($username, $password) {
$nonce = hash_hmac('sha512', uniqid(null, true), uniqid(), true);
$created = new DateTime('now', new DateTimezone('UTC'));
$created = $created->format(DateTime::ISO8601);
$digest = sha1($nonce.$created.$password, true);
return sprintf(
class App {
public static class SuperClass {}
public static class SubClass extends SuperClass {}
public static <T, U extends T> U returnSub(T sup, U sub) {
return sub;
}
public static void main(String[] args) {
SuperClass parent = new SuperClass();
@pulsation
pulsation / extend.sh
Last active May 26, 2019 00:10 — forked from wvengen/extend.sh
Extend non-HiDPI external display above HiDPI internal display
#!/bin/sh
# extend non-HiDPI external display on DP* above HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`