Skip to content

Instantly share code, notes, and snippets.

View schrodervictor's full-sized avatar
🖖
Live long and prosper.

Victor Schröder schrodervictor

🖖
Live long and prosper.
View GitHub Profile
@schrodervictor
schrodervictor / encryptedNixos.md
Created April 9, 2023 16:10 — forked from ladinu/encryptedNixos.md
NixOS install with encrypted /boot /root with single password unlock

Requirements

  1. Encrypt everthing including /boot and /root
  2. Enter password once
  3. Support UEFI

Installation media setup

Download NixOS minimal iso and copy to USB stick. For example on Mac OSX

$ diskutil list
$ diskutil unmountDisk /dev/disk1 # Make sure you got right device
@schrodervictor
schrodervictor / README.md
Created August 11, 2021 07:31 — forked from manuelbl/README.md
ESP32 as Bluetooth Keyboard

ESP32 as Bluetooth Keyboard

With its built-in Bluetooth capabilities, the ESP32 can act as a Bluetooth keyboard. The below code is a minimal example of how to achieve it. It will generate the key strokes for a message whenever a button attached to the ESP32 is pressed.

For the example setup, a momentary button should be connected to pin 2 and to ground. Pin 2 will be configured as an input with pull-up.

In order to receive the message, add the ESP32 as a Bluetooth keyboard of your computer or mobile phone:

  1. Go to your computers/phones settings
  2. Ensure Bluetooth is turned on
import argparse
from PIL import Image
parser = argparse.ArgumentParser()
parser.add_argument("inputfile", help="Path to the image file to convert")
parser.add_argument("-o", "--output", help="Path to output file with the C array, if not given the same filename as the input is used, with filetype .c", action="store_true")
parser.add_argument("-p", "--preview", help="Print the resulting image to the terminal", action="store_true")
parser.add_argument("-d", "--dither", help="Set flag to dither image in conversion from colour to BW, if applicable", action="store_true")
parser.add_argument("-s", "--small", help="Set flag if your OLED has a resolution of 128x32 instead of 128x64", action="store_true")
parser.add_argument("-x", "--width", help="Pixel width of your OLED", type=int)
@schrodervictor
schrodervictor / uncamelize.js
Last active August 6, 2019 14:52 — forked from jpetitcolas/uncamelize.js
How to uncamelize a string in Javascript? Example: "HelloWorld" --> "hello_world"
/**
* Uncamelize a string, joining the words by separator character.
*
* @param {string} text - Text to uncamelize
* @param {string} [separator='_'] - Word separator
* @returns {string} Uncamelized text
*/
function uncamelize(text, separator) {
// Assume separator is _ if no one has been provided.
if('undefined' === typeof separator) {
@schrodervictor
schrodervictor / product.sql
Created April 20, 2018 10:37
Product SQL (OMG Magento, really?)
SELECT
-- Attributes in the pivot table:
-- `p`.`whatever` AS `whatever`
p.entity_id AS id,
p.sku AS sku,
-- Attributes in the EAV tables:
-- IFNULL(`store_whatever`.`value`, `default_whatever`) AS `whatever`
@schrodervictor
schrodervictor / README.md
Created May 8, 2017 16:41 — forked from smoya/README.md
Get php trace -on segmentation fault- using xdebug
  • Enable the tracer on your xdebug.ini file (see the xdebug.ini file).
  • If you are gonna trace an http request, make sure your xdebug.trace_output_dir is writable by the webserver user (www-data).
  • Execute your script or your request. You can use produce_segmentation.php to test.
  • See the trace file(s) on your xdebug.trace_output_dir.
@schrodervictor
schrodervictor / 00. tutorial.md
Created September 22, 2015 20:31 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler
@schrodervictor
schrodervictor / better-nodejs-require-paths.md
Last active September 13, 2015 21:43 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@schrodervictor
schrodervictor / node-and-npm-in-30-seconds.sh
Last active September 7, 2015 06:18 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@schrodervictor
schrodervictor / boot.js
Last active September 6, 2015 16:18 — forked from jdx/boot.js
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run