Skip to content

Instantly share code, notes, and snippets.

View DispatchTimer.swift
let source = DispatchSource.makeTimerSource()
source.setEventHandler {
NSLog("hello world")
}
source.schedule(deadline: .now(), repeating: .seconds(2))
source.resume()
View bluetooth-agent.sh
### BEGIN INIT INFO
# Provides: bluetooth-agent
# Required-Start: $remote_fs $syslog bluetooth pulseaudio
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Makes Bluetooth discoverable and connectable to 0000
# Description: Start Bluetooth-Agent at boot time.
### END INIT INFO
#! /bin/sh
View udev-bluetooth.sh
#!/bin/bash
#change if you don't use default analog audio out.
#THIS DIDN'T WORK FOR MY PI SO I ADDED A amixer COMMAND BELOW
AUDIOSINK="alsa_output.platform-bcm2835_AUD0.0.analog-stereo"
echo "Executing bluetooth script...|$ACTION|" >> /var/log/bluetooth_dev
ACTION=$(expr "$ACTION" : "\([a-zA-Z]\+\).*")
if [ "$ACTION" = "add" ]
then
View AsyncTaskGps.java
public class AsyncTaskGps extends AsyncTask implements LocationListener {
private Location location;
@Override
protected Object doInBackground(Object... arg0) {
LocationManager lm = (LocationManager) arg0[0];
Looper.prepare();
// Request GPS updates. The third param is the looper to use, which defaults the the one for
// the current thread.
lm.requestSingleUpdate(LocationManager.GPS_PROVIDER, this, null);
View colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent">#00000000</color>
<color name="tab_highlight">#ff9ecfbf</color>
</resources>
View tab_bar_background_selected_pressed.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#ff4ba587" android:width="5dp"/>
<solid android:color="@color/tab_highlight"/>
</shape>
</item>
</layer-list>
View AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/FindMyTrain"
android:name=".FindMyTrainApplication" >
View tab_bar_background_selected.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#ff4ba587" android:width="5dp"/>
</shape>
</item>
</layer-list>