Skip to content

Instantly share code, notes, and snippets.

@nl5887
nl5887 / gist:9929911
Created April 2, 2014 08:06
LogglyHandler
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']
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
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 (
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
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 August 28, 2014 19:29
Flashrom support for Winbond W25Q256 (0x4019)
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 August 29, 2014 21:06
LZMA add uncompressed size
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 August 29, 2015 14:05
Function to validate Pyramid authentication tickets (auth_tkt cookie)
import (
"crypto/sha512"
"encoding/hex"
"fmt"
"net/http"
"strconv"
"strings"
)
func authorize(r *http.Request) (userid string, err error) {
### 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 October 26, 2014 21:47
Shows metadata about the current cloud instance. For use in logon scripts or prompts.
#!/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`