Skip to content

Instantly share code, notes, and snippets.

View samwalshnz's full-sized avatar

Sam Walsh samwalshnz

View GitHub Profile

Kogan Smarter Home & Homekit (via Homebridge)

KOGAN smarter home products use Tuya protocols except using a slightly different url and device domain. This means you can use the existing homebridge-tuya plugin for homebridge except using a different process to obtain the device id and keys.

Pre-requisites: First, Install the Kogan Smarter Home app on your idevice then add and configure all your kogan devices. (DO THIS FIRST!).

I am also assuming you already have homebridge setup and running. If not, I strongly reccomend you install homebridge via docker such as https://github.com/oznu/docker-homebridge (Makes it easy to get up and running)

Then:

#!/bin/sh
# default commands for osx to make it nicer to work with
##########################
# General UI?UX settings #
##########################
# Set hostname (hex of MVB9APPS)
sudo scutil --set ComputerName "0x4d56423941505053"
sudo scutil --set HostName "0x4d56423941505053"
@kitze
kitze / conditionalwrap.js
Created October 25, 2017 16:54
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@andy-berry-dev
andy-berry-dev / AbstractModel.php
Last active July 9, 2019 18:52
Changes required to Laravel to allow observing attached/detached events (https://github.com/laravel/framework/pull/14988#issuecomment-267717423)
<?php
use App\Extensions\Relations\BelongsToMany;
abstract class AbstractModel extends Model
{
/*
* This is copied AS IS from \Illuminate\Database\Eloquent\Model@belongsToMany but instead uses our own BelongsToMany class
*/
@andrewstobbe
andrewstobbe / MacOSXSierra:Brew+Apache+Mysql+PHPSwitcher+DNSMasq+SSL.md
Last active July 19, 2021 02:12
Mac OSX Sierra : Brew Apache + Mysql + PHP Switcher + DNSMasq + SSL

Mac OSX Sierra : Brew Apache + Mysql + PHP Switcher + DNSMasq + SSL 👍

Things I had to do using Homebrew to get my local web dev environment back up and running after migration to OSX Sierra + Xcode 8.1.

Note: I used brew reinstall because I had already installed most of this previously under Yosemite. Probably better ways to do this, but this is what worked for me.

brew doctor

brew tap homebrew/dupes
brew tap homebrew/versions
@joecritch
joecritch / object-assign-to-spread.js
Created July 14, 2016 16:29
Converts all Object.assign calls to { ... obj } spread.
// Highly based on an example from https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb
module.exports = function(file, api) {
var j = api.jscodeshift;
var root = j(file.source);
const update = path =>
j(path).replaceWith(j.objectExpression(
flatten(path.value.arguments.map(p =>
p.type === 'ObjectExpression'
@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active June 14, 2024 04:16
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@petcarerx
petcarerx / typescript_cheatsheet.ts
Created March 16, 2016 15:42
Typescript Cheat Sheet - Syntax features and examples
// _____ __ _ _
///__ \_ _ _ __ ___/ _\ ___ _ __(_)_ __ | |_
// / /\/ | | | '_ \ / _ \ \ / __| '__| | '_ \| __|
// / / | |_| | |_) | __/\ \ (__| | | | |_) | |_
// \/ \__, | .__/ \___\__/\___|_| |_| .__/ \__|
// |___/|_| |_|
//Typescript Cheat Sheet: every syntax feature exemplified
//variables are the same as javascript, but can be defined with a type:
var myString:string;

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!

@nmcgann
nmcgann / install-cluster-client.config
Created January 13, 2016 09:10
AWS Elastic Beanstalk .ebextensions config to install Elasticache memcached cluster client (PHP 5.6)
files:
"/home/ec2-user/install-cluster-client.sh":
mode: "000744"
owner: root
group: root
content: |
#!/bin/bash
#hide old ini
if [ -a /etc/php.d/50-memcached.ini ]
then