Skip to content

Instantly share code, notes, and snippets.

View hussanhijazi's full-sized avatar

Houssan Ali Hijazi hussanhijazi

View GitHub Profile
@hussanhijazi
hussanhijazi / bash_profile_docker
Last active December 11, 2018 16:19
ALIAS - Docker
# ------------------------------------
# Docker alias and function
# ------------------------------------
# Get latest container ID
alias dl="docker ps -l -q"
# Get container process
alias dps="docker ps"
@hussanhijazi
hussanhijazi / SensorActivity.kt
Created November 29, 2018 13:06
Kotlin tempertature/Humidity sensor activity
class SensorActivity : AppCompatActivity() {
companion object {
const val TAG = "SensorActivity"
const val TEMPERATURE_TOPIC = "t0th/temperature"
const val HUMIDITY_TOPIC = "t0th/humidity"
}
val mqttClient by lazy {
MqttClient(this)
@hussanhijazi
hussanhijazi / MqttClient.kt
Created November 29, 2018 13:02
Kotlin Mqtt Client
package br.com.hussan.mqttandroid
import android.content.Context
import android.util.Log
import org.eclipse.paho.android.service.MqttAndroidClient
import org.eclipse.paho.client.mqttv3.IMqttActionListener
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken
import org.eclipse.paho.client.mqttv3.IMqttToken
import org.eclipse.paho.client.mqttv3.MqttCallbackExtended
import org.eclipse.paho.client.mqttv3.MqttClient
@hussanhijazi
hussanhijazi / build.gradle
Last active November 29, 2018 13:02
Add Paho Android library
// no build.gradle do projeto
repositories {
maven {
url "https://repo.eclipse.org/content/repositories/paho-snapshots/"
}
}
// no build.gradle do app
dependencies {
compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0'
@hussanhijazi
hussanhijazi / variables.py
Last active November 29, 2018 12:43
Variables mqtt
temperature_topic = "t0th/temperature"
humidity_topic = "t0th/humidity"
broker_url = "iot.eclipse.org"
@hussanhijazi
hussanhijazi / requirements.txt
Last active November 16, 2018 12:18
Requirements temperature/humidity
Adafruit-DHT==1.3.4
@hussanhijazi
hussanhijazi / start_mqtt.py
Last active November 16, 2018 12:20
Publish temperature/humidity
import paho.mqtt.client as mqtt
import time
import Adafruit_DHT as dht
from variables import *
def mqtt_client_connect():
print("connected to: ", broker_url)
client.connect(broker_url)
client.loop_start()
Debug : 6897BB
Info : 6A8759
Warn : BBB529
Error : FF6B68
Assert : 9876AA
@hussanhijazi
hussanhijazi / README.md
Created February 20, 2018 21:36 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

@hussanhijazi
hussanhijazi / Android Lollipop Widget Tinting Guide
Created August 30, 2016 16:37 — forked from seanKenkeremath/Android Lollipop Widget Tinting Guide
How base colors in Lollipop apply to different UI elements
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
* ripple effect (Lollipop only) -- "colorControlHighlight"
Status Bar:
------------
* background (Lollipop only) - "colorPrimaryDark"