Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
typedef struct {
int *pArrNumbers;
long pSum;
int pos;
int len;
int (*funcMovingAvg)(void *self, int nextNum);
} MovingAvg;
@bmccormack
bmccormack / make_vba_multiline.py
Last active September 14, 2017 07:55
Python script to read from standard input to fake multi-line VBA
import fileinput
print 'Dim str As String'
print 'str = ""'
to_print = []
for line in fileinput.input():
line = line.strip('\n')
line_vba = 'str = str & "%s"' % line.replace('"','""')
to_print.append(line_vba)
@bmccormack
bmccormack / preferredLocale.js
Created May 14, 2015 18:53
Get the preferred browser locale (language)
// This is hacky. Have fun.
var identity = function(value) {
return value;
};
var compact = function(list) {
var results = [];
for (var i = 0; i < list.length; i++){
if (identity(list[i])) results.push(list[i]);
@bmccormack
bmccormack / progress.js
Created May 18, 2015 21:38
What % of strings have been translated on my LocalizeJS order?
($('div.item').length - $('div.translation p:contains("Waiting for translation")').length) / $('div.item').length
@bmccormack
bmccormack / uk_to_us.js
Created May 20, 2015 19:33
In Unbabel, change the UK flag icons to US flag icons
$('p.fontStyle2 img[src^="https://s3.amazonaws.com/unbabel-production/static/img/lang/en.png"]').attr('src', 'https://s3.amazonaws.com/unbabel-production/static/img/lang/en-us.png')
@bmccormack
bmccormack / _README.md
Last active August 29, 2015 14:26
On TomTom Runner MySports site, convert Speed in MPH to Pace in minutes per mile

You'll need to click "laps" before running the bookmarklet.

@bmccormack
bmccormack / _readme.md
Last active December 13, 2016 00:54
Trello List Math

##Demo

img

##Installation

Ideally, I'd have a bookmarklet right here that you could just drag to your bookmark window, but I don't have that. You have to make your own. But it's pretty easy.

  1. Go to http://chriszarate.github.io/bookmarkleter/
  2. Check the first two options, "URL-encode..." and "Wrap...". You can leave the others unchecked.
@bmccormack
bmccormack / README.md
Last active April 10, 2025 23:57
Print Trello Cards - Removes cruft so the description and checklists stand out

This little bit of javascript tries to make Trello cards look a bit nicer when printed, especially for checklists. It gets rid of some of the extra UI elements so the content shows through.

To convert to a bookmarklet:

  1. Copy the above code to the code box on this page
  2. Click the button
  3. Drag the link to your bookmark bar.
  4. Optionally, right click on the bookmarklet and change the name to "Print Trello Card".
import json
#via http://stackoverflow.com/a/12944035/166258
def jprint(to_print, indent=4, sort_keys=True):
print json.dumps(to_print, indent=indent, sort_keys=sort_keys)
@bmccormack
bmccormack / README.md
Last active November 2, 2017 18:40
Get count of tags within a Zendesk search Python script

##Before you begin

This is designed for Python 2.7. You'll need to have the requests package installed.

##Setup

  1. Setup 3 files that correspond to the 3 Python files in this gist within a single folder.
  2. In secrets.py, add your Zendesk account email and token. To get a token, from within Zendesk, go to Settings > API > Token Access (Enabled), then click the plus sign near "Active API Tokens".
  3. In query_zendesk_search_stats_tags.py, change SEARCH and ZENDESK_SUBDOMAIN for your needs.
  4. To run, type python query_zendesk_search_stats_tags.py from the command line and press enter. It will take about 2.5 seconds for each 100 tickets in the search. E.g. 811 tickets took ~22 seconds.