Skip to content

Instantly share code, notes, and snippets.

@dmy3k
dmy3k / build_systemd_sleep_selinux_module.sh
Last active June 18, 2023 11:13
SElinux module for suspend-than-hibernate with systemd v253, fedora 38
View build_systemd_sleep_selinux_module.sh
cd "$(mktemp -dt)"
cat <<-EOF | tee systemd_sleep.te
module systemd_sleep 1.0;
require {
type systemd_sleep_t;
type systemd_unit_file_t;
type unlabeled_t;
type udev_var_run_t;
type init_var_lib_t;
View linux_wifi_perf.bash
# most of the hacks taken from
# https://support.system76.com/articles/wireless/
sudo vim /etc/nsswitch.conf
# look for the following line
# hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
# If you find this file, replace it with the following line:
# hosts: files dns
sudo vim /etc/modprobe.d/iwlwifi.conf
View backbone_partial_render.js
/**
* Renders part of the view instead all of it.
* Useful in sutuations where view contains counter and input fields.
* Counter needs to be updated, while input state left intact.
* */
Backbone.View.prototype.renderPartial = function(selector, data, template) {
template = template || this.template;
var self = this;
var $html = $('<div>' + template(data) + '</div>');
View svgrasterize.sh
#!/bin/sh
#---------------------------------------------------------------
# Creates png files from given svg files in a directory.
# Target png dimensions hardcoded (120px width, height auto).
# Note: you need to `npm install -g svgexport` first.
#
# Usage example:
# ./svgrasterize.sh .
#---------------------------------------------------------------
@dmy3k
dmy3k / Howto convert a PFX to a seperate .key & .crt file
Created January 15, 2016 14:50 — forked from TemporaryJam/Howto convert a PFX to a seperate .key & .crt file
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
View Howto convert a PFX to a seperate .key & .crt file
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
View get_selection_ccords.js
function getSelectionCoords(win) {
win = win || window;
var doc = win.document;
var sel = doc.selection, range, rects, rect;
var x = 0, y = 0;
if (sel) {
if (sel.type != "Control") {
range = sel.createRange();
range.collapse(true);
x = range.boundingLeft;
View 51-android.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
@dmy3k
dmy3k / loader.css
Last active August 29, 2015 14:23
Zero element CSS loader
View loader.css
.loading {
position: relative;
}
.loading:before {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
View eps2svg.sh
#!/bin/bash
FILES=$(find $1 -maxdepth 1 -name '*.eps')
for file in $FILES
do
extension="${file##*.}"
filename="${file%.*}"
#echo $file
#echo $filename
View thread_pool.py
"""
Execute function in process/thread pool with possibility to get return values
credits to http://stackoverflow.com/a/8533626
"""
from multiprocessing.pool import ThreadPool as Pool
# for process-based pool use
# from multiprocessing import Pool
import time