Skip to content

Instantly share code, notes, and snippets.

import argparse
import json
import re
import shutil
from io import StringIO
from pathlib import Path
from typing import Callable, Optional, Sequence, Tuple, Union, cast
from git.diff import Diff, DiffIndex
from git.objects.commit import Commit
@xaberus
xaberus / lib.rs
Last active November 3, 2018 07:46
pub struct LinkedList<T> {
...
marker: PhantomData<Box<T>>,
}
impl<T> LinkedList<T> {
/* other list methods go before */
/// Provides a cursor with immutable references to elements in the list.
/// The cursor starts ether with an empty element before the head or after the tail
double[] data1 = new double[100000];
for (int i = 0; i < data1.length; i++) {
data1[i] = WaveGenerator.sawtoothWave((double) i / samplesPerSecond, 440);
}
playSong(data1);
#include <Python.h>
#include <stdio.h>
static PyObject *
trt_foo(PyObject *self, PyObject *args) {
printf("here!!!\n");
return Py_None;
}
static PyMethodDef TrtMethods[] = {
flatmap: (a, b, c, (d, (e), f), g) -> (fn[a], fn[b], fn[c], fn[d], fn[e], fn[f], fn[g])
map: (a, b, c, (d, (e), f), g) -> (fn[a], fn[b], fn[c], fn[(d, (e), f)], fn[g])
int array0[100]; // global memory
int main() {
int array1[100]; // function stack
int * ptr0 = array1; // points to stack
int * ptr1 = &array1[0]; // ptr0 == ptr1
int * const ptr2 = alloca(sizeof(int) * 100); // points to stack!, almost the same as array1
int * ptr3 = malloc(sizeof(int) * 100); // points to heap
#include <stdio.h>
void swapptr(int ** a, int **b) {
int * c = *a;
*a = *b;
*b = c;
}
int main() {
class Foo {
int a;
void setA(int v) {
a = v;
}
};
Foo a = new Foo();
a->setA(123);
int vector_getmaxindex(vector_t * v, double z) {
int k;
if (z >= v->data[0]) {
for (k = 0; k < v->length; k++) {
if (v->data[k + 1] >= z) {
return k;
}
}
}
return -1;