Skip to content

Instantly share code, notes, and snippets.

View op's full-sized avatar
🦥

Örjan Fors op

🦥
View GitHub Profile
@op
op / git-dolly
Last active April 28, 2023 23:14
Clone a git repository and retain directory structure
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# git-dolly -- Clone a git repository and retain directory structure
#
# Uses by default "~/src" as the root to where to clone repositories. It then
# automatically sets up the target directory based on the given URL.
#
# To override the default, set GIT_DOLLY_PATH.
#
@op
op / .cVimrc
Last active August 29, 2015 14:27
.cVimrc
" Settings
set autohidecursor " hide the mouse cursor when scrolling
set typelinkhints " type text in the link to narrow down numeric hints
let mapleader = ","
" Create a shortcut for search engines. For example, typing ':tabnew g example'
" would act the same way as ':tabnew google example'
let searchalias s = "stackoverflow"
let searchalias g = "google"
@op
op / thread_recv_block.c
Created May 24, 2013 05:29
If there is no timeout defined on a socket, and the socket is closed while another thread is waiting in nn_recv(), it would be very helpful for me to get an error back directly. Similar to how nn_term() works.
#include "src/nn.h"
#include "src/reqrep.h"
#include "src/utils/err.c"
#include "src/utils/thread.c"
#include "src/utils/sleep.c"
#include <stddef.h>
#include <assert.h>
#include <stdlib.h>
@op
op / thread_recv_close.c
Last active December 17, 2015 16:49
assert on mutex.c:71 triggered when closing socket in separate thread
#include "src/nn.h"
#include "src/reqrep.h"
#include "src/utils/err.c"
#include "src/utils/thread.c"
#include "src/utils/sleep.c"
#include <stddef.h>
#include <assert.h>
#include <stdlib.h>
@op
op / bash-history-to-zsh-history.py
Created September 28, 2012 21:25
Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | bash-history-to-zsh-history >> ~/.zsh_history
import sys
def main():
@op
op / pubsub.c
Created December 22, 2011 18:11
xpub/xsub assertion
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <zmq.h>
int main (int argc, char *argv[])
{
const char *msg[] = {"0", "1", "2"};
@op
op / gist:876997
Created March 18, 2011 22:53
go flag parser
diff -r f487d74ff495 src/pkg/flag/export_test.go
--- a/src/pkg/flag/export_test.go Thu Feb 10 23:01:45 2011 +0800
+++ b/src/pkg/flag/export_test.go Fri Feb 18 15:24:20 2011 +0800
@@ -12,7 +12,7 @@
// After calling ResetForTesting, parse errors in flag handling will panic rather
// than exit the program.
func ResetForTesting(usage func()) {
- flags = &allFlags{make(map[string]*Flag), make(map[string]*Flag), os.Args[1:]}
+ flags = NewParser()
Usage = usage