Skip to content

Instantly share code, notes, and snippets.

NSConnection *c = [NSConnection connectionWithRegisteredName:kNameConstantWhateverYouCalledIt
host:nil];
if (!c) {
NSLog(@"Could not connect to helper.");
return;
}
[c setRequestTimeout:3];
[c setReplyTimeout:3];
@try {
launch_data_t req = launch_data_new_string(LAUNCH_KEY_CHECKIN);
launch_data_t resp = launch_msg(req);
launch_data_t machData =
launch_data_dict_lookup(resp, LAUNCH_JOBKEY_MACHSERVICES);
launch_data_t machPortData =
launch_data_dict_lookup(machData, "com.company.helper.mach");
mach_port_t mp = launch_data_get_machport(machPortData);
launch_data_free(req);
launch_data_free(resp);
@tommetge
tommetge / wot-pov-scraper.rb
Last active December 10, 2015 19:28
Encyclopedia WOT scraper for figuring out how many points of view (POV) abound in the series
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
# Utility methods
def merge_povs(first_pov, second_pov)
second_pov.each do |k, v|
sum = [first_pov[k].to_i, second_pov[k].to_i].inject(:+)
first_pov[k] = sum
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
what(): boost::lock_error
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff3d82700 (LWP 5667)]
0x00000000006a4904 in leveldb::GetLengthPrefixedSlice(char const*) ()
(gdb) bt
#0 0x00000000006a4904 in leveldb::GetLengthPrefixedSlice(char const*) ()
#1 0x00000000006a4af4 in leveldb::MemTable::KeyComparator::operator()(char const*, char const*) const ()
#2 0x00000000006a51d0 in leveldb::SkipList<char const*, leveldb::MemTable::KeyComparator>::FindGreaterOrEqual(char const* const&, leveldb::SkipList<char const*, leveldb::MemTable::KeyComparator>::Node**) const ()
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff1fa1700 (LWP 25758)]
0x00007ffff75c9e84 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
(gdb) bt
#0 0x00007ffff75c9e84 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00000000004f9476 in lock (this=0x65736c616e) at /usr/include/boost/thread/pthread/mutex.hpp:52
#2 lock (this=0x7ffff1191590) at /usr/include/boost/thread/locks.hpp:412
#3 unique_lock (m_=..., this=0x7ffff1191590) at /usr/include/boost/thread/locks.hpp:290
#4 Mordor::FiberMutex::lock (this=0x65736c616e) at mordor/fibersynchronization.cpp:25
#5 0x000000000046827c in Mordor::FiberMutex::ScopedLock::ScopedLock (this=0x7ffff1191b40, mutex=...) at /usr/local/include/mordor/fibersynchronization.h:34
make all-am
clang++ -DHAVE_CONFIG_H -pthread -I/usr/local/include -I/usr/local/Cellar/postgresql/9.1.2/include -I. -I. -I/usr/include -Wall -fno-strict-aliasing -stdlib=libc++ -x c++-header mordor/pch.h -o mordor/pch.h.gch
/bin/sh ./libtool --tag=CXX --mode=compile clang++ -DHAVE_CONFIG_H -I. -include mordor/pch.h -pthread -I/usr/local/include -I/usr/local/Cellar/postgresql/9.1.2/include -I. -I. -I/usr/include -Wall -fno-strict-aliasing -stdlib=libc++ -MT mordor/mordor_libmordor_la-assert.lo -MD -MP -MF mordor/.deps/mordor_libmordor_la-assert.Tpo -c -o mordor/mordor_libmordor_la-assert.lo `test -f 'mordor/assert.cpp' || echo './'`mordor/assert.cpp
libtool: compile: clang++ -DHAVE_CONFIG_H -I. -include mordor/pch.h -pthread -I/usr/local/include -I/usr/local/Cellar/postgresql/9.1.2/include -I. -I. -I/usr/include -Wall -fno-strict-aliasing -stdlib=libc++ -MT mordor/mordor_libmordor_la-assert.lo -MD -MP -MF mordor/.deps/mordor_libmordor_la-assert.Tpo -c mordor/assert.cpp -o mordor/mordor_libmordor_l
/usr/local/share/boost-build/build/toolset.jam:38: in toolset.using
*** argument error
* rule pb.init ( prefix : condition * )
* called with: ( : : : : : : : )
* missing argument prefix
/Users/tom/src/git/spacemonkey/client/native/src/protos/pb.jam:44:see definition of rule 'init' being called
/usr/local/share/boost-build/build/project.jam:888: in using
src/protos/Jamfile:1: in modules.load
/usr/local/share/boost-build/build/project.jam:314: in load-jamfile
/usr/local/share/boost-build/build/project.jam:62: in project.load
@tommetge
tommetge / users2csv.py
Created June 15, 2012 03:14
Export users to CSV (Canvas)
import json
import urllib2
res = urllib2.urlopen("https://canvas.instructure.com/api/v1/accounts/85240/users?access_token=**")
users = json.loads(res.read())
csv = ""
for user in users:
attributes = flatten_dict_values(user)
i = 0
@tommetge
tommetge / downloadToStream.cpp
Created June 13, 2012 17:04
mordor download to stream
static bool downloadToStream(const char * inUrl, Stream &dst, Mordor::IOManager * iomanager)
{
boost::scoped_ptr<WorkerPool> workInThisThread;
if (Scheduler::getThis() == NULL) {
workInThisThread.reset(new WorkerPool(1, true));
}
HTTP::RequestBrokerOptions options;
options.ioManager = iomanager;
@tommetge
tommetge / get.cpp
Created June 13, 2012 16:49
mordor http client
// Copyright (c) 2009 - Decho Corp.
#include "mordor/predef.h"
#include <iostream>
#include <boost/bind.hpp>
#include "mordor/config.h"
#include "mordor/exception.h"