Skip to content

Instantly share code, notes, and snippets.

View r3a1d3a1's full-sized avatar
🎯
Focusing

r3a1d3a1

🎯
Focusing
View GitHub Profile
@r3a1d3a1
r3a1d3a1 / IdleNotifier.py
Last active June 11, 2023 23:35
Idle Notifier (chmod +x IdleNotifier.py)
#!/usr/local/bin/python3
import os, time
from datetime import datetime
period = 3*60
due = period - 5
while True:
idleSecs = round(float(os.popen("ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print $NF/1000000000; exit}'").read().splitlines()[0]),0)
@r3a1d3a1
r3a1d3a1 / customLayout.json
Last active December 5, 2021 12:18
Unity Dualshock 4 over Bluetooth
{
"name": "DS4 Custom",
"extend": "DualShockGamepad",
"extendMultiple": [],
"format": "HID ",
"beforeRender": "",
"commonUsages": [],
"displayName": "DS4 Custom",
"description": "",
"type": "UnityEngine.InputSystem.DualShock.DualShock4GamepadHID, Unity.InputSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
@r3a1d3a1
r3a1d3a1 / shutdown_button.py
Created July 4, 2021 12:12
Script for shutting down Pi with a push button (GPIO 6 in this case)
# !/bin/python
# Simple script for shutting down the Raspberry Pi at the press of a button.
import RPi.GPIO as GPIO
import time
import os
# Use the Broadcom SOC Pin numbers
# Setup the pin with internal pullups enabled and pin in reading mode.
GPIO.setmode(GPIO.BCM)
@r3a1d3a1
r3a1d3a1 / .js
Last active December 2, 2020 05:39
DPR/Resolution/...
alert(`DPR: ${window.devicePixelRatio},\n` +
`screen.width: ${window.screen.width}, screen.height: ${window.screen.height},\n` + //Least useful
`availWidth: ${window.screen.availWidth}, availHeight: ${window.screen.availHeight},\n` +
`innerWidth: ${window.innerWidth}, innerHeight: ${window.innerHeight}`); //Media queries are based on this
// To match inner dimensions with screen dimensions on mobiles, you can add this in the header:
// <meta name="viewport" content="width=device-width,initial-scale=1">
@r3a1d3a1
r3a1d3a1 / wpa_supplicant-wlan0.conf
Created November 27, 2019 23:20
/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
country=CA
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="DOPE_SSID"
mode=2
frequency=5745
#key_mgmt=NONE # uncomment this for an open hotspot
#delete next 3 lines if key_mgmt=NONE
@r3a1d3a1
r3a1d3a1 / Code.gs
Last active December 2, 2020 05:52
Slack notification for new emails
//query (q) format: https://support.google.com/mail/answer/7190?hl=en
function unreadCnt() {
var response = Gmail.Users.Messages.list('me', {'q':'-category:promotions -category:forums -category:social', 'labelIds':['UNREAD', 'INBOX']});
var unreadIds = response.messages;
unreadIds = (unreadIds === undefined) ? [] : unreadIds.map(getId);
var newCnt = updateSheet(unreadIds);
if (newCnt > 0)
notifySlack(newCnt);