Skip to content

Instantly share code, notes, and snippets.

View mikebaldry's full-sized avatar

Michael Baldry mikebaldry

View GitHub Profile
@mikebaldry
mikebaldry / gist:1358563
Created November 11, 2011 17:05
DRY my haml
-if t.incomplete?
%a{:href => lead_task_path(t.lead, t)}
=t.title
.sub= t.lead.business_name
-else
=t.title
.sub= t.lead.business_name
@mikebaldry
mikebaldry / gist:1366593
Created November 15, 2011 09:49
find subclasses
def self.all
results = []
ObjectSpace.each_object(Class) do |c|
(results << c) if c.ancestors.include?(PullSource) && c != PullSource
end
results
end
@mikebaldry
mikebaldry / gist:1410563
Created November 30, 2011 20:02
ne2k-pci error
ne2k-pci.c:v1.03 9/22/2003 D. Becker/P. Gortmaker
PCI: enabling device 0000:00:0c.0 (0100 -> 0101)
Unable to handle kernel paging request at virtual address 44000000
pgd = c0004000
[44000000] *pgd=00000000
Internal error: Oops: 35 [#1]
Modules linked in:
CPU: 0 Not tainted (3.1.0 #2)
PC is at ne2k_pci_init_one+0xc8/0x3d4
LR is at __request_region+0x88/0x128
@mikebaldry
mikebaldry / gist:1411646
Created November 30, 2011 22:58
qemu-ifup
deploy@buildroot:~/buildroot$ sudo /etc/qemu-ifup tap0
Wed Nov 30 22:57:27 2011 Note: Cannot ioctl TUNSETIFF tap0: Device or resource busy (errno=16)
Wed Nov 30 22:57:27 2011 Note: Attempting fallback to kernel 2.2 TUN/TAP interface
Wed Nov 30 22:57:27 2011 Cannot open TUN/TAP dev /dev/tap0: No such file or directory (errno=2)
Wed Nov 30 22:57:27 2011 Exiting
@mikebaldry
mikebaldry / gist:1437786
Created December 6, 2011 10:57
Query optimisation..
SELECT c.contract_id, csc1.changed_status
FROM contract c
LEFT
JOIN contract_status_change csc1
ON csc1.contract_status_change_id =
( SELECT csc2.contract_status_change_id
FROM contract_status_change csc2
WHERE csc2.contract_id = c.contract_id
ORDER
BY csc2.date_changed DESC
@mikebaldry
mikebaldry / gist:1519173
Created December 25, 2011 12:26
Why would resulting_command need to be declared, when declaring it?
command_parser.cpp:13: error: ‘resulting_command’ was not declared in this scope..
command& command_parser::parse(const std::string& command) {
13: command* resulting_command = NULL;
std::vector<std::string> parts;
boost::split(parts, command, boost::is_any_of(" "));
std::string cmd = parts.at(0);
boost::to_upper(cmd);
parts.erase(parts.begin());
@mikebaldry
mikebaldry / gist:1519546
Created December 25, 2011 17:49
My Makefile
CXX=g++
CXXFLAGS=-Wall -gdwarf-2 -O2 -g -I /usr/local/boost_1_48_0
LDFLAGS=-L/usr/local/boost_1_48_0/stage/lib -lboost_signals -lboost_thread -lboost_system -lboost_program_options
svr: main.o server.o io_service_pool.o connection.o command_parser.o
$(CXX) -o svr $(LDFLAGS) main.o server.o io_service_pool.o connection.o command_parser.o
%: %.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
@mikebaldry
mikebaldry / gist:1854050
Created February 17, 2012 15:35
merging 2 objects
mergeObjects: (obj1, obj2) ->
obj3 = {}
for attrName in obj1
obj3[attrName] = obj1[attrName]
for attrName in obj2
obj3[attrName] = obj2[attrName]
obj3
@mikebaldry
mikebaldry / gist:1884577
Created February 22, 2012 12:16
brew install sox
Warning: It appears you have Macports or Fink installed
Software installed with other package managers causes known problems for
Homebrew. If formula fail to build uninstall Macports/Fink and reinstall any
affected formula.
Also installing dependencies: libogg, libvorbis, lame, flac, libao, mad
==> Downloading http://downloads.xiph.org/releases/ogg/libogg-1.2.2.tar.gz
######################################################################## 100.0%
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/libogg/1.2.2
==> make
==> make install
@mikebaldry
mikebaldry / gist:2006495
Created March 9, 2012 13:25
always doing a GET?
$.ajax({
url: "/oasis/incoming_call",
dataType: "json",
data: {
id: leadId,
contact: {
call_id: callId,
campaign_name: campaignName
}
},