Skip to content

Instantly share code, notes, and snippets.

View stepancheg's full-sized avatar

Stepan Koltsov stepancheg

View GitHub Profile
[yozh@PowerBook-2:~/tmp]% cat hello.cxx
#include <iostream>
using namespace std;
class zbool: bool { };
int main(void) {
cout << "hello, world" << endl;
return 0;
diff -r 8dc6481b5d93 dulwich/pack.py
--- a/dulwich/pack.py Fri May 01 20:16:07 2009 -0700
+++ b/dulwich/pack.py Sat May 02 17:42:53 2009 +0400
@@ -30,6 +30,9 @@
a pointer in to the corresponding packfile.
"""
+from mercurial import demandimport
+demandimport.disable()
+
** unknown exception encountered, details follow
** report bug details to http://www.selenic.com/mercurial/bts
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 1.2)
** Extensions loaded: forest, graphlog, hg-git, hgsubversion, mq, patchbomb
Traceback (most recent call last):
File "/usr/bin/hg", line 27, in ?
mercurial.dispatch.run()
File "/var/lib/python-support/python2.4/mercurial/dispatch.py", line 16, in run
sys.exit(dispatch(sys.argv[1:]))
@stepancheg
stepancheg / gist:167566
Created August 14, 2009 01:15
How to convert Scala XML to JDK DOM
object XmlHelpers {
val docBuilder =
javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder()
}
class NodeExtras(n: Node) {
def toJdkNode(doc: org.w3c.dom.Document): org.w3c.dom.Node =
n match {
case Elem(prefix, label, attributes, scope, children @ _*) =>
// XXX: ns
@stepancheg
stepancheg / gist:168375
Created August 15, 2009 15:18
PackageLoader.doComplete diff
Index: Global.scala
===================================================================
--- Global.scala (revision 18483)
+++ Global.scala (working copy)
@@ -848,6 +848,7 @@
}
}
for ((sym, file) <- symSource.iterator) resetPackageClass(sym.owner)
+ Junk.printStats()
informTime("total", startTime)
@stepancheg
stepancheg / gist:168376
Created August 15, 2009 15:19
Junk — dummy profiler
package scala.tools.nsc
object Junk {
def currentTimeMicros = System.nanoTime / 1000
case class Current(stack: List[String], start: Long)
var current: Option[Current] = None
val map = new scala.collection.mutable.HashMap[String, Long]
"
" Author: Alex Naanou
"
" WARNING: The following will kill most indent functionality in vim.
" though you still can use ^F
"
" to install just drop me into your plugin dir.
nnoremap o ^y<home>o<esc>pI
nnoremap O ^y<home>O<esc>pI
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
size_t find_newline(const char* ptr, size_t len) {
size_t i = 0;
while (i < len) {
if (ptr[i] == '\n')
return i + 1;
if (ptr[i] == '\r') {
if (i + 1 < len && ptr[i + 1] == '\n')
return i + 2;
else
return i + 1;
@stepancheg
stepancheg / gist:233190
Created November 12, 2009 19:05
newline detection
.file "hello.c"
.text
.p2align 4,,15
.globl find_newline
.type find_newline, @function
find_newline:
.LFB3:
xorl %edx, %edx
testq %rsi, %rsi
je .L3