Skip to content

Instantly share code, notes, and snippets.

View nicholasblexrud's full-sized avatar

Nick B nicholasblexrud

View GitHub Profile
@jasonrdsouza
jasonrdsouza / combineS3Files.py
Last active June 3, 2023 17:22
Python script to efficiently concatenate S3 files
'''
This script performs efficient concatenation of files stored in S3. Given a
folder, output location, and optional suffix, all files with the given suffix
will be concatenated into one file stored in the output location.
Concatenation is performed within S3 when possible, falling back to local
operations when necessary.
Run `python combineS3Files.py -h` for more info.
'''
@seanislegend
seanislegend / rxjs-example-poll-url.js
Last active August 12, 2019 09:43
RxJS - Poll a URL
let timeout = 1000;
/**
* Create a custom observable that creates a XHR request and returns complete when the promise is fulfilled
*/
let observable = Rx.Observable.create((o) => {
dataService.fetch('test.json')
.then((data) => {
o.onNext(data);
o.onCompleted();
@Filirom1
Filirom1 / README.md
Last active June 9, 2017 10:11
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

@jramsahai
jramsahai / push_to_ga.html
Last active September 13, 2017 17:50
Using Google Analytics Event tracking and the Vidyard player API, we can push player events into Google Analytics to allow us to capture some useful viewership data along side the standard web traffic reporting.
<html>
<head>
<!-- Vidyard player API script -->
<script src="//play.vidyard.com/v0/api.js"></script>
<!-- Google Analytics tracking code -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
<!-- Regexp to recognize fake trafic from JS enabled crawlers
For use in Google Analytics **Filters** on the "ISP Organization" field, corresponding dimension in reporting is "Service Provider"
This lists fits within the 255 characters limit (!doesn't any more, to be optimized) of the filter field if you want to have a Profile/View that will include only that traffic
Most crawlers have Java disabled
You can also disable logging the activity of web monitoring services through a test on user-agent string, see https://gist.github.com/googleanalyticsresoneo/964266
-->
@yyx990803
yyx990803 / nl.sh
Last active March 5, 2024 01:24
npm list only top level modules.
alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"
@balupton
balupton / README.md
Last active June 7, 2021 16:00
Node.js Best Practice Exception Handling
@nuxlli
nuxlli / azure_upload_async.js
Last active August 13, 2019 10:52
Example uploaded file to azure with Q and without Q
var blob = require('azure').createBlobService()
, fs = require('fs')
, Q = require('q');
var options = { publicAccessLevel: 'blob' };
// With Q
var fsLstat = Q.nbind(fs.lstat, fs);
var getContainer = Q.nbind(blob.createContainerIfNotExists, blob);
var streamFile = Q.nbind(blob.createBlockBlobFromStream, blob);
@peterherrmann
peterherrmann / gist:2700284
Last active January 24, 2022 05:18
GASRetry - Exponential backoff JavaScript implementation for Google Apps Script (Library project key: "MGJu3PS2ZYnANtJ9kyn2vnlLDhaBgl_dE")
/**
* Invokes a function, performing up to 5 retries with exponential backoff.
* Retries with delays of approximately 1, 2, 4, 8 then 16 seconds for a total of
* about 32 seconds before it gives up and rethrows the last error.
* See: https://developers.google.com/google-apps/documents-list/#implementing_exponential_backoff
<h3>Examples:</h3>
<pre>//Calls an anonymous function that concatenates a greeting with the current Apps user's email
var example1 = GASRetry.call(function(){return "Hello, " + Session.getActiveUser().getEmail();});
</pre><pre>//Calls an existing function
var example2 = GASRetry.call(myFunction);
@n1k0
n1k0 / gist:1501173
Created December 20, 2011 10:44 — forked from fbuchinger/gist:1501115
PhantomJS: Capturing single dom elements as png files
var page = new WebPage(),
address, output, size;
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs
capture = function(targetFile, clipRect) {
var previousClipRect;
var clipRect = {top: 0, left:0, width: 40, height: 40};
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");