Skip to content

Instantly share code, notes, and snippets.

View flaviut's full-sized avatar

Flaviu Tamas flaviut

View GitHub Profile
@flaviut
flaviut / lin-py2.py
Created September 12, 2018 21:07
Output of sysconfig.get_config_vars() on various operating systems
Python 2.7.15 (default, Jun 27 2018, 13:05:28) [GCC 8.1.1 20180531] on linux2
>>> import sysconfig; from pprint import pprint; pprint(sysconfig.get_config_vars())
{'AC_APPLE_UNIVERSAL_BUILD': 0,
'AIX_GENUINE_CPLUSPLUS': 0,
'AR': 'ar',
'ARFLAGS': 'rc',
'ATHEOS_THREADS': 0,
'BASECFLAGS': '-fno-strict-aliasing',
'BASEMODLIBS': '',
'BEOS_THREADS': 0,
@flaviut
flaviut / todo.md
Last active September 10, 2018 19:02

Roadmap to calibre PY3

  • Make syntax correct for py3
  • build C extensions
    • ICU
    • speedups
    • winutils
    • everything else
  • Fix failing tests
from lib2to3 import fixer_base
from lib2to3.pytree import Node
from lib2to3.pygram import python_symbols as syms
from lib2to3.fixer_util import Name, ArgList
import libmodernize
class FixGetcwd(fixer_base.ConditionalFix):
BM_compatible = True
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.1.0
3 info using node@v10.5.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle foo@0.1.0~prestart: foo@0.1.0
6 info lifecycle foo@0.1.0~start: foo@0.1.0
7 verbose lifecycle foo@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle foo@0.1.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/user/dev/foo/node_modules/.bin:/home/user/dev/foo/node_modules/.bin:/usr/bin:/home/user/etc/.local/bin:/home/user/etc/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/opt/android-sdk/platform-tools:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/user/bin/:/home/user/etc/.nimble/bin/:/home/user/bin/:/home/user/etc/.nimble/bin/
9 verbose lifecycle foo@0.1.0~start: CWD: /home/user/dev/foo
@flaviut
flaviut / join.java
Created January 16, 2018 23:52
provides a string joining implementation for Java < 8
/**
* Joins the collection with string 'delimiter'. Somehow this function
* was overlooked in the stdlib until Java 8.
* <p>
* delimiter and collection must not be null.
*/
private static <T> String join(String delimiter, Collection<T> collection) {
// PRECONDITION delimiter and collection must not be null
StringBuilder result = new StringBuilder();
Iterator<T> iter = collection.iterator();
@flaviut
flaviut / groupby.java
Last active January 16, 2018 23:38
groupby for java 6 & 7
/**
* A generic interface for an one-element lambda
*/
private interface Predicate<P1, R> {
R apply(P1 p1);
}
private static <T, C> List<List<T>> groupBy(Collection<T> collection,
Predicate<? super T, C> byValue) {
// PRECONDITION collection and byValue must not be null
@flaviut
flaviut / box-drawing.md
Last active November 6, 2023 15:35
Box Drawing characters with examples

Box drawing fun

A few boxes drawn with Unicode box drawing characters:

╔═╦═╗
╠═╬═╣
║ ║ ║
╚═╩═╝
@flaviut
flaviut / libyaml.nim
Last active August 29, 2015 14:14
Nim libyaml wrapper. Here be dragons.
type
yaml_version_directive_t* = object
major*: cint
minor*: cint
type
yaml_tag_directive_t* = object
handle*: cstring
prefix*: cstring
type
yaml_encoding_t* {.size: sizeof(cint).} = enum
@flaviut
flaviut / debugging.md
Last active August 29, 2015 14:13
How to debug Nim code

Nim Debugging

I use GDB to debug my Nim code, but by default Nim doesn't output enough information to be usable. I pass --debuginfo --linedir:on to the nim command to fix that.

There is some name mangling, but in most cases things are still understandable. procs have an integer appended to the name, so when setting a breakpoint is done like this: b foo_431313. It's also possible to just line number for breakpoints, which is exactly as you might expect: b mymodule.nim:321.

Simple git-up

To install, download the script on your path, rename it to git-up and chmod +x git-up.

Usage is git up <remote> [params]. It iterates through all the the branches that exist on both local and the remote, and does git rebase $params $remote/$branch $branch. Really simple.

Dependencies are GNU Coreutils and git. Running linux? You'll have them both installed.