Skip to content

Instantly share code, notes, and snippets.

View Cloudef's full-sized avatar

Jari Vetoniemi Cloudef

View GitHub Profile
@Cloudef
Cloudef / migrate_db.bash
Last active August 29, 2015 14:21
Darkstar db migration script
#!/bin/bash
# Migrate database automatically.
#
# Automatically migrates between schema changes.
# Where fields were either added or removed.
#
# However does not understand, if field names were renamed.
# You stil have to manually migrate those (eg. linkshellid1 -> linkshellid)
# These fields should show up as "old fields" and "new fields" in stdout.
#
@Cloudef
Cloudef / bitrot.c
Last active August 29, 2015 14:27
Bitwise rotation with mask
#include <stdint.h>
#include <stdio.h>
#include <limits.h>
#include <assert.h>
static void
print_bits(uint32_t v)
{
for (uint32_t i = 0; i < sizeof(v) * CHAR_BIT; ++i)
printf("%u", !!(v & (1<<i)));
@Cloudef
Cloudef / fakedisp_interface.patch
Created October 6, 2011 19:29
FakeDisp interface for wine
From ce8506d5fb32fc2ecd0edfb9b29057edb1cba367 Mon Sep 17 00:00:00 2001
From: Jari Vetoniemi <mailroxas@gmail.com>
Date: Fri, 27 Jul 2012 23:57:38 +0300
Subject: [PATCH] Fake display interface.
Sends fake resolution information to applications and,
fakes succesful display resolution changes to applications.
Useful if one does not want resolution switches and applications
don't work if they don't get any resolution information.
@Cloudef
Cloudef / gist:1293166
Created October 17, 2011 17:22
Menu patch for dwm-6 (hg) (Keybindings, few fixes)
changeset: 1590:260e6f30aa70
tag: tip
user: cloudef
date: Sat Dec 17 22:34:07 2011 +0200
summary: dwm-menu-patch
diff -r 40bff70c312f -r 260e6f30aa70 config.def.h
--- a/config.def.h Tue Nov 15 20:16:58 2011 +0100
+++ b/config.def.h Sat Dec 17 22:34:07 2011 +0200
@@ -36,6 +36,7 @@
@Cloudef
Cloudef / gist:1324254
Created October 29, 2011 08:58
rtorrent-mod-v3
diff -rupN src-old/command_download.cc src/command_download.cc
--- src-old/command_download.cc 2011-06-04 07:01:19.000000000 +0300
+++ src/command_download.cc 2011-10-29 11:10:41.258332501 +0300
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
@Cloudef
Cloudef / gist:1344609
Created November 7, 2011 10:17
winmm/mmio: Add extra handling for unbuffered MMIO handles
From c877ba08ee19b8b5f38ea4f37ce345208d158eba Mon Sep 17 00:00:00 2001
From: Cloudef <mailRoxas@gmail.com>
Date: Sun, 6 Nov 2011 18:57:57 +0200
Subject: winmm/mmio: Add extra handling for unbuffered MMIO handles
On non buffered mmioSeek, set the lBufOffset accordingly.
On non buffered mmioRead, seek to beginning of the file and return 0 meaning that the file ended.
I don't know if this just reveals bad programming in application,
or that native winmm likes to try handle code when it's wrongly used..
@Cloudef
Cloudef / gist:1378156
Created November 19, 2011 00:01
milkyhelper, repo download
#!/bin/sh
# Install && Update everything from repo
# Virtual SD (Download directory)
# Creates pandora layout there and stores libmilky database
VD="/absolute/path/to/download/dir"
mkdir -p "$VD"
# Sync database with repo
milky -r "$VD" -Sy
@Cloudef
Cloudef / gist:1503155
Created December 20, 2011 20:34
shellinabox: fix reverse proxy timeouts
AJAX_TIMEOUT 5
in session.h
@Cloudef
Cloudef / gist:1566795
Created January 5, 2012 19:30
Scale Katawa Shoujo
#!/bin/sh
# Katawa Shoujo
# Default setting is fullscreen for 1440x900 with black borders at side.
#
# Depends: x11vnc, Xvfb
# vncviewer comes from tightvnc, but you can alternatively use any viewer you want.
#
# To calculate the target resolution and scaler
# that matches your whole screen while maintaining aspect ratio, here's some math:
#
@Cloudef
Cloudef / nvidia-load-settings.sh
Created January 25, 2012 13:45
Some system utilities
#!/bin/sh
# Workaround bug where nvidia-settings --load-config-only
# does not actually load any attributes.
#
# It might be related to values that have decimals such as
# RedBrightness=1.000000
# nvidia-settings will complain about (Trailing garbage), unless ran as root..
#
# However, running as root isn't really a nice thing, so this script just assign everything
# It will still give you complaints about (Trailing garbage), but at least other settings get applied.