Skip to content

Instantly share code, notes, and snippets.

View aldonline's full-sized avatar

Aldo Bucchi aldonline

  • Decoupled Inc
  • San Francisco - Bay Area
View GitHub Profile
@aldonline
aldonline / _.md
Created October 27, 2012 18:15
just another inlet to tributary
@aldonline
aldonline / gist:4410275
Last active December 10, 2015 08:48
Implicit Scala to RDF Value conversions
object rdfStringOps {
import org.openrdf.model._
private lazy val vf = impl.ValueFactoryImpl.getInstance
implicit class RDFStringOps( val str:String ){
def uri = vf createURI str
def lit = vf createLiteral str
@aldonline
aldonline / gist:6958973
Last active December 25, 2015 10:09
GET RDF triples from graph.facebook.com
# triples for a given entity
curl -H "Accept: text/turtle" -X GET "https://graph.facebook.com/aldo.bucchi"
# with metadata ( triples for properties / schema )
curl -H "Accept: text/turtle" -X GET "https://graph.facebook.com/aldo.bucchi?metadata=1"
# of course you can pass an access token to gain access to a broader piece of the graph
curl -H "Accept: text/turtle" -X GET "https://graph.facebook.com/aldo.bucchi&access_token=TOKEN"
# to get a fresh ( but short lived ) token browse to:
@aldonline
aldonline / gist:6959006
Created October 13, 2013 07:06
Given a Java class name get the path of its containing jar
Class.forName(c).getProtectionDomain.getCodeSource.getLocation()
@aldonline
aldonline / gist:6959067
Created October 13, 2013 07:16
polymorphic map() over Google Apps Script iterators and Arrays.
function _map( coll, f ){
var res = []
var isIterator = ( typeof coll.next == "function" )
var isArray = ( coll instanceof Array )
var hasFunc = ( typeof f == "function" )
var append = function(e){ res.push( hasFunc ? f(e) : e ) }
if( isIterator ){
while( coll.hasNext() ){ append( coll.next() ) }
} else if ( isArray ) {
coll.forEach(append)
@aldonline
aldonline / gist:6959105
Created October 13, 2013 07:21
SQL string to Scala Stream[ResultSet] and common Loan pattern usages when dealing with SQL connections
object x {
// stream a sql query
def sql( str:String ):Stream[ResultSet] = withStatement { s =>
val rs = s executeQuery str
new Iterator[ResultSet] { def hasNext = rs.next ; def next = rs }.toStream
}
// loan a sql statement
@aldonline
aldonline / gist:865d2331fb02cdfdd31c
Created October 8, 2014 08:11
scala-js version of radioactive
package radioactivejs
import org.scalajs.dom
import _root_.util.StackVal
import org.scalajs.dom.{Event, HTMLElement}
import scala.collection.mutable
import scala.util.Try
import scala.scalajs.js
radioactive.react(function(){
var userId = getTextInputValue();
var userName = getNameFromServer( userId );
console.log( userName );
})
@aldonline
aldonline / affirmation
Created December 24, 2014 20:57
MuleSoft Contributor Agreement Acceptance by Aldo Bucchi
I, Aldo Bucchi, have read and do accept the MuleSoft Contributor Agreement
at http://www.mulesoft.org/legal/contributor-agreement.html
Accepted on Wed Dec 24 2014 17:57:06 GMT-0300 (CLST)
##1 How-to
Everybody knows what **looping** over a collection is. But do you know what **reducing** a collection means?
No? Are you sure?
It sounds scary. But it is in fact pretty simple. You do it all the time.
Here. Let me show you an example:
<!--code lang=javascript linenums=true-->