Skip to content

Instantly share code, notes, and snippets.

View evadne's full-sized avatar
🎣
gone fishing

Evadne Wu evadne

🎣
gone fishing
View GitHub Profile
@evadne
evadne / nec.py
Last active December 31, 2022 20:53
NEC X651UHD External Control
#!/usr/bin/env python3
import select
import socket
import sys
import functools
import datetime
import time
class Display:
@evadne
evadne / lg.py
Last active December 29, 2022 22:20
LG Digital Signage External Control
#!/usr/bin/env python3
import re
import select
import socket
import sys
class WakeOnLan:
def __init__(self, mac, broadcast_ip = "255.255.255.255", broadcast_port = 9):
self.mac_bytes = bytes.fromhex(re.sub('[^a-z0-9]', '', mac))
@evadne
evadne / messages.ex
Last active October 11, 2020 22:30
Stream Iterator
defmodule StreamIterator.Messages do
@moduledoc """
The Stream Iterator can be used to consume items from an Elixir Stream incrementally.
## Examples
### Infinite Streams
When used on infinite streams such as the ones returned by `Stream.cycle/1`, the Stream
Iterator will always return the next item.
@evadne
evadne / script.sh
Created April 28, 2019 19:23
Properly invoke Sublime Text from WSL
function subl () {
SublimePath="/mnt/c/Program Files/Sublime Text 3/subl.exe"
TargetPath=$(readlink -f $1)
HomePath="/home/evadne"
ProjectsPath=$(readlink -f $HomePath/projects)
SublimeProjectsPath=$(readlink -f $HomePath/sublime)
echo "Editing $TargetPath"
case $TargetPath/ in
$ProjectsPath/*)
@evadne
evadne / xmastree.ex
Last active December 16, 2019 06:29
Christmas Trees in Elixir
defmodule Tree do
def print(n) do
for i <- 1 .. n do
p(n - i, " ")
p(i * 2 - 1, "*")
w("\n")
end
p(n - 1, " ")
w("|\n")
end
@evadne
evadne / gettext-sanitise.exs
Created October 13, 2019 15:09
Sanitise Gettext (Elixir) output for version control
# For all .POT files
# Parse PO to internal format
# Remove comments
# Remove duplicate references
# Sort terms by key
# Dump out data
# Bodge data with regex
# Remove leading #: for long reference
# Write file
@evadne
evadne / service_discovery.ex
Created September 12, 2019 20:34
ExAws add-on for AWS Service Discovery
defmodule ExAws.ServiceDiscovery do
@moduledoc """
Minimal module to issue AWS Cloud Map requests with ExAws, which
is used by clustering mechanisms.
"""
alias ExAws.Operation.JSON
@version "2017-03-14"
@namespace "Route53AutoNaming_v20170314"
@evadne
evadne / srcds_rcon.ex
Created November 12, 2018 01:13
Source RCON client in Elixir (using gen_tcp)
defmodule HuddleGateway.External.SourceRemoteControl do
@moduledoc """
A simple gen_tcp based implementation of a Source RCON client
- [Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)
By calling `connect/2`, you can obtain an open TCP socket,
which can then be used with `auth/3` or `exec/3`.
"""
@evadne
evadne / environment.ex
Created November 11, 2018 01:06
Environment Variable based Config Provider
defmodule Huddle.Environment do
use GenServer
@config_entries [
{:huddle_web, HuddleWeb.Endpoint, ~w(http port)a, {:system, "PORT"}}
]
def start_link(args) do
GenServer.start_link(__MODULE__, args)
end
@evadne
evadne / index.html
Created May 7, 2013 22:52
Accordion (Stacked Flex-Box Panels)
<html>
<head>
<meta charset="UTF-8">
<title>Accordion Test</title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
body {