Skip to content

Instantly share code, notes, and snippets.

@durango
durango / sepsplit.c
Created November 26, 2017 12:46 — forked from xerub/sepsplit.c
/*
* SEP firmware split tool
*
* Copyright (c) 2017 xerub
*/
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@durango
durango / app.html
Created July 8, 2017 17:48 — forked from jdanyow/app.html
Aurelia autocomplete
<template>
<require from="./autocomplete"></require>
<form>
<label class="form-component">
Country
<autocomplete service.bind="countryNameService"
value.bind="countryName"
placeholder="Country">
</autocomplete>
</label>
func authenticateBearer(c *echo.Context) error {
// Look for an Authorization header
if ah := c.Request().Header.Get("Authorization"); ah != "" {
// Should be a bearer token
if len(ah) > 6 && ah[0:6] == "Bearer" {
// Parse rest of header and verify with the secret
if token, err := jwt.Parse(ah[7:], tokenSecret); err == nil && token.Valid {
c.Set("token", token)
return nil
@durango
durango / cloud-nlp.js
Created April 22, 2017 19:16 — forked from sararob/cloud-nlp.js
Call the Cloud Natural Language API from Node.js
'use strict';
const fs = require('fs');
const ndjson = require('ndjson');
const request = require('request');
fs.createReadStream('reddit-comments.json') // Newline delimited JSON file
.pipe(ndjson.parse())
.on('data', function(obj) {
@durango
durango / coordinate.rs
Created January 26, 2017 12:19 — forked from jethrogb/coordinate.rs
Custom Diesel wrapper type example
/// This defines a custom Diesel type for storing a 6-bit integer and a 58-bit
/// integer in the same 64-bit SQL column
use std::error::Error;
use std::fmt;
use std::io::Write;
use diesel::backend::Backend;
use diesel::types::{FromSqlRow,FromSql,ToSql,HasSqlType,IsNull,BigInt,Nullable};
use diesel::expression::AsExpression;
use diesel::row::Row;
#define _GNU_SOURCE 1
#include <sched.h> // sched_setaffinity
#include <stdint.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <assert.h>
#include <sys/time.h>
#define _GNU_SOURCE 1
#include <sched.h> // sched_setaffinity
#include <stdint.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <assert.h>
#include <sys/time.h>
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|ipad|android 3|sch-i800|playbook|tablet|kindle|gt-p1000|sgh-t849|shw-m180s|a510|a511|a100|dell streak|silk|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|
@durango
durango / console.c
Created April 19, 2016 06:59
Basic gamepad controlled UI
/*
Copyright (c) 2016 Micha Mettke
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
@durango
durango / install_ffmpeg_ubuntu.sh
Created April 16, 2016 18:50 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update