Skip to content

Instantly share code, notes, and snippets.

import evdev
from evdev import *
import time
#dev =evdev.InputDevice('/dev/input/by-id/usb-SM_SM-2D_PRODUCT_HID_KBW_APP-000000000-event-kbd')
dev =evdev.InputDevice('/dev/input/event1')
dev.grab()
print(dev)
# for event in dev.read_loop():
# if event.type == ecodes.EV_KEY:
@dovy
dovy / test.txt
Last active November 1, 2021 14:25
#!/usr/bin/python
import struct
import time
import sys
infile_path = "/dev/input/event" + (sys.argv[1] if len(sys.argv) > 1 else "0")
"""
FORMAT represents the format used by linux kernel input event struct
See https://github.com/torvalds/linux/blob/v5.5-rc5/include/uapi/linux/input.h#L28
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk
gcloud init
[
{
"slug": "yith-woocommerce-brands-add-on",
"name": "YITH WooCommerce Brands Add-On",
"version": "1.3.11",
"active_installs": 10000,
"url": "https://yithemes.com/themes/plugins/yith-woocommerce-brands-add-on/",
"match_text": [
"\t\t\t\tif( register_block_type( \"yith/{$block}\", $block_args ) ){"
]
@dovy
dovy / fetch_from_cloud_logging.sh
Created November 20, 2018 21:47
It's a REAL pain to figure out how to grab the data from Google cloud logging. This script lets you grab historic data and save locally so you can process since Cloud Logging Sync's won't do anything historic.
gcloud beta logging read "resource.type=\"dataflow_step\" resource.labels.job_id=\"2018-11-13_09_13_59-6912497806535022683\" OR \"timestamp>=\\\"2018-11-12T00:00:00Z\" OR \"timing:\" timestamp<=\"2200-01-01T00:00:00.000000000Z\" timestamp<\"2018-11-20T20:20:01.065Z\"" --format=json --limit 100000 | jq -rnc --stream 'fromstream(1|truncate_stream(inputs)) | .jsonPayload.message' >> gcs.txt
@dovy
dovy / gcs_cluster_status.py
Last active February 16, 2018 23:01
Utility to make it easy to monitor a single cluster or a prefix name for multiple clusters using gcs dataproc. Be sure to run `pip install beautifultable` before running.
#!/usr/bin/env python
import json
import argparse
from beautifultable import BeautifulTable
import commands
import time
import os
def print_jobs(cluster_name):
@dovy
dovy / README.md
Last active November 8, 2017 15:23
A simple utility to help work with LDS.org Hometeaching for district leaders. Now updated to work for Presidency members as well.

What is this?

This is a utility to properly output all the assignments and teachers in a way that would allow easy email or text message generation.

Instructions

  • Open Google Chrome (Should work on Firefox or Safari as well)
  • Go to this website: https://www.lds.org/htvt/?lang=eng#/companionships
  • Right click on the page, and click on Inspect
  • Click on the Console tab at the top.
  • Copy the code above and paste it in the console (starts with a &gt; symbol, button of the window).
@dovy
dovy / get_table_query.js
Last active July 25, 2017 21:50
Use this to get a SQL statement for a BigQuery table. You can run use this in the console of chrome/firefox when the desired BigQuery table is selected. Great for casting specific columns.
if (typeof jQuery == 'undefined') {
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();
}
var $columns = ""
$('.schema-table-field').each(function(e){
@dovy
dovy / README.md
Last active April 28, 2017 21:39
Sickie button
#!/usr/bin/python
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.get_logger(__name__)
import time
from subprocess import Popen, PIPE, STDOUT
import xmlrpclib