Skip to content

Instantly share code, notes, and snippets.

@ankurcha
ankurcha / AvroToBigQuery.java
Created Oct 23, 2015
Helper class to convert Apache Avro schema to BigQuery Table schema
View AvroToBigQuery.java
package com.mallo64.dataflow
import com.google.api.client.json.GenericJson;
import com.google.api.services.bigquery.model.TableCell;
import com.google.api.services.bigquery.model.TableFieldSchema;
import com.google.api.services.bigquery.model.TableRow;
import com.google.api.services.bigquery.model.TableSchema;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
import org.apache.avro.Schema;
import org.apache.avro.specific.SpecificRecord;
@terrancesnyder
terrancesnyder / README.md
Last active May 26, 2020
Sankey Barchart with D3
View README.md

Sankey Barchart

Info

Provides a visualization similar to google analytics shopper behavior analytics.

Requires

  • d3js
  • underscorejs
@alediaferia
alediaferia / tiny_uploader.js
Last active May 3, 2022
A tiny snippet for reading files chunk by chunk in plain JavaScript
View tiny_uploader.js
/*
Copyright (c) 2015-2020 Alessandro Diaferia
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@glebcha
glebcha / gulpfile.js
Last active Jul 22, 2020
Gulp task with Less processing (autoprefixer), live reload (browser-sync), javascript (es6, babelify, react), error handling, images optimization, jade templates
View gulpfile.js
'use strict';
/*
Instructions:
1 - Should execute 'npm run prepare'
before the very first run, it will install and symlink all dependencies.
2 - Choose between production 'npm start' and development 'npm run start-dev' modes
(watcher will run immediately after initial run).
@maxsap
maxsap / CustomJwtTokenStore
Last active Apr 10, 2020
Spring Security OAuth2 programmatic configuration.
View CustomJwtTokenStore
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.jwt.JwtHelper;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
View markov.r
# http://cran.r-project.org/web/packages/markovchain/vignettes/an_introduction_to_markovchain_package.pdf
library(markovchain)
initialState <- c(0,1,0)
weatherStates <- c("sunny", "cloudy", "rain")
byRow <- TRUE
trans.probs <- matrix(data=c(0.7, 0.2, 0.1,
0.3, 0.4, 0.3,
0.2, 0.45, 0.35), byrow=TRUE, nrow=3,
dimnames = list(weatherStates, weatherStates))
@miketheman
miketheman / zook_grow.md
Created Jul 22, 2013
Adding nodes to a ZooKeeper ensemble
View zook_grow.md

Adding 2 nodes to an existing 3-node ZooKeeper ensemble without losing the Quorum

Since many deployments may start out with 3 nodes and so little is known about how to grow a cluster from 3 memebrs to 5 members without losing the existing Quorum, here is an example of how this might be achieved.

In this example, all 5 nodes will be running on the same Vagrant host for the purpose of illustration, running on distinct configurations (ports and data directories) without the actual load of clients.

YMMV. Caveat usufructuarius.

Step 1: Have a healthy 3-node ensemble

@cykl
cykl / HLLMergeBenchmark.java
Created Jun 2, 2013
Benchmarks for stream-lib/faster_hll
View HLLMergeBenchmark.java
package bench;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.BenchmarkType;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.State;
View gist:5526393

Puppet with Jenkins

Setup Jenkins

With Puppet:

puppet module install rtyler-jenkins

puppet apply -v -e "include jenkins"

@abramsm
abramsm / gist:5483928
Created Apr 29, 2013
example HLL+ for different p values
View gist:5483928
for (int p = 10; p < 18; p++)
{
HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, 25);
int count = 4200000;
for (int i = 0; i < count; i++)
{
hyperLogLogPlus.offer("i" + i);
}
long estimate = hyperLogLogPlus.cardinality();
double se = count * (1.04 / Math.sqrt(Math.pow(2, p)));