Skip to content

Instantly share code, notes, and snippets.

View mitchty's full-sized avatar

Mitch Tishmack mitchty

  • Saint Paul, MN
View GitHub Profile
commit 683faf9bfbb43560a6cee8d921360f499af0e212
Author: Mitch Tishmack <mitch.tishmack@gmail.com>
Date: Mon Mar 3 00:30:13 2014 -0600
Fix collision with fls(int) on osx.
diff --git a/src/yuck.c b/src/yuck.c
index bbd3bbb..2215792 100644
--- a/src/yuck.c
+++ b/src/yuck.c
--- a/src/yuck.c 2014-03-04 05:26:03.000000000 -0600
+++ b/src/yuck.c 2014-04-05 14:59:29.000000000 -0500
@@ -1099,9 +1099,16 @@
ssize_t off;
char *mp;
+#if __APPLE__
+ pid_t pid = getpid();
+ if ((off = proc_pidpath(pid, buf, bsz)) < 0) {
+ return -1;
#include <stdio.h>
#include <stdlib.h>
#include "uv.h"
// uv_pipe_t apipe;
void on_child_exit(uv_process_t *req, int exit_status, int term_signal) {
fprintf(stderr, "Process exited with status %d, signal %d\n", exit_status,
term_signal);
uv_close((uv_handle_t *)req, NULL);
@mitchty
mitchty / getdents-glibc.c
Created June 10, 2014 17:08
getdents like ls behavior with a buffer the same size as most glibc implementations are compiled with.
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#define handle_error(msg) \
@mitchty
mitchty / getdents-hacked.c
Created June 10, 2014 17:10
getdents like ls behavior with a buffer size of 1024*1024*1 which vastly helps with performance of giant directory entries (200meg+)
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#define handle_error(msg) \
me@mini $ ls -d /usr/local/{include,lib}/*gmp*
/usr/local/include/gmp.h /usr/local/lib/libgmp.dylib
/usr/local/include/gmpxx.h /usr/local/lib/libgmpxx.4.dylib
/usr/local/lib/libgmp.10.dylib /usr/local/lib/libgmpxx.a
/usr/local/lib/libgmp.a /usr/local/lib/libgmpxx.dylib
me@mini $ cabal install --extra-include-dirs=/usr/local/include --extra-lib-dirs=/usr/local/lib ansi-terminal
Resolving dependencies...
Configuring ansi-terminal-0.6.1.1...
Failed to install ansi-terminal-0.6.1.1
Build log ( /Users/mitch/.cabal/logs/ansi-terminal-0.6.1.1.log ):
---
- hosts: localhost
vars:
- kb_key: "com.apple.keyboard.modifiermapping"
- kb_map_dest: "HIDKeyboardModifierMappingDst"
- kb_map_src: "HIDKeyboardModifierMappingSrc"
tasks:
- shell: >
ioreg -p IOUSB -c IOUSBDevice |
grep -e class -e idVendor -e idProduct |
---
- hosts: localhost
vars:
- kb_key: "com.apple.keyboard.modifiermapping"
- kb_map_dest: "HIDKeyboardModifierMappingDst"
- kb_map_src: "HIDKeyboardModifierMappingSrc"
tasks:
- shell: >
ioreg -p IOUSB -c IOUSBDevice |
grep -e class -e idVendor -e idProduct |
require 'formula'
class Subversion16 < Formula
homepage 'http://subversion.apache.org/'
url 'http://archive.apache.org/dist/subversion/subversion-1.6.23.tar.bz2'
sha1 '578c0ec69227db041e67ade40ac4cf2ebe2cf54a'
depends_on 'pkg-config' => :build
depends_on 'sqlite3' => :build
import System.Random (randomRIO)
pick r xs = r (0, length xs - 1) >>= return . (xs !!)
outcomes = ["It is certain", "It is decidedly so", "Without a doubt", "Yes - definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Signs point to yes", "Yes", "Reply hazy, try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful"]
main = putStrLn =<< pick randomRIO outcomes