Skip to content

Instantly share code, notes, and snippets.

View scotchi's full-sized avatar

Scott Wheeler scotchi

View GitHub Profile
@scotchi
scotchi / taglib-kindle.diff
Created October 15, 2011 08:51
Diff of TagLib 1.5 and the version from the Amazon Kindle
diff -ur -x 'Makefile*' -x 'config*' -x '*.cache' -x aclocal.m4 taglib-1.5/bindings/c/tag_c.cpp gplrelease/taglib-1.5/bindings/c/tag_c.cpp
--- taglib-1.5/bindings/c/tag_c.cpp 2008-02-12 05:43:44.000000000 +0100
+++ gplrelease/taglib-1.5/bindings/c/tag_c.cpp 2011-09-28 05:57:55.000000000 +0200
@@ -28,10 +28,10 @@
#include <mpegfile.h>
#include <flacfile.h>
#include <oggflacfile.h>
-#include <mpcfile.h>
-#include <wavpackfile.h>
-#include <speexfile.h>
@scotchi
scotchi / smapper.rb
Created February 20, 2013 13:05
Mini-tool to get the amount of memory being used by a process, *not* the amount of memory plus the size of mmaped files. In other words, it's a way of removing the mmaped size of PIDs.
#!/usr/bin/env ruby
PID = ARGV.shift
smaps ="/proc/#{PID}/smaps"
if PID.nil?
warn 'You must specify a PID'
exit 1
end
@scotchi
scotchi / gist:6460510
Created September 6, 2013 07:14
Set the recording date for a track using TagLib
#include <tstring.h>
#include <mpegfile.h>
#include <id3v2tag.h>
#include <textidentificationframe.h>
int main(int argc, char *argv[])
{
for(int i = 1; i < argc; i++)
{
TagLib::MPEG::File file(argv[i]);
@scotchi
scotchi / gist:6580980
Created September 16, 2013 13:54
Example from TagLib mailing list
#include <iostream>
#include <mpegfile.h>
#include <id3v2tag.h>
#include <privateframe.h>
static void AddTag(const char * payload, const char * URL)
{
TagLib::MPEG::File f(URL);
TagLib::ID3v2::Tag *tag = f.ID3v2Tag();
@scotchi
scotchi / ns-use-native-fullscreen-and-toggle-frame-fullscreen.patch
Last active December 26, 2015 20:29
Backport of Emacs master's fullscreen mode to Emacs 24.3
From 446fcea51c0b579d30d6bf3183fada2f2f70440e Mon Sep 17 00:00:00 2001
From: Scott Wheeler <[email protected]>
Date: Tue, 29 Oct 2013 04:06:54 +0100
Subject: [PATCH 1/2] Backport patch from master to support
ns-use-native-fullscreen flag
The original patch is here:
http://bzr.savannah.gnu.org/lh/emacs/trunk/diff/111679
---
@scotchi
scotchi / find_each.rb
Created November 7, 2013 05:52
ShopifyAPI::Base.find_each
module ShopifyAPI
class Base
RETRY_AFTER = 60
def self.find_each(params = {}, &block)
params[:limit] ||= 50
params[:page] = 1
retried = false
begin
@scotchi
scotchi / tdat-test.cpp
Created September 25, 2014 20:52
Example of how to pull the raw data out a deprecated frame type with TagLib
#include <mpegfile.h>
#include <id3v2tag.h>
#include <unknownframe.h>
int main(int argc, char *argv[])
{
for(int i = 1; i < argc; i++)
{
TagLib::MPEG::File f(argv[i]);
TagLib::ID3v2::Tag *t = f.ID3v2Tag(false);
@scotchi
scotchi / emacs-fix-ns-antialias-text-mac-os.patch
Last active August 29, 2015 14:08
Check to see if the user has explicitly disabled anti-aliasing
commit 604a4d21ead40691afe3efe13f0ba1000b2cd61a
Author: Jan D. <[email protected]>
Date: Fri Oct 31 19:41:07 2014 +0100
* macfont.m (macfont_glyph_extents): Turn off syntetic bold
if force_integral_p (i.e. no antialias).
(macfont_draw): Check ns_antialias_text, also turn off syntetic
bold if no antialias.
diff --git a/src/macfont.m b/src/macfont.m
@scotchi
scotchi / convert_controller_to_strong_params.rb
Last active October 5, 2016 11:48
Tool to parse out params in usage in a Rails controller and add a line to specify which strong params are allowed
#!/usr/bin/env ruby
require 'parser/current'
module Parser
module AST
class Node
def find(type, found: [], &block)
if self.type == type && (!block || block.call(self))
found.push(self)
@scotchi
scotchi / magic-mouse-scrolling-speed.c
Created December 13, 2016 06:33
Little tool to run setuid that can be called from ~/.xinitrc
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, const char *argv[])
{
if(geteuid() != 0)
{
fprintf(stderr, "This program should be setuid or run as root.\n");