Skip to content

Instantly share code, notes, and snippets.

@imranansari
imranansari / introrx.md
Last active August 29, 2015 14:24 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

import hudson.model.*
disableChildren(Hudson.instance.items)
def disableChildren(items) {
for (item in items) {
if ((item.class.canonicalName != 'com.cloudbees.hudson.plugins.folder.Folder')
&& (item.class.canonicalName != 'org.jenkinsci.plugins.workflow.job.WorkflowJob')
// Discard old data v2
def jobs = Hudson.instance.items
for (item in jobs ) {
if (item.class.canonicalName != 'com.cloudbees.hudson.plugins.folder.Folder') {
//println("JOB : " + item.name)
try {
item.logRotator.perform(item);
} catch (Exception e) {
println("Error: in" + item.name + " Reason: " + e)
/*** BEGIN META {
"name" : "Count executors",
"comment" : "Shows the total number of nodes and executors on Jenkins",
"parameters" : [ ],
"core": "1.350",
"authors" : [
{ name : "Andy Pemberton" }
]
} END META**/
import jenkins.model.Jenkins
@imranansari
imranansari / Jenkinsfile
Created January 9, 2016 21:39 — forked from chinshr/Jenkinsfile
Best of Jenkinsfile, a collection of useful workflow scripts ready to be copied into your Jenkinsfile on a per use basis.
#!groovy
# Best of Jenkinsfile
# `Jenkinsfile` is a groovy script DSL for defining CI/CD workflows for Jenkins
node {
}
def splits = splitTests parallelism: [$class: 'CountDrivenParallelism', size: 5], generateInclusions: true
def branches = [:]
for (int i = 0; i < splits.size(); i++) {
def split = splits[i]
branches["split${i}"] = {
node('!master') {
checkout scm
writeFile file: (split.includes ? 'inclusions.txt' : 'exclusions.txt'), text: split.list.join("\n")
writeFile file: (split.includes ? 'exclusions.txt' : 'inclusions.txt'), text: ''
sh 'mvn -s /tmp/settings.xml -B clean test -Dmaven.test.failure.ignore'
@imranansari
imranansari / gist:02f86dfa0efc87552782
Created February 4, 2016 08:30 — forked from rowan-m/gist:1026918
update jenkins Updatecenter from CLI
$ java -jar jenkins-cli.jar -s http://localhost:9000 install-plugin findbugs
findbugs is neither a valid file, URL, nor a plugin artifact name in the update center
No update center data is retrieved yet from: http://updates.jenkins-ci.org/update-center.json
findbugs looks like a short plugin name. Did you mean 'null'?
# Specifying a full URL works!
$ java -jar jenkins-cli.jar -s http://localhost:9020 install-plugin http://updates.jenkins-ci.org/download/plugins/AdaptivePlugin/0.1/AdaptivePlugin.hpi
# Get the update center ourself
node {
// Mark the code checkout 'stage'....
stage 'Checkout'
// Get some code from a GitHub repository
// git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
git url: 'https://github.com/mvpartisans/jenkins-workflows'
println 'getting changesets'
@imranansari
imranansari / README.md
Created March 31, 2016 09:36 — forked from Filirom1/README.md
ElasticSearch dynamic default mapping for nested objects

First start ES with /etc/elasticsearch/default-mapping.json, then index several documents with inner objects

curl -XPOST -d '{"key":{"subkey1":1, "subkey2":1}}' localhost:9200/toto/toto/1
curl -XPOST -d '{"key2":{"subkey1":1, "subkey2":1}}' localhost:9200/toto/toto/2
curl -XPOST -d '{"key3":{"subkey1":1, "subkey2":1}}' localhost:9200/toto/toto/3

Finally, launch the query