Skip to content

Instantly share code, notes, and snippets.

View Ad115's full-sized avatar

Andrés García García Ad115

View GitHub Profile
@eulersson
eulersson / main.cpp
Last active November 24, 2020 02:38
Thrust + CUDA kernel
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <thrust/device_vector.h>
/*
* --- Using Thrust vectors in kernel functions ---
* This example demonstrates how we can use device vectors (vectors that live
* in GPU) as arguments to a kernel launched by the CPU.
@zopieux
zopieux / tree.py
Created May 11, 2015 08:03
Python tree
def tree(root):
"""
Node(label = "string", children = [list of Node])
"""
ret = [root.label]
ln = len(root.children)
for i, child in enumerate(root.children):
for j, s in enumerate(tree(child)):
char = '│ '
if i == ln - 1: # last child
@caruccio
caruccio / attr-tree.md
Last active October 16, 2019 05:59
Attribute tree

Attribute tree

Based upon One-line Tree in Python, here is a tree-like class where struct is accesible by attributes rather than keys (much more readable IMHO):

from collections import defaultdict

class Tree(defaultdict):
	def __init__(self, *va, **kva):
		super(Tree, self).__init__(*va, **kva)