Skip to content

Instantly share code, notes, and snippets.

@jtbonhomme
jtbonhomme / forkStream.js
Created September 13, 2016 14:36
This gist shows how to fork a nodejs stream into 2 streams
var spawn = require('child_process').spawn;
var pass = require('stream').PassThrough;
var a = spawn('echo', ['hi user']);
var b = new pass;
var c = new pass;
a.stdout.pipe(b);
a.stdout.pipe(c);
@jtbonhomme
jtbonhomme / responseStream.js
Created September 16, 2016 11:47 — forked from geowa4/responseStream.js
This Node Stream will transform a response stream from request (https://github.com/mikeal/request) to be an object containing the status code, headers, and body. The data is emitted as an error if the response is not a 2xx.
'use strict';
var Base, ResponseTransformStream, twoHundo;
Base = require('stream').Transform;
twoHundo = /^2\d\d$/;
ResponseTransformStream = function (opts) {
Base.call(this, opts);
@jtbonhomme
jtbonhomme / epicStatusShouldBe.groovy
Created October 25, 2016 17:25
This groovy script returns the status the epic of a issue should have according to a hardcoded workflow (to be used as a script field)
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.web.bean.PagerFilter
enableCache = {-> false}
@jtbonhomme
jtbonhomme / solveEpic.groovy
Last active October 26, 2016 12:14
Perfoms Epic trasitions
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
import com.atlassian.jira.bc.issue.IssueService
@jtbonhomme
jtbonhomme / runner.js
Created November 18, 2016 12:13 — forked from phanan/runner.js
Record a webpage with PhantomJS and FFMpeg
// Run this from the commandline:
// phantomjs runner.js | ffmpeg -y -c:v png -f image2pipe -r 24 -t 10 -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart output.mp4
var page = require('webpage').create(),
address = 'http://s.codepen.io/phanan/fullembedgrid/YPLewm?type=embed&safe=true&_t=1424767252279',
duration = 3, // duration of the video, in seconds
framerate = 24, // number of frames per second. 24 is a good value.
counter = 0,
width = 500,
height = 500;
@jtbonhomme
jtbonhomme / fix.md
Created November 27, 2016 13:23
Solving "No rule to make target `/Users/xxxx/.pyenv/versions/3.5.0/lib/libpython3.5.dylib', needed by `dlib.so'. Stop." with pyenv

By default of CPython (and pyenv), the python executable will be generated as static linked and libpython*.dylib will not be generated.

Reinstall the python version and enable framework support (to generate .dylib)

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.5.0
@jtbonhomme
jtbonhomme / aggregate.js
Created December 6, 2016 17:19
aggregate mongodb
db.g5t.aggregate([{$project: { msd:true, actKey:true }},{$group:{_id: {msd:"$msd", actKey: "$actKey"}, total: {$sum : 1}}},{$group:{_id: "$_id.msd", ackKeys: {$push: {actKey: "$_id.actKey", quantity: "$total"}}}},{$out: "g5tend2"}], {allowDiskUse:true});
@jtbonhomme
jtbonhomme / mongo-dump-csv.sh
Created December 6, 2016 17:21 — forked from mderazon/mongo-dump-csv.sh
Export all of Mongodb collections as csv without the need to specify fields
OIFS=$IFS;
IFS=",";
# fill in your details here
dbname=DBNAME
user=USERNAME
pass=PASSWORD
host=HOSTNAME:PORT
# first get all collections in the database
@jtbonhomme
jtbonhomme / bobp-python.md
Created April 16, 2017 12:52 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@jtbonhomme
jtbonhomme / rest.py
Created June 3, 2017 13:08 — forked from tliron/rest.py
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
#!/usr/bin/env python
'''
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
Features:
* Map URI patterns using regular expressions
* Map any/all the HTTP VERBS (GET, PUT, DELETE, POST)
* All responses and payloads are converted to/from JSON for you