Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Van Horne cwvh

  • Seattle, WA, USA
View GitHub Profile
@cwvh
cwvh / B.hs
Created Feb 4, 2014
fast reverse ordered character count
View B.hs
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Internal as B
import qualified Data.ByteString.Unsafe as B
import Data.List
import Data.Word
import Foreign
import Foreign.C.Types
import Foreign.Marshal.Alloc
import Foreign.ForeignPtr
import Text.Printf
@cwvh
cwvh / facebook.user.js
Created Apr 7, 2014
Fix for Facebook updated UI (2014-04-06) for smaller desktop displays
View facebook.user.js
// ==UserScript==
// @match https://www.facebook.com/*
// ==/UserScript==
var e = document.getElementById('rightCol');
e.parentNode.removeChild(e);
document.getElementById('contentArea').style.width = '100%';
View y.cc
#include <iostream>
#include <chrono>
#include <cstdlib>
int main() {
const int N = 7*1024;
int** m = new int*[N];
int* n = new int[N*N];
int* k = new int[N*N];
View gist:eb2d6e26829a7e6c4dbe
```
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1
owFtUn1QVFUUX0CcQcahUVK+4uOVTsGyvu93H0MGmNtESBFiyofre+/etzyQXdxd
QERGZhIdRWUnxxA0QFhKVIwSQ9JqDaKIIWrxY2IIScxCMHGUjBkcesvQmDPdv865
53d+9/e759gXe2k8PSacF1PMUVVeHr1joibVlvpaCSaaYTEWU4JJWxVksrkjk5CH
sBgsFxWLghXpFHO4yQyRLscaPo/RYoXIYlXMJhWF6ygdiZVq3XB3s6yYjMiSb1Hc
XJjEsQQvMyTPMzguUzInsgzFcAjRSOJpmeeALLIix6uU2War7alXsTlOgwLV27X0
2jU8rVfx+gQ2YQ5fMFcAPOSQSBKCwBEiYBkkMLTE4jTOI4YTcNwNtCLLvCWpqDDb
View x.py
""" pip install GitPython --upgrade --pre """
import git
import sys
def pretty_date(time=False):
"http://stackoverflow.com/questions/1551382/user-friendly-time-format-in-python"
from datetime import datetime
now = datetime.now()
if type(time) is int:
@cwvh
cwvh / vimrc
Created Aug 15, 2014
minimal vimrc
View vimrc
set nocompatible
filetype plugin indent on
syntax on
let mapleader = " "
no j gj
no k gk
no <c-j> 6j
no <c-k> 6k
no <c-a> ^
no <c-e> $
View __init__.py
#!/usr/bin/env python
#
# Copyright 2009 Chris Van Horne
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
View admin.py
from django.contrib import admin
from foobar import models
class CommonSearchCriteria(admin.ModelAdmin):
search_fields = ('title',)
class AdvancedOptions(admin.ModelAdmin):
fieldsets = (
('Advanced options', {
'classes': ('collapse',),
View gist:268448
(setq frame-title-format (concat "%b - emacs@" system-name))
(setq inhibit-startup-screen t)
(setq make-backup-files nil)
(setq require-final-newline t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(fset 'yes-or-no-p 'y-or-n-p)
(setq-default indent-tabs-mode nil)
View gist:519799
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
/* IEEE-754 values taken from page 2 of:
* "Introduction to Floating point calculations and IEEE 754 standard"
* Jamil Khatib, August 10, 2000
*/
typedef uint32_t uint;