Skip to content

Instantly share code, notes, and snippets.

@rveachkc
rveachkc / zwave-js_docker.md
Last active September 9, 2024 06:35
Getting zwave-js running in docker

Update: Just run ZwaveJS2Mqtt

Shortly after writing this, I realized that ZwaveJS2Mqtt can be used with a websocket connection instead of the mqtt. I've had a great experience with it, so there's really no good reason to use what is below.

Documentation: https://zwave-js.github.io/zwavejs2mqtt/#/

I'll leave the text below, because somebody might find it useful.

Getting zwave-js running in docker

@mcattarinussi
mcattarinussi / gpg-ssh-setup.md
Last active November 15, 2024 20:48
A setup guide to use a personal gpg key for ssh authentication

GPG - SSH setup

Generating the master key

Here we create the master key. We want only Certify capability: we use the master key only to create the subkeys, Sign - Encrypt - Authenticate capabilities will be assigned to the subkeys.

Run the following command to start the master key generation process. Select the set your own capabilities creation process (type 8)

  ▶ gpg --full-generate-key --expert

gpg (GnuPG) 2.2.9; Copyright (C) 2018 Free Software Foundation, Inc.

@oinopion
oinopion / read-access.sql
Created October 5, 2016 13:00
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@peterhurford
peterhurford / num_rows_csv.R
Last active November 5, 2024 08:13
What's the fastest way to determine the number of rows of a CSV in R?
# What's the fastest way to determine the number of rows of a CSV in R?
# ...Reading the entire CSV to only get the dimensions is likely too slow. Is there a faster way?
# Benchmarks done on a EC2 r3.8xlarge
# Cowritten with Abel Castillo <github.com/abelcastilloavant>
m <- 1000000
d <- data.frame(id = seq(m), a = rnorm(m), b = runif(m))
dim(d)
# [1] 1000000 3
pryr::object_size(d)
@e-mon
e-mon / Dinic.py
Created May 28, 2015 03:06
Dinic's Algorithm
class Dinic:
class Edge:
def __init__(self, to, cap, rev):
self.to = to
self.cap = cap
self.rev = rev
def __repr__(self):
return "(to: {0} cap: {1} rev: {2})".format(self.to, self.cap, self. rev)

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@FichteFoll
FichteFoll / find_scopes.py
Last active May 8, 2016 02:22 — forked from sparr/scopecount
Download color schemes and count the occuring atomic scopes
#!/usr/bin/env python3
import requests
import plistlib
from collections import Counter
import posixpath
from urllib.parse import urlsplit
import sys
import os
@sparr
sparr / scopecount
Last active May 8, 2016 02:22
SublimeText theme gallery scope usage count
574 : string [std]
311 : source
278 : entity [std]
253 : keyword [std]
242 : comment [std]
236 : entity.name.tag
229 : constant [std]
212 : support.function [std]
209 : storage [std]
209 : entity.other.attribute-name
@wch
wch / speed.r
Last active January 31, 2023 01:56
Modifying objects in loops in R, and other speed pitfalls
# =============================================
# Modifying a data frame in place
# =============================================
library(ggplot2)
str(diamonds)
# Modify data frame in place, in loop
# This is super, super slow
system.time({
@kosh04
kosh04 / sizseof.c
Created September 15, 2011 07:11
sizeof演算子で変数の大きさを調べる
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <wchar.h>
#include <time.h>
// XXX: "%zd" format cannot work in VC, MinGW
#define prints(type) printf(#type "\t\t" "%lu\n", (unsigned long)sizeof(type))