Skip to content

Instantly share code, notes, and snippets.

@ridiculousfish
ridiculousfish / SafeSet.m
Created June 26, 2012 09:22
A thread safe set written in Objective-C
#import <Foundation/Foundation.h>
@interface SafeSet : NSObject {
NSMutableSet *set;
dispatch_queue_t queue;
}
@end
@implementation SafeSet
@ridiculousfish
ridiculousfish / gist:3729531
Created September 15, 2012 20:06
A (buggy) thread safe set written in Go
package main
import (
"fmt"
)
type SetTest struct {
val string
result chan bool
}
getwcd can be slow.
```
Analysis of sampling fish (pid 17046) every 1 millisecond
Process: fish [17046]
Path: /usr/local/bin/fish
Load Address: 0x100000000
Identifier: fish
Version: ???
Code Type: X86-64
.globl _ZN10parse_ll_t11parse_errorE13parse_token_tPKwz
.align 16, 0x90
.type _ZN10parse_ll_t11parse_errorE13parse_token_tPKwz,@function
_ZN10parse_ll_t11parse_errorE13parse_token_tPKwz: # @_ZN10parse_ll_t11parse_errorE13parse_token_tPKwz
.cfi_startproc
.cfi_personality 3, __gxx_personality_v0
.Leh_func_begin40:
.cfi_lsda 3, .Lexception40
# BB#0:
pushq %r15
@ridiculousfish
ridiculousfish / gist:7017899
Last active December 25, 2015 18:09
clang UBSan test case fails at -O1 and above
#include <string>
struct obj1_t
{
std::string text;
int val;
};
struct obj2_t
{
vmmap fancy_fish
Virtual Memory Map of process 27219 (fancy_fish)
Output report format: 2.2 -- 64-bit process
==== Non-writable regions for process 27219
__TEXT 000000010393f000-0000000103a0f000 [ 832K] r-x/rwx SM=COW ...y/fancy_fish
__LINKEDIT 0000000103ca9000-0000000103e98000 [ 1980K] r--/rwx SM=COW ...y/fancy_fish
MALLOC (admin) 0000000103e98000-0000000103e99000 [ 4K] r--/rwx SM=ZER
MALLOC (admin) 0000000103e9a000-0000000103e9b000 [ 4K] ---/rwx SM=NUL
MALLOC (admin) 0000000103eb0000-0000000103eb2000 [ 8K] ---/rwx SM=NUL
@ridiculousfish
ridiculousfish / inotify test
Last active August 29, 2015 14:01
inotify test that fails on travis-ci
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#define INOTIFY_TEST_PATH "/tmp/inotify_test.tmp"
import Haste
import Haste.App
import Haste.Foreign
server_func_1 :: Server (String)
server_func_1 = return "func1"
server_func_2 :: Server ()
server_func_2 = return ()
<html>
<head>
</head>
<body>
Hello World
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript">
window.setTimeout(function(){
Haste.hs_entry_point()
}, 1000)
@ridiculousfish
ridiculousfish / index.html
Created November 23, 2014 01:39
haste html 2
<html>
<head>
</head>
<body>
Hello World
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript">
window.setTimeout(function(){
Haste.hs_entry_point("foo", "bar")
}, 1000)