• Interactive Poisson Blending on GPU
    Interactive Poisson Blending on GPU
  • 404 Not Found In Two Triangles
    404 Not Found In Two Triangles
  • Simplest and Fastest GLSL Edge Detection using Fwidth
    Simplest and Fastest GLSL Edge Detection using Fwidth

Category: Code

Timer: How to Measure Execution Time in C++ 11

Timer is important for measuring speed-ups or elapsed time for custom algorithms. We used to import <ctime> and measure time with:

However, clock() measures CPU time, not actual time elapsed (which may be much greater) according to this StackOverFlow. Hence, here provides my code snippets to measure execution time in C++ as a DebugTimer Class….


404 Not Found in Two Triangles

Inspred by 104 from ShaderToy, I made a new 404 Not Found page with two triangles in GLSL using calligraphic strokes. Live Demo Please visit: http://duruofei.com/404 Code

 


Quick Fix: PHP SSL certificate error: unable to get local issuer certificate

Steps: Go to https://github.com/bagder/ca-bundle/tree/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09 Fork or download the repository, put the file ca-bundle.crt in a certain place. Open php.ini, add two lines of code: curl.cainfo=“your-dir/ca-bundle.crt” openssl.cafile=“your-dir/ca-bundle.crt” Everything works fantastically now!   This is useful for your are scraping the Twitter.


Do We Really Need 24-bit Color? Floyd–Steinberg Dithering

Do We Really Need 24-bit Color? When I was paining in childhood, I only have 24 colors, and somethings I only buy 4 colors to use (i.e., red, green, blue and white). However, blending of all colors could create vivid pictures. (image from pininterest) On the other side, the storage of digital colors in computer…


ACM UIST 2015 Summary from AR / VR Perspective

It was a great pleasure to attend the ACM UIST 2015 conference at Charlotte, NC for the first time. First, let me explain my initial motivation to UIST (skip this if you felt boring 🙂 I just keep it as a memory. The first time I learnt about HCI is when I was conducting a student research project, EyeControl, in…


Local Sensitivity Hashing in C

Today I tried local sensitivity hashing in C. The result is very interesting. Suppose you have N feature vectors, each vector is in R^D, you want to hash them to 1<<K bytes. Local Sensitivity Hashing give you the answer in O(NDK); It might be useful for image compression. Of course, k-means is preferred and you…


Uniforms Types in Three.js

Here is a a cheat sheet for uniform types in Three.js

Here is how to cite them in GLSL:

 


Bresenham’s Line Algorithm in C++

Bresenham’s line algorithm is an algorithm that determines the points of an n-dimensional raster that should be selected in order to form a close approximation to a straight line between two points. It is commonly used to draw lines on a computer screen, as it uses only integer addition, subtraction and bit shifting, all of…


Quicksort, Mergesort, and Bucket sort in C

Quick Sort This is used in research code when built-in qsort does not satisfy the demands.

K-th element Qsort can be used to find the Kth smallest element a[k]:

Use partition to sort 0, 0, 0, 1, 1, 2, 2, 2…

  Merge Sort Linked List Version Here is the merge sort…


Treap in 45 lines of C++

According to Wikipedia, in computer science, the treap and the randomized binary search tree are two closely related forms of binary search tree data structures that maintain a dynamic set of ordered keys and allow binary searches among the keys. After any sequence of insertions and deletions of keys, the shape of the tree is…