Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicholas Blexrud nicholasblexrud

View GitHub Profile
View commands.vim
Select all and delete (actually move to buffer)
:%d
Exit
:x
Paste
CTRL + Insert
@nicholasblexrud
nicholasblexrud / convertbase64.py
Created Apr 5, 2016
Encode file content to base64
View convertbase64.py
import base64
with open("yourfile.ext", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
@nicholasblexrud
nicholasblexrud / data.json
Last active Mar 10, 2016
logstash file for converting multiline mixpanel events into elasticsearch
View data.json
{
event: {
"name": "event_test",
"properties": {
"color": "red",
"size": "medium",
"texture": "flannel"
}
}
},{
View sublime_jsbeautify_settings.js
{
"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,
View sublime_jslint_settings.js
{
// 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 Feb 12, 2016
Bulk upload files using Node.js to Elasticsearch
View elasticsearchbulkimport.js
// 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 Jan 29, 2016
Track Vidyard videos in Google Tag Manager
View vidyard.js
<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 Dec 16, 2015
Google Analytics Management API
View main.js
/*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;