Skip to content

Instantly share code, notes, and snippets.

View qtxie's full-sized avatar
🏠
Working from home

Qingtian qtxie

🏠
Working from home
  • FullStack Technologies
View GitHub Profile
@qtxie
qtxie / ANSI.md
Created October 5, 2023 02:11 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@qtxie
qtxie / windows_nanosleep.c
Created March 27, 2020 07:53 — forked from Youka/windows_nanosleep.c
Windows nanosleep
#include <windows.h> /* WinAPI */
/* Windows sleep in 100ns units */
BOOLEAN nanosleep(LONGLONG ns){
/* Declarations */
HANDLE timer; /* Timer handle */
LARGE_INTEGER li; /* Time defintion */
/* Create timer */
if(!(timer = CreateWaitableTimer(NULL, TRUE, NULL)))
return FALSE;
@qtxie
qtxie / _readme_quarks.md
Created September 13, 2019 10:59 — forked from vurtun/_readme_quarks.md
Quarks: Graphical user interface

gui

@qtxie
qtxie / webcam_capture.c
Created September 13, 2019 07:19 — forked from mmozeiko/webcam_capture.c
Capture webcam device with Media Foundation API
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <stdio.h>
#include <intrin.h>
@qtxie
qtxie / Of Mice and Men
Created March 22, 2017 07:03 — forked from svoisen/Of Mice and Men
Information on low-level scrolling events on Mac OS X
From the WebKit documentation at:
http://www.opensource.apple.com/source/WebKit/WebKit-7533.16/chromium/src/mac/WebInputEventFactory.mm
// Of Mice and Men
// ---------------
//
// There are three types of scroll data available on a scroll wheel CGEvent.
// Apple's documentation ([1]) is rather vague in their differences, and not
// terribly helpful in deciding which to use. This is what's really going on.
//
@qtxie
qtxie / gist:67b382155c516b6af7b61a985880380e
Created November 10, 2016 23:30 — forked from Koze/gist:10550725
List of monospace font
// UIFontDescriptor on iOS 7 or later
NSDictionary *traitsAttributes = @{UIFontSymbolicTrait: @(UIFontDescriptorTraitMonoSpace)};
NSDictionary *fontAttributes = @{UIFontDescriptorTraitsAttribute: traitsAttributes};
UIFontDescriptor *fontDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:fontAttributes];
NSArray *array = [fontDescriptor matchingFontDescriptorsWithMandatoryKeys:nil];
for (UIFontDescriptor *descriptor in array) {
NSLog(@"%@", descriptor.postscriptName);
// NSLog(@"%@", [descriptor objectForKey:UIFontDescriptorNameAttribute]);
// NSLog(@"%@", [descriptor objectForKey:UIFontDescriptorVisibleNameAttribute]);
@qtxie
qtxie / irq_balance_habrahabr.sh
Created October 24, 2016 04:18 — forked from pavel-odintsov/irq_balance_habrahabr.sh
irq_balance_habrahabr.sh
#!/bin/bash
# from http://habrahabr.ru/post/108240/
ncpus=`grep -ciw ^processor /proc/cpuinfo`
test "$ncpus" -gt 1 || exit 1
n=0
for irq in `cat /proc/interrupts | grep eth | awk '{print $1}' | sed s/\://g`
do
f="/proc/irq/$irq/smp_affinity"
@qtxie
qtxie / latency.markdown
Created October 8, 2016 23:15 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@qtxie
qtxie / JSON.red
Last active October 6, 2016 22:39 — forked from dockimbel/JSON.red
JSON toy parser for Red
Red [
Title: "JSON parser"
File: %json.red
Author: "Nenad Rakocevic, Qingtian Xie"
License: "BSD-3 - https://github.com/red/red/blob/master/BSD-3-License.txt"
]
json: context [
quoted-char: charset {"\/bfnrt}
exponent: charset "eE"
@qtxie
qtxie / gameoflife2.red
Last active September 30, 2016 07:35 — forked from Mufferaw/gameoflife2.red
system/view/auto-sync?: no
grid: collect [repeat i 50 [keep/only collect [repeat j 50 [keep random true]]]]
scratchgrid: collect [repeat i 50 [keep/only collect [repeat j 50 [keep false]]]]
a: copy grid/1
b: copy grid/50
c: collect [keep/only b keep grid keep/only a]
count-neighbors: function [gridd x y][