Skip to content

Instantly share code, notes, and snippets.

View nicholasblexrud's full-sized avatar

Nick B nicholasblexrud

View GitHub Profile
@nicholasblexrud
nicholasblexrud / commands.vim
Created April 21, 2016 17:08
VI - commands
Select all and delete (actually move to buffer)
:%d
Exit
:x
Paste
CTRL + Insert
@nicholasblexrud
nicholasblexrud / convertbase64.py
Created April 5, 2016 01:00
Encode file content to base64
import base64
with open("yourfile.ext", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
@nicholasblexrud
nicholasblexrud / data.json
Last active March 10, 2016 23:08
logstash file for converting multiline mixpanel events into elasticsearch
{
event: {
"name": "event_test",
"properties": {
"color": "red",
"size": "medium",
"texture": "flannel"
}
}
},{
@nicholasblexrud
nicholasblexrud / sublime_jsbeautify_settings.js
Created February 23, 2016 21:18
sublime jsbeautify settings
{
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"brace_style": "collapse",
"keep_array_indentation": false,
@nicholasblexrud
nicholasblexrud / sublime_jslint_settings.js
Last active February 23, 2016 21:16
sublime jslint settings
{
// an array of options to pass to jslint.
"options" : [
// examples using predef flag.
"--predef", "['angular', 'document', '\\$', '_', 'jQuery', 'FB', 'window', 'Bootstrapper']"
// tolerate missing 'use strict' pragma.
,"--sloppy"
// suggest an indent level of two spaces.
,"--indent", "4"
@nicholasblexrud
nicholasblexrud / elasticsearchbulkimport.js
Created February 12, 2016 17:40
Bulk upload files using Node.js to Elasticsearch
// credit goes to this stack overflow post - http://stackoverflow.com/questions/20646836/is-there-any-way-to-import-a-json-filecontains-100-documents-in-elasticsearch
var elasticsearch = require('elasticsearch'),
fs = require('fs'),
pubs = JSON.parse(fs.readFileSync(__dirname + '/pubs.json')), // name of my first file to parse
forms = JSON.parse(fs.readFileSync(__dirname + '/forms.json')); // and the second set
var client = new elasticsearch.Client({ // default is fine for me, change as you see fit
host: 'localhost:9200',
log: 'trace'
});
@nicholasblexrud
nicholasblexrud / vidyard.js
Last active January 29, 2016 18:52
Track Vidyard videos in Google Tag Manager
<script>
!function (t) {
function e(t) {
var e, r = null,
n = [];
for (e = 0; e < t.length; ++e) !r || r[1] < t[e][0] ? (r && n.push(r), r = [t[e][0], t[e][1]]) : t[e][1] > r[1] && (r[1] = t[e][1]);
return r && n.push(r), n
}
function r(t) {
@nicholasblexrud
nicholasblexrud / main.js
Created December 16, 2015 21:27
Google Analytics Management API
/*globals Analytics, Browser, SpreadsheetApp */
var analyticsManagement = Analytics.Management;
var accounts = analyticsManagement.Accounts;
var properties = analyticsManagement.Webproperties;
var profiles = analyticsManagement.Profiles;
var filters = analyticsManagement.Filters;
var viewFilters = analyticsManagement.ProfileFilterLinks;
var goals = analyticsManagement.Goals;