Skip to content

Instantly share code, notes, and snippets.

View OneSadCookie's full-sized avatar

Keith Bauer OneSadCookie

View GitHub Profile
#!/bin/sh
echo "package depdenencies for $1:"
ldd $1 | perl -pe 's|.*?(/.*?)\s*\(.*|\1|' | grep -v linux-gate | xargs -n 1 dpkg --search | perl -pe 's|(.*?):.*|\1|' | sort | uniq
Desktop 🐶 while true; do ruby -e '$a = File.read("nouns.txt").split("\n"); puts "You only get one #{$a[rand($a.length)]}"'; done
You only get one swallow
You only get one sheep
You only get one goat
You only get one start
You only get one truck
You only get one willow
You only get one dragonfly
You only get one baby
You only get one soccer
Desktop 🐶 cat > test.c
#include <stdio.h>
void bar() { printf("hi\n"); }
void foo() { bar(); }
int main() { foo(); }
Desktop 🐶 cc test.c -Wl,-map -Wl,test.map.txt
Desktop 🐶 cat test.map.txt
# Path: a.out
# Arch: x86_64
# Object files:
test.m:25:4: error: weak receiver may be unpredictably set to nil
[-Werror,-Wreceiver-is-weak]
[a doStuff];
^
test.m:25:4: note: assign the value to a strong variable to keep the object
alive during use
@OneSadCookie
OneSadCookie / gist:6443465
Created September 4, 2013 22:03
for alex
Desktop 🐶 cat test.c
static int foo(int b)
{
int a;
if (b)
{
a = 3;
}
return a;
}
#import <Foundation/Foundation.h>
void eachrow(size_t total, size_t nrows, size_t ncols, char const*** rows, BOOL(^cb)(size_t i, size_t ncols, char const **row, size_t *lengths))
{
size_t lengths[ncols];
for (size_t k = 0; k < total; ++k)
{
size_t i = k % nrows;
for (size_t j = 0; j < ncols; ++j)
{
ATFLogError("Couldn't determine rounding mode. Possibiliites:\n");
if (possibilities & (1 << IEEE754RoundTiesToEven)) ATFLogError(" RoundTiesToEven");
if (possibilities & (1 << IEEE754RoundTiesToAway)) ATFLogError(" RoundTiesToAway");
if (possibilities & (1 << IEEE754RoundTowardPositive)) ATFLogError(" RoundTowardPositive");
if (possibilities & (1 << IEEE754RoundTowardNegative)) ATFLogError(" RoundTowardNegative");
if (possibilities & (1 << IEEE754RoundTowardZero)) ATFLogError(" RoundTowardZero");
fail_exit();
mx::maybe<std::__1::insert_iterator<std::__1::unordered_map<char, std::__1::unordered_map<char, int, std::__1::hash<char>, std::__1::equal_to<char>, std::__1::allocator<std::__1::pair<char const, int> > >, std::__1::hash<char>, std::__1::equal_to<char>, std::__1::allocator<std::__1::pair<char const, std::__1::unordered_map<char, int, std::__1::hash<char>, std::__1::equal_to<char>, std::__1::allocator<std::__1::pair<char const, int> > > > > > > > mx::_mapM<std::__1::pair<char const, std::__1::unordered_map<char, int, std::__1::hash<char>, std::__1::equal_to<char>, std::__1::allocator<std::__1::pair<char const, int> > > >, std::__1::insert_iterator<std::__1::unordered_map<char, std::__1::unordered_map<char, int, std::__1::hash<char>, std::__1::equal_to<char>, std::__1::allocator<std::__1::pair<char const, int> > >, std::__1::hash<char>, std::__1::equal_to<char>, std::__1::allocator<std::__1::pair<char const, std::__1::unordered_map<char, int, std::__1::hash<char>, std::__1::equal_to<char>, std::__1::allocator<s
@OneSadCookie
OneSadCookie / font.cc
Created July 1, 2013 05:05
So I've been trying not to use exceptions, 'cos I hate 'em. I'm pretty sure my new file loading code is more robust. But it sure as heck ain't easier to read :(
namespace mx
{
namespace
{
inline maybe<int32_t> intval(json::object *o, char const *key)
{
return (*o)[key].bind([](json::base *b){
return b->to_number();
@protocol DBObjectVisitor
@required
- (void)visitDatabase:(DBDatabase *)database;
- (void)visitProcedure:(DBProcedure *)procedure;
...
@end
@interface DBObject
- (void)visitWith:(id<DBObjectVisitor>)visitor;
@end