Skip to content

Instantly share code, notes, and snippets.

@GlennPegden2
GlennPegden2 / ghc.py
Created February 18, 2018 19:32
My handler code that sits between fauxmo and LGTV / XBox One / SkyQ to enabled Alexa to control the devices.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Must be python2 as lgtv currently doesn't work with python3
#Uses the following (make sure they are installed and set up
#Sky-Q - https://github.com/dalhundal/sky-remote-cli (NodeJS) - I also ported his node sample for the getPower code
#LGTV - https://github.com/klattimer/LGWebOSRemote (Python)
#
#Credit to Schamper for the code the xbox remote-wake code is based on - https://github.com/Schamper/xbox-remote-power
#!/bin/bash
# Don't put duplicate lines in the history
export HISTCONTROL=ignoredups
# Store a lot history entries in a file for grep-age
shopt -s histappend
export HISTFILE=~/long_history
export HISTFILESIZE=50000

Git Cheat Sheet

Commands

Getting Started

git init

or

@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active October 27, 2024 19:13
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active August 30, 2024 08:37
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@davidfowl
davidfowl / gist:3173128
Created July 24, 2012 22:36 — forked from jmangelo/gist:3173109
MethodInfo.Invoke is slow... open instance delegate to the rescue
using System;
using System.Linq;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program