Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas McDonald thomas-mcdonald

View GitHub Profile
View gist:892529
| Site | Eligible | Visited (%) | Voted (%e) [%v] |
| Stack Overflow | 43,778 | 14,130 (32) | 4,970 (11) [35] |
| Server Fault | 3,834 | 566 (14) | 310 (8) [54] |
| Super User | 4,566 | 505 (11) | 213 (4) [42] |
| Maths | 394 | | 174 (44) | *
| Programmers | 1,930 | 413 (21) | 229 (11) [55] |
| Game Dev | 445 | 102 (23) | 58 (13) [56] |
| Theoretical CS | 261 | 129 (49) | 104 (39) [80] |
| Web Apps | | | | **
| Gaming | 809 | 177 (21) | 129 (15) [72] |
View crash-on-clone
Process: GitHub [4299]
Path: /private/var/folders/*/GitHub.app/Contents/MacOS/GitHub
Identifier: com.github.GitHub
Version: 1.2.1 (1.2.1)
Code Type: X86-64 (Native)
Parent Process: launchd [211]
Date/Time: 2012-03-15 19:12:17.185 +0000
OS Version: Mac OS X 10.7.3 (11D50b)
Report Version: 9
View gist:2950487
require 'gst'
require 'sinatra'
class App < Sinatra::Application
configure do
Gst.init
@@pipeline = Gst::ElementFactory.make("playbin2")
@@pipeline.uri = GLib.filename_to_uri(File.expand_path(File.dirname(__FILE__)) + '/icarus.mp3')
end
View gist:4380609
> brew install cdrtools
==> Downloading ftp://ftp.berlios.de/pub/cdrecord/cdrtools-3.00.tar.gz
######################################################################## 100.0%
######################################################################## 100.0%==> make INS_BASE=/usr/local/Cellar/cdrtools/3.00 INS_RBASE=/usr/local/Cellar/cdrtools/3.00 install
/usr/local/Cellar/cdrtools/3.00: 176 files, 1.8M, built in 55 seconds
> brew list cdrtools
/usr/local/Cellar/cdrtools/3.00/etc/default/rscsi
/usr/local/Cellar/cdrtools/3.00/include/scg/ (12 files)
/usr/local/Cellar/cdrtools/3.00/include/schily/ (101 files)
@thomas-mcdonald
thomas-mcdonald / brew --config
Last active Dec 10, 2015
gst-plugins-ugly homebrew ticket
View brew --config
> brew --config ~
HOMEBREW_VERSION: 0.9.3
HEAD: 4baf64237d8fefba68a24e2237d08311592f00bb
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit ivybridge
OS X: 10.8.1-x86_64
Xcode: 4.5.2
CLT: 4.5.0.0.1.1249367152
LLVM-GCC: build 2336
View union.hs
union [] [] = []
union [] ys = ys
union xs [] = xs
union (x@(n,_):xs) ys
| has n ys = (join x (find n ys)):(union xs (without n ys))
| otherwise = x:(union xs ys)
where
find p = filter (\x -> fst x == p)
without p = filter (\x -> fst x != p)
has p = length (find p) != 0
@thomas-mcdonald
thomas-mcdonald / linkextract.php
Created Feb 2, 2013
MediaWiki internal link handler
View linkextract.php
function replaceInternalLinks2( &$s ) {
static $tc = FALSE, $e1, $e1_img;
# the % is needed to support urlencoded titles as well
if ( !$tc ) {
$tc = Title::legalChars() . '#%';
# Match a link having the form [[namespace:link|alternate]]trail
$e1 = "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
# Match cases where there is no "]]", which might still be images
$e1_img = "/^([{$tc}]+)\\|(.*)\$/sD";
}
View DisableableSelect.tsx
import { ISelectProps } from "@blueprintjs/labs";
import * as React from "react";
import { DropdownButton } from "./DropdownButton";
interface IDisableableSelectProps {
disabled?: boolean;
text: string;
}
export function disableableSelect<T>(
@thomas-mcdonald
thomas-mcdonald / instrumentation.rb
Created Aug 8, 2019
count number of active record objects instantiated
View instrumentation.rb
ActiveSupport::Notifications.subscribe "instantiation.active_record" do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
RequestStore.store[:object_count] ||= 0
RequestStore.store[:object_count] += event.payload[:record_count]
end
ActiveSupport::Notifications.subscribe "process_action.action_controller" do
Rails.logger.info "AR Object count: #{RequestStore.store[:object_count]}"
end
@thomas-mcdonald
thomas-mcdonald / attempt1.txt
Last active Sep 22, 2019
3n -> n query playground
View attempt1.txt
SELECT * FROM (
SELECT "functions".* FROM "functions" WHERE "functions"."klass_id" = 242 AND "functions"."name" = 'change'
UNION
SELECT "functions".* FROM "functions" WHERE "functions"."klass_id" = 661 AND "functions"."name" = 'change'
UNION
SELECT "functions".* FROM "functions" INNER JOIN "klasses" ON "klasses"."id" = "functions"."klass_id" INNER JOIN "versions" ON "versions"."id" = "klasses"."version_id" WHERE "versions"."id" = 1 AND "functions"."name" = 'change'
) as subquery LIMIT 1
however postgres will execute all union queries even if the first query returns a result