Skip to content

Instantly share code, notes, and snippets.

View akhenakh's full-sized avatar
🏠
Working from home

Fabrice Aneche akhenakh

🏠
Working from home
View GitHub Profile
@akhenakh
akhenakh / update.sh
Created December 15, 2014 22:29
Manually update your FreeBSD systems and ports assume you installed portsnap and portmaster
#!/bin/sh
freebsd-update fetch
freebsd-update install
portsnap fetch update
portmaster -a
pkg clean

Keybase proof

I hereby claim:

  • I am akhenakh on github.
  • I am akh (https://keybase.io/akh) on keybase.
  • I have a public key whose fingerprint is C4E6 D698 01D7 45F5 B6DC B48F 258B 18A5 DF33 C30B

To claim this, I am signing this object:

@akhenakh
akhenakh / NBUnitsNumberFormatter.m
Last active August 29, 2015 14:18
Round numbers to Units 102.000 to 102K 9.900 to 9.9K 1.000.200 to 1M
#import "NBUnitsNumberFormatter.h"
@implementation NBUnitsNumberFormatter
- (NSString *)stringForObjectValue:(id)value; {
if (![value isKindOfClass:[NSNumber class]]) {
return nil;
}
return [self stringForFloat:[value floatValue]];
}
@akhenakh
akhenakh / dev.sh
Last active August 29, 2015 14:19
Compile LedisDB with leveldb and rocksdb support on OSX using Macports
#!/bin/bash
# using macports install:
# port install gcc5 rocksdb leveldb
export CC=/opt/local/bin/gcc-mp-5
export CXX=/opt/local/bin/g++-mp-5
export LEDISTOP=$(pwd)
export LEDISROOT="${LEDISROOT:-${LEDISTOP/\/src\/github.com\/siddontang\/ledisdb/}}"
# LEDISTOP sanity check
if [[ "$LEDISTOP" == "${LEDISTOP/\/src\/github.com\/siddontang\/ledisdb/}" ]]; then
echo "WARNING: LEDISTOP($LEDISTOP) does not contain src/github.com/siddontang/ledisdb"
@akhenakh
akhenakh / gevent_ses.py
Created June 26, 2012 15:06
Async amazon ses with gevent and pool
# 2012 Fabrice Aneche. https://gist.github.com/2996326
# Gevent rewrite with requests
#
# Copyright 2011 The greplin-tornado-ses Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@akhenakh
akhenakh / gist:3376839
Created August 17, 2012 07:57
negative float for flask
from werkzeug.routing import NumberConverter, ValidationError
class NegativeFloatConverter(NumberConverter):
regex = r'\-?\d+\.\d+'
num_convert = float
def __init__(self, map, min=None, max=None):
NumberConverter.__init__(self, map, 0, min, max)
app.url_map.converters['float'] = NegativeFloatConverter
@akhenakh
akhenakh / xbee.c
Created October 26, 2015 22:27
Calculate checksum for an xbee frame on iOS
void checksum(uint8_t *buf, int length, uint8_t *dstbuf, int *retlength) {
uint16_t sum = 0;
// then calculate checksum
for (int i=3;i<length-1;i++) {
sum+= buf[i];
}
sum = CFSwapInt16HostToBig(sum);
uint8_t right = (sum >> 8) & 0xff;
uint8_t checksum = 0xFF - right;
@akhenakh
akhenakh / influxdb
Last active November 4, 2015 22:35
influxdb on freebsd
pkg install bison flex leveldb protobuf gmake ruby ruby-gems bzr mercurial valgrind
export CC=clang
export GOROOT=/home/akh/dev/gosrc
export CGO_CFLAGS="-I/usr/local/include"
export CGO_LDFLAGS="-L/usr/local/lib"
git clone https://github.com/influxdb/influxdb.git
./configure --with-flex=/usr/local/bin/flex --with-bison=/usr/local/bin/bison
# edit Makefile to change the SHELL path to /usr/local/bin/bash
@akhenakh
akhenakh / gist:4623208
Created January 24, 2013 15:34
convert date json entries to datetime objet while loading with json.loads (usefull to import data from Django datadump)
import json
import datetime
import re
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
def datetime_parser(entry):
for k, v in entry.items():
if isinstance(v, basestring) and re.search("^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$", v):
try:
entry[k] = datetime.datetime.strptime(v, DATE_FORMAT)
@akhenakh
akhenakh / PKGBUILD
Created August 2, 2014 00:52
libstemmer archlinux armv6
# Contributor: Andreas Baumann <abaumann at yahoo dot com>
pkgname=snowball-c
pkgver=20140401
pkgrel=1
pkgdesc="Snowball rule-based stemming algorithms (shared lib + stemwords executable)"
arch=('i686' 'x86_64', 'armv6h')
url='http://snowball.tartarus.org/'
license=('BSD')
makedepends=()