Skip to content

Instantly share code, notes, and snippets.

View gist:9929911
import logging
import traceback
LOGGLY_URL = "https://logs-01.loggly.com/inputs/{{ LOGGLY_ID }}/tag/{{ TAG }}/"
class LogglyHandler(logging.Handler):
def emit(self, record):
trace = None
exc = record.__dict__['exc_info']
View gist:6a8ef81823490f0adbdf
eCos - hal_diag_init
Init device '/dev/BrcmTelnetIoDriver'
Init device '/dev/ttydiag'
Init tty channel: 8130a258
Init device '/dev/tty0'
Init tty channel: 8130a278
Init device '/dev/haldiag'
HAL/diag SERIAL init
Init device '/dev/ser0'
BCM 33XX SERIAL init - dev: 0.2
View gist:41b8e78627de45803fc1
import json
import logging
from pyramid.response import Response
from pyramid.view import view_config, view_defaults
from sqlalchemy.sql.expression import and_, or_, not_
from sqlalchemy.orm.exc import NoResultFound
from .models import (
View gist:41ab4d44d5279755fcb2
mod.directive('mjGridArticle', ['$state', '$location', '$timeout', function($state, $location, $timeout) {
return {
restrict: 'EA',
priority: 0,
scope: false,
link: function (scope, element, attrs) {
var render = function() {
var toRender = {scope:scope, state: $state, location: $location, attrs: attrs };
React.renderComponent(window.GridArticle( {scope:scope, state: $state, location: $location, attrs: attrs }), element[0]);
};
@nl5887
nl5887 / W25Q256.patch
Created Aug 28, 2014
Flashrom support for Winbond W25Q256 (0x4019)
View W25Q256.patch
Index: flashchips.c
===================================================================
--- flashchips.c (revision 1846)
+++ flashchips.c (working copy)
@@ -13137,7 +13137,40 @@
.read = spi_chip_read,
.voltage = {2700, 3600},
},
+ {
+ .vendor = "Winbond",
@nl5887
nl5887 / gist:9670b9af6ba5eef7839f
Created Aug 29, 2014
LZMA add uncompressed size
View gist:9670b9af6ba5eef7839f
import mmap
import sys
with open(sys.argv[1], "r+b") as f:
# memory-map the file, size 0 means whole file
mm = mmap.mmap(f.fileno(), 0)
offset = int(sys.argv[2])
mm[offset:]
f2 = sys.stdout
@nl5887
nl5887 / gist:f654d670e1c28b809740
Last active Aug 29, 2015
Function to validate Pyramid authentication tickets (auth_tkt cookie)
View gist:f654d670e1c28b809740
import (
"crypto/sha512"
"encoding/hex"
"fmt"
"net/http"
"strconv"
"strings"
)
func authorize(r *http.Request) (userid string, err error) {
View gist:6ec23da93b3414709a27
### Keybase proof
I hereby claim:
* I am nl5887 on github.
* I am remcov (https://keybase.io/remcov) on keybase.
* I have a public key whose fingerprint is 655E FFD1 D47E 0C42 D866 FB0C FED8 ECD4 B967 EC86
To claim this, I am signing this object:
@nl5887
nl5887 / motd.sh
Created Oct 26, 2014
Shows metadata about the current cloud instance. For use in logon scripts or prompts.
View motd.sh
#!/bin/sh
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
instanceid=`curl http://169.254.169.254/latest/meta-data/instance-id -s`
amiid=`curl http://169.254.169.254/latest/meta-data/ami-id -s`
hostname=`curl http://169.254.169.254/latest/meta-data/hostname -s`
instancetype=`curl http://169.254.169.254/latest/meta-data/instance-type -s`
kernelid=`curl http://169.254.169.254/latest/meta-data/kernel-id -s`
securitygroups=`curl http://169.254.169.254/latest/meta-data/security-groups -s`