Skip to content

Instantly share code, notes, and snippets.

View duhow's full-sized avatar
🏠
Working from home

David Girón duhow

🏠
Working from home
View GitHub Profile
@skinp
skinp / tailf.py
Created March 30, 2012 15:24
Tail -f implementation in python
import time
def tailf(filename):
f = open(filename, 'r')
f.seek(0,2)
while True:
line = f.readline()
if not line:
time.sleep(0.1)
continue
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@kylemanna
kylemanna / README-python-service-on-systemd-activated-socket.md
Last active July 2, 2024 10:30 — forked from drmalex07/README-python-service-on-systemd-activated-socket.md
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at ~/tmp/foo/serve.py.

@donmccurdy
donmccurdy / wildcard-to-regexp.js
Last active February 21, 2024 06:49
Wildcard and glob matching in JavaScript.
/**
* Creates a RegExp from the given string, converting asterisks to .* expressions,
* and escaping all other characters.
*/
function wildcardToRegExp (s) {
return new RegExp('^' + s.split(/\*+/).map(regExpEscape).join('.*') + '$');
}
/**
* RegExp-escapes all characters in the given string.
@Luzifer
Luzifer / README.md
Last active May 29, 2024 08:02
Running docker-compose as a systemd service

Running docker-compose as a systemd service

Files

File Purpose
/etc/compose/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/docker-compose-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/docker-compose-reload.timer Timer unit to plan the reloads
/etc/systemd/system/docker-compose.service Service unit to start and manage docker compose
@David-Lor
David-Lor / disablewupdateWatchdog.bat
Created March 7, 2018 17:50
Disable Windows Update "Watchdog"
@echo off
:loop
sc stop "wuauserv"
sc config "wuauserv" start= disabled
timeout 15
goto loop
@XMB5
XMB5 / irconvert.js
Last active March 5, 2024 16:51
Convert from infrared pronto codes to raw codes
//usage: node irconvert.js <pronto hex>
//steps from https://stackoverflow.com/a/27323452
numbers=process.argv[2].split(' ').map(x=>parseInt(x,16))
fullSequenceConverted=[]
carrierFrequency = 1000000/(numbers[1] * .241246)
codeLength = numbers[2]
repeatCodeLength = numbers[3]
for(i=4;i<numbers.length;i++) {
@mcfrojd
mcfrojd / Shield_Intents.MD
Last active July 27, 2024 13:39
Working INTENTS to use with Community Hass.io Add-ons: Android Debug Bridge for your Nvidia Shield TV

Latest Update 2021-03-06 : New image showing the new "Services" in Home Assistant and got some tips from the comments below.

Credits and thanks: Home Assistant Forum users & Github users: @ocso, @wiphye, @teachingbirds, @tboyce1, @simbesh, @JeffLIrion @ff12 @rebmemer @siaox @DiederikvandenB @Thebuz @clapbr @Finsterclown


Start apps on your android device (in the examples below, my Nvidia Shield TV) from Home Assistant

alt text

Starts Youtube App

entity_id: media_player.shield
command: >-
@likeablob
likeablob / running-debian-on-goke-gk710x-devices-chroot.md
Last active March 12, 2022 22:13
Running Debian on Goke GK710x devices (chroot)

WIP

Prerequisites

  • A Goke GK710x-based device(uname -r === 3.4.43-gk)
  • Ubuntu 18.04 as a build environment

Set up the toolchain

  • Install crosstool-ng
$ wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.24.0.tar.xz
$ tar xvf http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.24.0.tar.xz
@triangletodd
triangletodd / README.md
Last active July 6, 2024 01:03
k3s in LXC on Proxmox

On the host

Ensure these modules are loaded

cat /proc/sys/net/bridge/bridge-nf-call-iptables

Disable swap

sysctl vm.swappiness=0
swapoff -a