Skip to content

Instantly share code, notes, and snippets.

View subnetmarco's full-sized avatar
🦍
Hiring, Thinking, Coding

Marco Palladino subnetmarco

🦍
Hiring, Thinking, Coding
View GitHub Profile
@subnetmarco
subnetmarco / install.sh
Last active October 19, 2021 16:23
Installs OpenResty with "ssl_certificate_by_lua" support
#!/bin/bash
set -o errexit
##############################################################
# Make sure you have the dependencies for building OpenResty #
##############################################################
BUILD_DIR=/tmp
OPENRESTY_VERSION=1.7.10.2rc0
#!/bin/bash
set -o errexit
OPENRESTY_VERSION=1.7.10.2rc0
OPENSSL_VERSION=1.0.2a
OPENRESTY_CONFIGURE_PARAMS=""
# Preparing environment
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
echo "Current directory is: "$DIR
$ sudo luarocks install ansicolors --verbose
os.execute: unzip -n '/Users/marco/.cache/luarocks/https___rocks.moonscript.org/manifest-5.1.zip'
Archive: /Users/marco/.cache/luarocks/https___rocks.moonscript.org/manifest-5.1.zip
inflating: manifest-5.1
Results: 1
1 (number): 0
Installing https://rocks.moonscript.org/ansicolors-1.0.2-3.src.rock...
Using https://rocks.moonscript.org/ansicolors-1.0.2-3.src.rock... switching to 'build' mode
# perl v5.18.2 on MacOSX v10.10.2
echo "hello" > /tmp/file
alias realpath="perl -MCwd -e 'print Cwd::realpath ($ARGV[0]), qq<\n>'"
cd /tmp && realpath file
# Outputs: /private/tmp/ARRAY(0x7fb6518042e8)
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
@subnetmarco
subnetmarco / gist:7883866
Last active December 30, 2015 20:59
Consuming the DB api
var unirest = require('unirest');
function get(url, callback) {
unirest.get(url).end(function (response) {
var result, entity = response.body;
if (entity.data) {
result =[];
for(var t=0;t<entity.data.length;t++) {
result.push(_prepare(entity.data[t]));
}
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
@subnetmarco
subnetmarco / pom.xml
Created November 5, 2013 20:01
Unirest-Java pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<dependencies>
<!-- Unirest -->
@subnetmarco
subnetmarco / gist:5139686
Last active December 14, 2015 19:49
unicorn-ios

Making a request

NSDictionary* headers = [NSDictionary dictionaryWithObjectsAndKeys:@"application/json", @"accept", nil];
    NSDictionary* parameters = [NSDictionary dictionaryWithObjectsAndKeys:@"value1", @"param1", @"value2", @"param2", nil];
    
    HttpJsonResponse* response = [[Unicorn post:^(MultipartRequest* request) {
        [request setUrl:@"http://httpbin.org/post"];
        [request setHeaders:headers];
        [request setParameters:parameters];
@subnetmarco
subnetmarco / gist:5139418
Last active December 14, 2015 19:49
Unicorn-Java samples

Making a request

HttpResponse<JsonNode> jsonResponse = Unicorn.post("http://httpbin.org/post")
  												 .header("accept", "application/json")
													 .field("param1", "value1")
													 .field("param2", "value2")
													 .asJson();
                           
int code = jsonResponse.getCode(); // The HTTP status code