This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# "Scripting" java. Download jar dependencies if needed. | |
# execute it directly from command line: bash < <(curl -L -k https://raw.github.com/gist/3762558/b941980bf5cf6671c3ff1477982ce370015a8333/scripting.java.sh) | |
if [ ! -f junit-4.11-SNAPSHOT-20120805-1225.jar ]; | |
then | |
wget --no-check-certificate https://github.com/downloads/KentBeck/junit/junit-4.11-SNAPSHOT-20120805-1225.jar | |
fi | |
cat <<-EOF > Scripting.java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import py4j.GatewayServer; | |
public class FindForbiddenEntryPoint { | |
public class Finder{ | |
public boolean jForbidden(String word, char forbidden_1){ | |
return word.indexOf(forbidden_1) > -1; | |
} | |
} | |
Finder finder = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# writing c1 class definition to module mod1 | |
cs = """ | |
class c1(object): | |
att = 1 | |
def m1(self): | |
self.__class__.att += 1 | |
# printing class name, class-id, and the id of the class, which happens to be its memory address | |
print "uno:", self.__class__, "class-id:", id(self.__class__), "att:", self.__class__.att | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pika import BlockingConnection, ConnectionParameters, BasicProperties | |
########################################################################## | |
# RABBITMQ & AMQP INTRO - MESSAGING PATTERNS | |
# http://www.slideshare.net/javierarilos/rabbitmq-intromsgingpatterns | |
# | |
# ******** Escenario 1: | |
# * | |
# Using pika we are going to create a exchange named 'important', bind it to a queue named 'important-jobs'. | |
# Finally we will produce (to exchange) and consume (from queue) a message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Proof of concept of starting Apache Camel routes. | |
Grabs all dependencies, starts Camel and adds two routes to it. | |
- Timer to console | |
- Websockets => RabbitMQ | |
Usage: | |
>>> groovy groovying_camel.groovy | |
End with CTRL+C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymongo | |
from pymongo import Connection | |
from bson.dbref import DBRef | |
from bson.objectid import ObjectId | |
from pymongo.database import Database | |
from datetime import datetime | |
client = pymongo.MongoClient() | |
# use micro database | |
db = client['micro'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################## | |
# THE MICRO MONGODB+PYTHON BOOK | |
# | |
# A simple adaptation to Python + summary of | |
# The Little MongoDB Book: https://github.com/karlseguin/the-little-mongodb-book | |
# | |
# javier arias losada | |
# twitter: @javier_arilos | |
# Usage suggestion: run line by line bu using pydemo project (https://github.com/pablito56/pydemo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* Implementing main examples from Martin Fowler article | |
* on Collection Pipeline programming pattern: | |
* http://martinfowler.com/articles/collection-pipeline/ | |
* with #javascript and underscore.js: http://underscorejs.org/ | |
* | |
* tested with nodejs v0.10.32 | |
* | |
* underscore.js is required: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependency injection used in frameworks like Angular.js, Require.js, Inject.js | |
// There are 3 types of dependency injection : setter, constructor and interface injection. | |
// Needs: a container or injector which can provide dependencies we need. | |
// Reasons for DI: two main reason to favor dependency injection : | |
// * improve maintainability | |
// * make it easier to test | |
var Injector = {dependencies: {}, | |
add : function(qualifier, obj){ | |
this.dependencies[qualifier] = obj;}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'); | |
var esprima = require('esprima'); | |
var fs = require('fs'); | |
var jscode = fs.readFileSync('./src/index.js').toString('utf8'); | |
jscode = jscode.replace(/#!.*\n/,''); //remove shebang (executable js files) | |
console.log(jscode); | |
var tree = esprima.parse(jscode); | |
console.log(util.inspect(tree, {depth: 15, colors: true})); |
OlderNewer