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 / cache.m
Last active August 29, 2015 14:00
Force private cache-control requests to be public (cachable) with AFHTTPSessionManager
[sessionManager
setDataTaskWillCacheResponseBlock:^NSCachedURLResponse *
(NSURLSession *session,
NSURLSessionDataTask *dataTask,
NSCachedURLResponse *
proposedResponse) {
NSURLResponse *response = proposedResponse.response;
NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response;
NSDictionary *headers = HTTPResponse.allHeaderFields;
@akhenakh
akhenakh / is_airplay_active.m
Last active August 29, 2015 14:02
airPlayVideoActive property returns false while between two streams, here is a way to detect airplay in all condition from: http://www.ask-coder.com/3162230/how-to-customize-the-airplay-button-when-airplay-is-active
- (BOOL)isAirPlayActive{
CFDictionaryRef currentRouteDescriptionDictionary = nil;
UInt32 dataSize = sizeof(currentRouteDescriptionDictionary);
AudioSessionGetProperty(kAudioSessionProperty_AudioRouteDescription, &dataSize, &currentRouteDescriptionDictionary);
if (currentRouteDescriptionDictionary) {
CFArrayRef outputs = CFDictionaryGetValue(currentRouteDescriptionDictionary, kAudioSession_AudioRouteKey_Outputs);
if(outputs && CFArrayGetCount(outputs) > 0) {
CFDictionaryRef currentOutput = CFArrayGetValueAtIndex(outputs, 0);
CFStringRef outputType = CFDictionaryGetValue(currentOutput, kAudioSession_AudioRouteKey_Type);
return (CFStringCompare(outputType, kAudioSessionOutputRoute_AirPlay, 0) == kCFCompareEqualTo);
@akhenakh
akhenakh / config.json
Created June 27, 2014 00:02
Peco simple config file and examples
{
"Keymap": {
"C-p": "peco.SelectPrevious",
"C-n": "peco.SelectNext",
"Tab": "peco.ToggleSelectionAndSelectNext",
"C-r": "peco.RotateMatcher"
}
}
#alias pll='ls | peco | xargs ls -l'
@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=()
@akhenakh
akhenakh / main.go
Created October 28, 2014 20:09
Test influxDB connection
package main
import (
"fmt"
"github.com/influxdb/influxdb/client"
)
func main() {
c, err := client.NewClient(&client.ClientConfig{
@akhenakh
akhenakh / main.go
Last active August 29, 2015 14:08
influx test 2
package main
import (
"fmt"
"log"
"math/rand"
"net/http"
"time"
"github.com/influxdb/influxdb/client"
@akhenakh
akhenakh / config.js
Created October 28, 2014 22:31
Grafana demo
define(['settings'],
function (Settings) {
return new Settings({
datasources: {
influx: {
type: 'influxdb',
url: 'http://localhost:8086/db/test',
username: 'root',
@akhenakh
akhenakh / reverse
Created November 9, 2014 18:25
reverse a slice in Go
for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
res[i], res[j] = res[j], res[i]
}
@akhenakh
akhenakh / jsontime.go
Created December 8, 2014 01:56
time.Time timestamp JSON in Go
type JSONTime time.Time
func (t JSONTime) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf("\"%d\"", time.Time(t).Unix())
return []byte(stamp), nil
}
// If you are using gob you need to redefine MarshalBinary
func (t JSONTime) MarshalBinary() ([]byte, error) {
return time.Time(t).MarshalBinary()
@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