Skip to content

Instantly share code, notes, and snippets.

@plaes
plaes / calc.py
Created September 12, 2015 07:15
#!/usr/bin/env python3
"""
calc.py
~~~~~~~
Simple mathematical expression parser for infix syntax.
Caveats:
- only supports +-/* and ()
- fails with prefix syntax: -1
@plaes
plaes / werkzeug.patch
Created November 9, 2011 18:54
Flask session/cookie disappearance after redirect issue - werkzeug testcase
diff --git a/werkzeug/testsuite/test.py b/werkzeug/testsuite/test.py
index 795de90..5ee8864 100644
--- a/werkzeug/testsuite/test.py
+++ b/werkzeug/testsuite/test.py
@@ -26,7 +26,7 @@ from werkzeug.datastructures import MultiDict
def cookie_app(environ, start_response):
- """A WSGI application which sets a cookie, and returns as a ersponse any
+ """A WSGI application which sets a cookie, and returns as a response any
@plaes
plaes / test.html
Created August 16, 2012 07:38
CSS selector specificity - overriding #id
<!--
256 CSS Classes can Override #id:
* http://news.ycombinator.com/item?id=4388649
* http://stackoverflow.com/questions/2809024/points-in-css-specificity/11934505#11934505
W3C documentation on selector specificity:
* http://www.w3.org/TR/CSS2/cascade.html#specificity
Code samples from:
* http://codepen.io/anon/pen/zbcxs
* http://codepen.io/chriscoyier/pen/lzjqh
Also implementation source from Mozilla and WebKit:
@plaes
plaes / flask_admin_multiple_key_issue.py
Created October 5, 2012 18:26
Flask-Admin InlineForm
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext import admin
from flask.ext.admin.contrib import sqlamodel
from flask.ext.admin.model import InlineFormAdmin
# Create application
app = Flask(__name__)
@plaes
plaes / sqla_hstore_update_bug.py
Created December 13, 2012 16:37
Bug in sqla hstore mutability implementation
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer
from sqlalchemy.dialects.postgres import HSTORE
from sqlalchemy.sql import text
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('postgresql:///hstore_test', echo=True)
session = sessionmaker(bind=engine)()
Base = declarative_base()
@plaes
plaes / cordic_algorithm_plot.c
Last active November 18, 2018 08:10
cordic_algorithm_differences.c
#include <stdio.h>
typedef __signed__ char __s8;
typedef unsigned char __u8;
typedef __signed__ int __s32;
typedef unsigned int __u32;
typedef __u8 u8;
typedef __s8 s8;
@plaes
plaes / plbu_dumps.txt
Created December 8, 2018 11:09
PLBU analysis
- https://gist.github.com/yuq/a17350bd5bf91dbeba24e9deeda9a829 // fbo.260.0
0x00000200, 0x1000010b, 0x00000000, 0x1000010c, /* 0x00000000 */
0x10001000, 0x10000109, 0x00000011, 0x30000000, /* 0x00000010 */
0x1003ec00, 0x28000121, 0x00000000, 0x10000107, /* 0x00000020 */
0x43820000, 0x10000108, 0x00000000, 0x10000105, /* 0x00000030 */
0x43820000, 0x10000106, 0x00010002, 0x60000000, /* 0x00000040 */
0x00002200, 0x1000010b, 0x10152440, 0x81015240, /* 0x00000050 */
0x00000000, 0x1000010a, 0x00000000, 0x1000010e, /* 0x00000060 */
0x3f800000, 0x1000010f, 0x03000000, 0x00040000, /* 0x00000070 */
0x00010001, 0x60000000, 0x00000000, 0x50000000, /* 0x00000080 */
@plaes
plaes / ccu-dump.sh
Created February 12, 2019 09:01
sunxi-mmc2-emmc-fail
#! /bin/bash
function dump {
base=$1
size=$2
for((i=0;i<$size;i=i+4)) ; do
addr=$(($base + $i))
data=$(busybox devmem $addr)
echo $(printf '%#x: %s' $addr $data)
done
}
/* compile with gcc -lm -march=native test_tms34020_setcdp.c */
#include <stdint.h>
#include <stdio.h>
#include <math.h>
uint32_t setcdp(uint32_t dptch) {
uint32_t m_convdp;
// Check whether we're dealing with an even number
if ((dptch & 1) == 0) {
switch(__builtin_popcount(dptch))
### Keybase proof
I hereby claim:
* I am plaes on github.
* I am paf_plaes (https://keybase.io/paf_plaes) on keybase.
* I have a public key ASBEWn5w8BVm9aU5eFFXwrRN7VXsUNZxMybNHkDhTvVyPAo
To claim this, I am signing this object: