Skip to content

Instantly share code, notes, and snippets.

View slashvar's full-sized avatar

Marwan Burelle slashvar

View GitHub Profile
package main
import (
"context"
"fmt"
"log"
"os"
"time"
_ "github.com/joho/godotenv/autoload"
@slashvar
slashvar / auto-ref.cc
Created October 12, 2021 11:27
`const auto&` vs `const auto`
#include <iostream>
#include <string>
#include <type_traits>
struct Foo
{
std::string content;
const std::string& get() const
{
@slashvar
slashvar / noncopyable.cc
Created October 4, 2018 12:59
C++ constructors check ...
/*
* checking some assumptions
* compile with: clang++ -Weverything -Wno-c++98-compat -std=c++17 -o noncopyable noncopyable.cc
*/
#include <iostream>
#include <type_traits>
class Default {};
@slashvar
slashvar / rebfs.c
Created September 20, 2017 09:26
Recursive example of a BFS in C
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
struct queue {
size_t cap, start, size;
int store[0];
};
struct queue* new_queue(size_t cap)
@slashvar
slashvar / dfs.py
Created July 22, 2017 18:10
A simple DFS example
import graphviz
g = {
'A': ['B', 'C', 'D', 'F'],
'B': ['C', 'D'],
'D': ['A', 'C'],
'C': [],
'E': ['C', 'G'],
'F': ['A', 'C'],
'G': ['E']
@slashvar
slashvar / gist:014cb091f66c413d39009c08afc92c69
Created June 30, 2017 12:40
Change for module creation
static
PyObject* pepi_module_init(void) {
PyObject *m;
if (PyType_Ready(&pepy_parsed_type) < 0 ||
PyType_Ready(&pepy_section_type) < 0 ||
PyType_Ready(&pepy_import_type) < 0 ||
PyType_Ready(&pepy_export_type) < 0 ||
PyType_Ready(&pepy_relocation_type) < 0 ||
PyType_Ready(&pepy_resource_type) < 0)
@slashvar
slashvar / siamese_lstm.py
Created March 20, 2017 11:37
LSTM siamese network (masking issues)
from keras import backend as K
from keras.layers import Input, Dense, merge, Dropout, Lambda, LSTM, Masking
from keras.models import Model, Sequential
from keras.optimizers import SGD, RMSprop, Adam, Nadam
from sys import argv
import argparse
import csv
import json
import numpy as np
import pickle