Skip to content

Instantly share code, notes, and snippets.

@pulse00
pulse00 / clone and install github maven projects
Created April 12, 2013 16:07
Shell script to clone and build (maven) github projects. Put a `projects.txt` file into the script folder containing.
#!/bin/sh
###########################
## Shell script to clone a list of github repositories and run `mvn clean install` on each one of them
##
## Usage: put a file called `repos.txt` in the folder of the script containing the repository URLs, line by line:
##
##https://github.com/pulse00/Composer-Eclipse-Plugin.git
##git@github.com:pulse00/Symfony-2-Eclipse-Plugin.git
##etc
@pulse00
pulse00 / JsonSessionHandler.php
Created December 4, 2012 14:24
Serialize php sessions to redis using json as serialization format
<?php
namespace Snc\RedisBundle\Session\Storage\Handler;
/**
* Sessionhandler to serialize PHP sessions into redis using json as
* format.
*
* This way we can read the session in node.js websockets.
*
@pulse00
pulse00 / GithubJsonProtocol.scala
Last active November 4, 2021 10:19
spray-client http post request with custom header and json4s unmarshalling/marshalling
package com.example.actors.github
import spray.httpx.Json4sSupport
import org.json4s.{DefaultFormats, Formats}
/**
* Marshalling/Unmarshalling for the github json format
*
* see http://developer.github.com/v3/oauth/#web-application-flow
*/
function createDispatchAdvice(options) {
if (options.quantity) {
logger(`Setting quantity to ${options.quantity}`);
await DispatchAdviceEnvelope.addDispatchQuantity(options.quantity);
}
// blah blah
}
@pulse00
pulse00 / nginx reverse proxy with dynamic jolokia backend secured by http basic auth
Created April 19, 2013 13:55
Setup nginx as a reverse proxy for jolokia including http basic auth. You might consider - Restrict the backend URL to your jolokia domains - Restrict the `Allow-Origin` Access-Control header to your domain Example Request: http://yourNginxProxy.com?uri=your.dynamic.jolokia.domain/jolokia/
server {
listen 80;
server_name localhost;
access_log /path/to/jolokia.access.log;
location / {
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Origin "*"; # <--- customize this
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
package spock
import org.openqa.selenium.remote.RemoteWebDriver
@Singleton
class BrowserInstance {
def RemoteWebDriver driver
}
<Authority auths={['foo', 'bar']}>
<Button>Click</Button>
</Authority>
### Keybase proof
I hereby claim:
* I am pulse00 on github.
* I am pulse00 (https://keybase.io/pulse00) on keybase.
* I have a public key ASDGEzgLn0m5jyZvWKqK4n6Usu_J2WJuK256bCfqG7unkgo
To claim this, I am signing this object:
// drop spring-data-rest and spring-rest-hateoas into your pom.xml
public interface BookRepository extends MongoRepository<Book, String> {
@Query(" {'name' : { $regex : '.*?0.*', $options: 'i' }} ")
Page<Book> filterBooksByName(@Param("term") String term, Pageable pageable);
}
// curl http://127.0.0.1:8080/book/search/filterBooksByName?term=Potter
// java < 8
if (document != null && document.getOrder() != null && document.getOrder().getAddress() != null && document.getOrder().getAddress().getStreet() != null) {
// boom
)
// java >= 8
Optional<Street> street = resolve(() -> document.getOrder().getAddress().getStreet());
if (street.isPresent() {