Skip to content

Instantly share code, notes, and snippets.

View MoriTanosuke's full-sized avatar

Carsten MoriTanosuke

View GitHub Profile
@MoriTanosuke
MoriTanosuke / LdapRouteTest-context.xml
Last active December 19, 2015 02:28
Embedded Apache DS LDAP and Spring Security
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
@MoriTanosuke
MoriTanosuke / pulse_irq.ino
Last active December 14, 2015 12:19
Arduino project with pulsesensor and microSD shield.
volatile int rate[10]; // used to hold last ten IBI values
volatile unsigned long sampleCounter = 0; // used to determine pulse timing
volatile unsigned long lastBeatTime = 0; // used to find the inter beat interval
volatile int P =512; // used to find peak in pulse wave
volatile int T = 512; // used to find trough in pulse wave
volatile int thresh = 512; // used to find instant moment of heart beat
volatile int amp = 100; // used to hold amplitude of pulse waveform
volatile boolean firstBeat = true; // used to seed rate array so we startup with reasonable BPM
volatile boolean secondBeat = true; // used to seed rate array so we startup with reasonable BPM
@MoriTanosuke
MoriTanosuke / pom.xml
Created October 22, 2012 05:20
fitbit-cli-example POM
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.kopis</groupId>
<artifactId>fitbit-cli-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.fitbit</groupId>
<artifactId>fitbit4j</artifactId>
@SuppressWarnings("unchecked")
protected void addError(String key, ActionErrors actionErrors, ActionError errorToAdd){
if(StringUtils.isNotBlank(key) && actionErrors != null && errorToAdd != null){
Iterator<ActionError> it = actionErrors.get(key);
boolean okToAdd = true;
//empty iterator returned where key not in action errors so no need for null check
while(it.hasNext()){
ActionError error = it.next();
if(StringUtils.equals(error.getKey(), errorToAdd.getKey())){
okToAdd = false;
@MoriTanosuke
MoriTanosuke / sanitize.sh
Last active February 25, 2016 15:56
Fix broken filenames. Removes all non-alphanumeric characters from directory and filenames from a given directory and copies them into the current directory. I'm using this to help me organize and backup my music on multiple devices.
#!/bin/bash
#
# Sanitizes all files in the given path
# and makes them lowercase too.
#
# param 1: source directory
# param 2: target directory
shopt -s extglob;
@MoriTanosuke
MoriTanosuke / merge.sh
Created August 14, 2012 19:35
Simple BASH script to merge pictures into a single picture, transparently overlayed
#/usr/bin/env bash
# expecting a list of files "trans_vlcsnap-000??.png" that I want to merge into
# file with all images transparently overlayed
#
# need to create transparent images first, but the transparency has to be exponential
# otherwise the single images will blend out too fast in the merged result
for i in $(seq 23 59); do
prev=$(( $i-1 ))
@MoriTanosuke
MoriTanosuke / fitbit_cb.php
Created May 31, 2012 06:06
Fitbit and oauth-php
<?php
require_once 'library/OAuthRequester.php';
// get store
$dboptions = array('server' => 'server', 'username' => 'username', 'password' => 'password', 'database' => 'database');
$store = OAuthStore::instance("MySQL", $dboptions);
$consumer_key = $_REQUEST['consumer_key'];
$oauth_token = $_REQUEST['oauth_token'];
$oauth_verifier = $_REQUEST['oauth_verifier'];
@MoriTanosuke
MoriTanosuke / FitbitConsoleApplication.java
Created May 29, 2012 16:05
Simple fitbit API client using fitbit4j
import java.io.IOException;
import org.joda.time.LocalDate;
import com.fitbit.api.FitbitAPIException;
import com.fitbit.api.client.FitbitAPIEntityCache;
import com.fitbit.api.client.FitbitApiClientAgent;
import com.fitbit.api.client.FitbitApiCredentialsCache;
import com.fitbit.api.client.FitbitApiCredentialsCacheMapImpl;
import com.fitbit.api.client.FitbitApiEntityCacheMapImpl;
@MoriTanosuke
MoriTanosuke / cleanup.rb
Created March 18, 2012 16:52
Delete all your tweets from Twitter with Ruby
require 'twitter'
require 'peach'
USERNAME = '' # put your twitter username here
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_SECRET
@MoriTanosuke
MoriTanosuke / gallery.sh
Created February 5, 2012 13:40
Recursive create a gallery from all images in a directory