Skip to content

Instantly share code, notes, and snippets.

View danielSanchezQ's full-sized avatar
🦀

Daniel Sanchez danielSanchezQ

🦀
View GitHub Profile
@danielSanchezQ
danielSanchezQ / const_str_check.rs
Created January 31, 2022 12:53
Compile time str eq
use const_str;
pub trait Foo {
const ID: &'static str;
}
struct A;
struct B;
impl Foo for A {
@danielSanchezQ
danielSanchezQ / flatten_files_and_deserialize.rs
Created May 4, 2021 13:34
Stream deserialized content by appending different files stream data
use std::fs;
use std::io;
use std::io::BufReader;
use std::path::{Path, PathBuf};
use bincode::Options;
type PersistentFragmentLog = String;
struct FileFragments {
#ifndef _MEM_LICKER_
#define _MEM_LICKER_
#include <unordered_map>
#include <iostream>
#include <string>
using namespace std;
using ptr = void*;
struct PtrData

Keybase proof

I hereby claim:

  • I am danielsanchezq on github.
  • I am netwave (https://keybase.io/netwave) on keybase.
  • I have a public key ASBVfZvvkvmyQlUIyK7jDaQsE8e9lIqAhHqjASkaZoIF2Qo

To claim this, I am signing this object:

@danielSanchezQ
danielSanchezQ / MemLicker.hpp
Last active March 12, 2019 11:27
Memory tracking utility
#ifndef _MEM_LICKER_
#define _MEM_LICKER_
#include <unordered_map>
#include <iostream>
#include <string>
using namespace std;
using ptr = void*;
struct PtrData
@danielSanchezQ
danielSanchezQ / functor.rs
Created December 17, 2018 08:10
Functor trait and example rust
trait Functor <A, B, C, F> where F : Fn(&A) -> B {
fn fmap(&self, f: F) -> C;
}
enum List<T> {
Nil,
List(T, Box<List<T>>)
}
impl<A, B, F> Functor<A, B, List<B>, F> for List<A>
@danielSanchezQ
danielSanchezQ / operations_test.py
Created September 23, 2018 12:13
batching operations groping method
#! /user/bin/python3
from collections import defaultdict
from itertools import groupby
import operator
class Operation(object):
TAPE = []
RECORD = defaultdict(lambda: 0)
RESULTS = {}
OPERATIONS = {
@danielSanchezQ
danielSanchezQ / matrix_transform_playground.py
Last active January 15, 2018 16:33
Short code to apply matrix transfomation over a cube in maya
import maya.cmds as cmds
import itertools as it
def transpose(m, size=4):
return list(it.chain.from_iterable(map(
lambda x: m[x:len(m):size],
xrange(size)
)))
class TransformationsPlayground(object):
@danielSanchezQ
danielSanchezQ / VietNumbers.py
Created December 21, 2017 09:25
Number to vietnamese representation
from itertools import *
vietNums = {
0 : u"",
1 : u"một",
2 : u"hai",
3 : u"ba",
4 : u"bốn",
5 : u"năm",
6 : u"sáu",
// bInarytree.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <algorithm>
class BinaryTree
{
private: