Skip to content

Instantly share code, notes, and snippets.

View maxint's full-sized avatar

Naiyang Lin maxint

View GitHub Profile
@marekyggdrasil
marekyggdrasil / gen.py
Created September 18, 2018 01:31
Example how to read/write large files in incremental way using cPickle. Run `gen.py` to generate a file containing list of integers then use `read.py` to read this list incrementally from the file.
import cPickle as pickle
import io
lst = range(16)
with io.open('list.p', 'wb') as f :
pickler = pickle.Pickler(f)
for l in lst :
pickler.dump(l)
@maddouri
maddouri / has_member.hpp
Last active January 5, 2024 01:38
Checking the Existence of a C++ Class Member at Compile Time
// A compile-time method for checking the existence of a class member
// @see https://general-purpose.io/2017/03/10/checking-the-existence-of-a-cpp-class-member-at-compile-time/
// This code uses "decltype" which, according to http://en.cppreference.com/w/cpp/compiler_support
// should be supported by Clang 2.9+, GCC 4.3+ and MSVC 2010+ (if you have an older compiler, please upgrade :)
// As of "constexpr", if not supported by your compiler, you could try "const"
// or use the value as an inner enum value e.g. enum { value = ... }
// check "test_has_member.cpp" for a usage example
@bkaradzic
bkaradzic / orthodoxc++.md
Last active June 1, 2024 02:52
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

@Flix01
Flix01 / imguitabwindow.cpp
Last active August 19, 2023 08:35
ImGui::TabWindow: a self-partitioning ImGui::Window with TabLabels that can be dragged around.
#include "imguitabwindow.h"
#include <imgui_internal.h>
#include <imgui.h> // intellisense
// TODO: Clean this code, it's a mess!
namespace ImGui {
@Flix01
Flix01 / imguitablabel.h
Last active October 12, 2021 22:36
A ImGui::TabLabels(...) that supports line wrapping, tab reordering through drag'n'drop and tab closing through MMB press.
#pragma once
#include <imgui.h>
// USAGE EXAMPLE
/*
ImGui::Text("Tabs (based on the code by krys-spectralpixel):");
static const char* tabNames[] = {"Render","Layers","Scene","World","Object","Constraints","Modifiers","Data","Material","Texture","Particle","Physics"};
static const int numTabs = sizeof(tabNames)/sizeof(tabNames[0]);
static const char* tabTooltips[numTabs] = {"Render Tab Tooltip","","","","Object Type Tooltip","","","","","Tired to add tooltips...",""};
static int tabItemOrdering[numTabs] = {0,1,2,3,4,5,6,7,8,9,10,11};
@Flix01
Flix01 / README.txt
Last active August 19, 2023 08:36
imguifilesystem dialogs for imgui v.1.17 wip (https://github.com/ocornut/imgui/issues/88)
imguifilesystem dialogs for imgui v.1.17 wip (https://github.com/ocornut/imgui).
See also: https://github.com/ocornut/imgui/issues/88
It's composed by three files:
- imguifilesystem.h (usage instructions are here)
- imguifilesystem.cpp
- dirent_portable.h
It needs testing and feedback (expecially for Windows/VisualC++ and MacOS).
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
typedef int i; //Save space by using 'i' instead of 'int'
typedef float f; //Save even more space by using 'f' instead of 'float'
//Define a vector class with constructor and operator: 'v'
struct v {
f x,y,z; // Vector has three float attributes.
@xanxys
xanxys / affine.py
Created September 17, 2012 13:10
SE2 and SE3
# coding=utf-8
"""
affine: provides 2d and 3d rotation and translation library
"""
from __future__ import division
import math
import numpy as np
class SE2(object):
"""
@himika
himika / import_facegen_tri.py
Created July 3, 2012 03:39
.tri file importer for Blender 2.49b 要 pyffi 2.1.10
#!BPY
"""
Name: 'FaceGen TRI (.tri)...'
Blender: 249
Group: 'Import'
Tooltip: 'Load a FaceGen TRI file.'
"""
__author__= "himika"
@kevintop
kevintop / 12306AutoSubmit.user.js
Created January 8, 2012 08:11
12306 Auto Submit
/*
12306 Auto Submit => A javascript snippet to help you auto submit.
Copyright (C) 2011 Kevintop
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes 12306.user.js