Skip to content

Instantly share code, notes, and snippets.

View mattandrews's full-sized avatar

Matt Andrews mattandrews

View GitHub Profile
@mattandrews
mattandrews / unique-chars.js
Created November 20, 2015 15:12
Get all unique characters on a webpage
(function(){
var chars = [];
var logCharacters = function(str) {
var letters = str.split('');
letters.forEach(function(l){
l = l.trim(); // we don't need spaces
if (chars.indexOf(l) === -1) {
chars.push(l);
}
@mattandrews
mattandrews / snapchat.sh
Last active November 20, 2016 14:10
Scale, crop and trim videos for Snapchat
#!/bin/bash
# this script does four things:
#
# 1. detects any crop marks (black bars) on the source clip
# 2. uses those crop marks to trim the clip so it has no bars (semi-manual task)
# 3. scales the video up ands crops it (from the center) to snapchat size
# 4. trims the clip to 10s long (might make sense to do this step first?)
INPUT='vid.mp4'
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tango_with_django_project.settings')
import django
django.setup()
from rango.models import Category, Page
def populate():
python_cat = add_cat('Pythons')
@mattandrews
mattandrews / dropout-missing-docs.md
Last active August 29, 2015 14:09
Getting dropout to work

I was really excited to read about Dropout as it seemed great for my project. Unfortunately though the documentation is a bit sparse and, in a couple of spots, wrong. These are the steps I took over a few hours messing around with it to get it to work:

(you'll need pip and virtualenv installed for this to work)

  • mkdir dropout; cd dropout
  • pip install gapy
  • git clone git@github.com:annapowellsmith/dropout.git

At this point you'll need to do some configuration work: in goals.csv you should have something like:

// ==UserScript==
// @name Show New Guardian Comments
// @namespace http://www.theguardian.com/
// @description Shows new comments
// @include http://www.theguardian.com/*
// @version 1
// @grant none
// ==/UserScript==
var prefix = 'gu-discussion-';
@mattandrews
mattandrews / foo.js
Created October 21, 2014 22:23
execute arbitrary shell commands in node
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
// pass in your command line arguments here – this one uses the default local config
exec("converjon --config node_modules/converjon/config/development.yml", puts);
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var urlMajor = "http://anyorigin.com/dev/get?url=http%3A//api.steampowered.com";
var apiKey = "9E19315419261EF7FFDE640368790BAB";
function apiRequest(steamID) {
var that = this;
var deferred = $.Deferred();
<style>
.container {
width: 100%;
}
.row-fluid {
width: 100%;
*zoom: 1;
}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function apiRequest(apiKey) {
var that = this;
var deferred = $.Deferred();
this.response = {};
function ajax() {
$.ajax({
@mattandrews
mattandrews / gist:e9e54e792cad9fe8589e
Created July 9, 2014 10:45
Guardian Content API python example
import requests
def get_content():
api_url = 'http://content.guardianapis.com/'
payload = {
'api-key': 'YOUR-API-KEY-HERE',
'page-size': 10,
'show-editors-picks': 'true',
'show-elements': 'image',
'show-fields': 'all'
}