Skip to content

Instantly share code, notes, and snippets.

View anoochit's full-sized avatar

Anuchit Chalothorn anoochit

View GitHub Profile
@anoochit
anoochit / Watch face Ambient mode detection
Last active August 29, 2015 14:04
Detect Ambient mode to switch Watch face display on Wear devices
Handler handler = new Handler(Looper.getMainLooper());
final DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
displayManager.registerDisplayListener(new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int displayId) {
}
@Override
@anoochit
anoochit / Watch face for Android Wear
Created July 17, 2014 12:21
Watch face for Android Wear
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.redlinesoft.hellowear">
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
@anoochit
anoochit / wifi-rest.ino
Created July 30, 2014 15:46
wifi cc3000 rest api
// Import required libraries
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <CC3000_MDNS.h>
#include <aREST.h>
// These are the pins for the CC3000 chip if you are using a breakout board
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
@anoochit
anoochit / lm35-cc3000-xively.ino
Created August 4, 2014 03:58
CC3000 WiFi chip & Xively
/***************************************************
This is a sketch to use the CC3000 WiFi chip & Xively
Written by Marco Schwartz for Open Home Automation
Modified code for read temperature from LM35
****************************************************/
// Libraries
@anoochit
anoochit / rockmongo_mongo.json
Created August 8, 2014 13:02
geard orchestration example
{
"containers":[
{
"name":"rockmongo",
"count":1,
"image":"openshift/centos-rockmongo",
"publicports":[
{"internal":80,"external":6060}
],
"links":[
@anoochit
anoochit / config.yaml
Created August 21, 2014 07:21
sample cloud config for coreos
#cloud-config
hostname: coreos01
coreos:
units:
- name: docker.service
command: start
users:
@anoochit
anoochit / dht22.py
Last active August 29, 2015 14:05
read temperature from dht22 for raspberry pi
#!/usr/bin/python
import sys
import time
import Adafruit_DHT
sensor = Adafruit_DHT.DHT22
pin = 4
while True:
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
@anoochit
anoochit / hc05.ino
Last active December 5, 2015 03:11
set bluetooth at command
/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.com)
*/
@anoochit
anoochit / bluetooth_basic.ino
Created September 6, 2014 16:57
bluetooth basic
char BYTE;
int LED = 13; // LED on pin 13
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
void loop() {
Serial.println("Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:");
@anoochit
anoochit / bluetooth_bacic2.ino
Created September 7, 2014 00:17
always read data from bluetooth
char BYTE;
void setup() {
Serial.begin(9600);
}
void loop() {
while (!Serial.available()); // stay here so long as COM port is empty
BYTE = Serial.read(); // read next available byte
Serial.print(BYTE);