Skip to content

Instantly share code, notes, and snippets.

@nico
nico / gist:813631
Created February 6, 2011 19:27
vimrc to use per-file settings with chrome and clang_complete
let g:cr_root = '/Users/thakis/src/chrome-git/src/'
let g:cr_builddb = '/Users/thakis/src/chrome-git/src/all-builddb.sqlite'
fu! g:clang_per_file_user_options(path)
if a:path =~ g:cr_root
let l:path = a:path[strlen(g:cr_root):]
let l:cmd = 'sqlite3 ' . g:cr_builddb .
\' ''' . 'select command from gcc_build_commands join filenames ' .
\ 'on filename_input_id = filenames.rowid where name = "' .
\ l:path .
hummer:src thakis$ time ninja -C out/Release chrome
ninja: Entering directory `out/Release'
[151/9970] LIBTOOL-STATIC libwebkit_system_interface.a, POSTBUILDS
libtool: warning for library: libwebkit_system_interface.a the table of contents is empty (no object file members in the library define global symbols)
[444/9970] MACTOOL copy-bundle-resource ../../breakpad/src/client/mac/sender/Breakpad.xib
/* com.apple.ibtool.document.notices */
/Volumes/MacintoshHD2/src/chrome-git/src/out/Release/../../breakpad/src/client/mac/sender/Breakpad.xib:48: note: This view is clipping its content.
[590/9970] OBJCXX obj/breakpad/src/common/mac/breakpad_utilities.MachIPC.o
../../breakpad/src/common/mac/MachIPC.mm:190:18: warning: 'bootstrap_register' is deprecated [-Wdeprecated-declarations]
init_result_ = bootstrap_register(bootstrap_port,
@nico
nico / memchr_bench.cc
Created May 6, 2012 20:49
libSystem memchr / strchr benchmark.
// memchr / strchr benchmark
// clang -O2 -o chr_bench chr_bench.cc
//
// Includes a glibc memchr implementation for comparison, which makes this
// benchmark GPL-licensed I believe.
// Output on my system (OS X 10.7.3):
// stupid_memchr: 380.0us
// glibc_memchr: 105.0us
// memchr: 566.0us
@nico
nico / make_tab_icons.py.py
Created July 23, 2012 02:56
Creates retina icons for some PSMTabBarControl icons
from Foundation import *
from AppKit import *
from Quartz import *
def mkimg(w, h):
img = NSImage.alloc().initWithSize_((w, h))
return img
def saverep(rep, path):
rep.representationUsingType_properties_(NSPNGFileType, None) \
@nico
nico / gist:3890115
Created October 14, 2012 23:10
saving images
// uncompressed png, no dependencies
// from https://github.com/nico/hack/blob/master/wpng/wpng.c
void wpng(int w, int h, const uint8_t* pix, FILE* f) { // pix: rgba in memory
uint32_t crc_table[256];
for (uint32_t n = 0, c = 0; n < 256; n++, c = n) {
for (int k = 0; k < 8; k++) c = (c & 1) ? 0xedb88320L ^ (c >> 1) : c >> 1;
crc_table[n] = c;
}
#define CRCWRITE(d, len) fwrite(d, 1, len, f); for (int n = 0; n < len; n++) \
crc = crc_table[(crc ^ (d)[n]) & 0xff] ^ (crc >> 8)
@nico
nico / gist:5398098
Created April 16, 2013 18:02
ninja perf data for empty chromium builds over time.
Data was collected with:
time caffeinate ./runall.sh 4d9bf949e0fd6976725dea12bcc254fd39da6490 master ./gettime.sh | tee time.csv
$ cat runall.sh
#!/bin/bash
#
# This script runs a given command over a range of Git revisions. Note that it
# will check past revisions out! Exercise caution if there are important
@nico
nico / gist:5779489
Created June 14, 2013 04:37
repro for ninja issue #595
Nicos-MacBook-Pro:repro thakis$ cat repro.py
#!/usr/bin/env python
import ninja_syntax
n = ninja_syntax.Writer(open('build.ninja', 'w'))
n.rule(name='cxx',
command='clang++ -c $in -o $out -MF $out.d -MMD',
depfile='$out.d',
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#include <direct.h>
#include <stdint.h>
@nico
nico / gist:b0cca071e5b1fd71f929
Last active June 3, 2019 13:14
benchmarking different file stat()ing techniques on windows (parts based on https://github.com/cpizano/Kodefind/blob/master/src/engine_v1_win.cc)
// cl stattest.cc /Ox /GL /GR-
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#include <direct.h>

Keybase proof

I hereby claim:

  • I am nico on github.
  • I am thakis (https://keybase.io/thakis) on keybase.
  • I have a public key whose fingerprint is 6CB0 90B6 D027 3BCF FD99 475D E98E DBFB D44D EE5C

To claim this, I am signing this object: