Skip to content

Instantly share code, notes, and snippets.

@anoochit
anoochit / Watch face Ambient mode detection
Last active Aug 29, 2015
Detect Ambient mode to switch Watch face display on Wear devices
View Watch face Ambient mode detection
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 Jul 17, 2014
Watch face for Android Wear
View 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 Jul 30, 2014
wifi cc3000 rest api
View wifi-rest.ino
// 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 Aug 4, 2014
CC3000 WiFi chip & Xively
View lm35-cc3000-xively.ino
/***************************************************
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 Aug 8, 2014
geard orchestration example
View rockmongo_mongo.json
{
"containers":[
{
"name":"rockmongo",
"count":1,
"image":"openshift/centos-rockmongo",
"publicports":[
{"internal":80,"external":6060}
],
"links":[
@anoochit
anoochit / config.yaml
Created Aug 21, 2014
sample cloud config for coreos
View config.yaml
#cloud-config
hostname: coreos01
coreos:
units:
- name: docker.service
command: start
users:
@anoochit
anoochit / dht22.py
Last active Aug 29, 2015
read temperature from dht22 for raspberry pi
View dht22.py
#!/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)
View bluetooth_basic.ino
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 Sep 7, 2014
always read data from bluetooth
View bluetooth_bacic2.ino
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);
View dht22-rest-client.py
#!/usr/bin/python
import sys
import time
import datetime
import requests
import Adafruit_DHT
from time import gmtime, strftime
sensor = Adafruit_DHT.DHT22
pin = 4