Skip to content

Instantly share code, notes, and snippets.

View jvalentik's full-sized avatar
:octocat:
coding

Johny jvalentik

:octocat:
coding
View GitHub Profile
@jvalentik
jvalentik / hue_dimmer_switchV2.yaml
Last active May 29, 2025 06:03 — forked from cptkng/hue_dimmer_switchV2.yaml
ZHA - Philips Hue Dimmer Switch - V2
blueprint:
name: ZHA - Philips Hue Dimmer Switch - V2
description: |
Control lights with a Philips Hue Dimmer Switch.
The top "on" button behaviour is adjustable. By default it behaves like this:
- Press it while the light is off, and the light will turn on to the last set brightness.
- Press it again while the light is on, the light will turn to the fixed brightness setting.
Dim up/down buttons will change the brightness smoothly and can be pressed
@jvalentik
jvalentik / CategoryRecycleAdapter.kt
Created February 25, 2018 12:58
Android RecyclerView pattern
package jvk.org.coderswag.adapters
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import jvk.org.coderswag.R
@jvalentik
jvalentik / CategoryAdapter.kt
Created February 25, 2018 12:57
Android ViewHolder pattern
class CategoryAdapter(private val context: Context, private val categories: List<Category>) : BaseAdapter() {
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val categoryView : View
val holder : ViewHolder
if (convertView == null) {
categoryView = LayoutInflater.from(this.context).inflate(R.layout.category_list_item, null)
holder = ViewHolder()
holder.categoryImage = categoryView.findViewById(R.id.categoryImage)
holder.categoryName = categoryView.findViewById(R.id.categoryTitle)
@jvalentik
jvalentik / gist:c34cc617d6524df29181
Created February 20, 2016 22:39
JAVA HttpServer
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
public class PingPong {
public static void main(String[] args) throws Exception {