Skip to content

Instantly share code, notes, and snippets.

@houtianze
houtianze / sysv.init.script.to.systemd.unit.file.md
Last active April 3, 2025 17:44
Convert SysV Init scripts to Systemd Unit File

Let's say you have a SysV Init Script named foo

  1. Copy the file to /etc/init.d/foo

  2. Enable the SysV service: chkconfig --add foo

  3. Enable the SysV service: chkconfig foo on

  4. Start the service: service foo start. After this, systemd-sysv-generator will generate this file /run/systemd/generator.late/foo.service, copy this file to /etc/systemd/system by running: cp /run/systemd/generator.late/foo.service /etc/systemd/system/foo.service

  5. Edit /etc/systemd/system/foo.service by running systemctl edit foo.service, add in the following line to foo.servie (this makes the service installable)

[Install]

@putnamhill
putnamhill / docker-rmi-interactive.sh
Last active January 4, 2024 13:40
A script to help clean up docker images interactively
#!/bin/bash
agree() {
local question="$1"
while true; do
read -p "$question " answer
case $answer in
[Yy]|[Yy][Ee][Ss]) return 0 ;;
[Nn]|[Nn][Oo]|'') return 1 ;; # empty string is default
@n-st
n-st / pre-commit
Created August 9, 2015 13:07
Git pre-commit hook: Reject commit if a DNS zone file has been changed without changing its SOA serial. The serial needs to be on a separate line that contains ' ; serial'.
#!/bin/bash
# Check if all changed zone files have had their SOA serial incremented.
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@hbrysiewicz
hbrysiewicz / ember.css
Last active January 9, 2020 13:19
Ember.js Theme for Reveal.js - Based off of the Simple Theme
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,600,300italic,700italic);
/**
* A simple theme for reveal.js presentations, similar
* to the default theme. The accent color is rgb(242, 56, 24).
*
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
*/
/*********************************************
* GLOBAL STYLES
@op8867555
op8867555 / input.lua.patch
Created June 28, 2014 03:41
don't starve ( linux ) xbox 360 controller prompt dirty hack
--- input.lua.bak 2014-06-28 10:13:51.897841317 +0800
+++ input.lua 2014-06-28 11:38:07.049859004 +0800
@@ -295,6 +295,10 @@
if not (nil == intParam) then
text = string.format(text, intParam)
end
+
+ for key, rename in pairs(STRINGS.UI.CONTROLSSCREEN.GENERIC_CONTROLLER_RENAMES) do
+ text = string.gsub(text, key, rename)
+ end
@mariussturm
mariussturm / gist:061b9f4861ef1292aa60
Last active February 1, 2017 13:16
How to pair Firefox 29 with Owncloud's mozilla_sync / Weave
_Go to your Owncloud installation <https://myowncloud/remote.php/mozilla_sync> and accept the SSL Certificate
_Open about:config
_Create: services.sync.username <string> the value should be a hash not the username itself. (You only need the hash if the
sync was setup with a pre FF29, if you start from scratch the string doesn't matter)
You can look this up in an older browser or in the logs of your Owncloud server!!
_Go to: Preferences -> Sync -> Setup Firefox sync (you should see the old UI now)
'I Have an Account'
'I don't have the device with me'
'Account' - again use the hash NOT the actual username!
@wu-lee
wu-lee / gist:9274194
Created February 28, 2014 16:31
Using Apache as s CORS-handling proxy to a CouchDB server
<IfModule !proxy_module>
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
</IfModule>
<IfModule !proxy_http_module>
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
</IfModule>
<IfModule !headers_module>
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
@hubgit
hubgit / README.md
Last active September 28, 2025 16:30
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files

@rodneyrehm
rodneyrehm / anti-keygrabber.user.js
Last active May 26, 2024 17:50
GreaseMonkey: Prevent Web Applications From Grabbing Certain HotKeys
// ==UserScript==
// @name anti key-grabber
// @description Prevent web apps from capturing and muting vital keyboard shortcuts
// @grant none
// @version 1.1
// ==/UserScript==
(function(){
var isMac = unsafeWindow.navigator.oscpu.toLowerCase().contains("mac os x");
unsafeWindow.document.addEventListener('keydown', function(e) {
if (e.keyCode === 116) {
@KartikTalwar
KartikTalwar / Documentation.md
Last active October 12, 2025 04:53
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs