Skip to content

Instantly share code, notes, and snippets.

View palmerabollo's full-sized avatar

Guido García palmerabollo

View GitHub Profile
@palmerabollo
palmerabollo / red.py
Created June 4, 2017 08:32
basic redmine cli in python
#!/usr/bin/env python
# pylint: disable=invalid-name
# http://www.redmine.org/projects/redmine/wiki/Rest_api
# author: guido
import argparse
import json
import os
import urllib
@palmerabollo
palmerabollo / middleware.ts
Created May 14, 2017 16:11
BotBuilder middleware. Access session in send function
import * as builder from 'botbuilder';
import * as logger from 'logops';
export default {
builder: (session: builder.Session, next: Function) => {
logger.info(session.sessionState, 'Session');
// hook
let options = (<any>session).options as builder.ISessionOptions;
let _onSend = options.onSend;
- name: Release chaos monkey
hosts: localhost
gather_facts: true
connection: local
vars:
probability: 5
tasks:
- name: Kill random instances belonging to hostgroups with multiple instances
os_server:
@palmerabollo
palmerabollo / gist:14244c813b67464e9b71
Created March 25, 2016 08:18
YuvImage in Android
public void uploadImage(byte[] data, int width, int height) {
final Context context = contextWeakReference.get();
YuvImage yuvimage = new YuvImage(data, ImageFormat.NV21, width, height, null);
try {
final File outputFile = FileUtils.createExternalFile(Environment.DIRECTORY_DCIM, ".jpeg");
final BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(outputFile));
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 90, os); // compress level = 90
import java.util.Map;
import org.elasticsearch.storm.EsBolt;
import backtype.storm.task.IOutputCollector;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
public class ExtendedESBolt extends EsBolt {
module['exports'] = function echoHttp (hook) {
console.log(hook.params);
console.log(hook.req.path);
console.log(hook.req.method);
console.log(hook.env);
hook.res.end(JSON.stringify(hook.params, true, 2));
};
git pull --rebase origin master
git rebase -i origin/master
--
git commit --amend --no-ff
@palmerabollo
palmerabollo / tokbox.js
Last active December 2, 2015 09:34
Tokbox meet room for Slack
module['exports'] = function tokbox(hook) {
var request = require('request');
// The parameters passed in via the slash command POST request.
var params = hook.params;
console.log(JSON.stringify(params));
// Check that the hook has been triggered from our slash command by
// matching the token against the one in our environment variables.
if (params.token !== hook.env.tokbox_command_token) {
@palmerabollo
palmerabollo / ip-get.js
Last active August 29, 2015 14:27
My first hook.io microservice
module['exports'] = function getExternalIp(hook) {
var store = hook.datastore;
store.get('externalip', function(err, result) {
if (err) {
return res.end(err.message);
}
hook.res.write(JSON.stringify(result));
hook.res.end();
});
};
@palmerabollo
palmerabollo / ip-save.js
Last active August 29, 2015 14:27
My first hook.io microservice
module['exports'] = function saveExternalIp (hook) {
var params = hook.params;
var store = hook.datastore;
var obj = { ip: params.ip, date: new Date() };
store.set('externalip', obj, function(err, result) {
if (err) {
return res.end(err.message);
}
// See http://hook.io/docs#data for more information