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
@netj
netj / memusg
Last active June 4, 2024 07:04
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
@meijeru
meijeru / unicode-multiple.reds
Created October 30, 2011 12:08
UTF-8 string to block of Unicode codepoints conversion: Red/System
Red/System []
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; function utf8-to-cps (cps = codepoints)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This function decodes UTF-8 information supplied as bytes in argument u
; and uses the argument res to store the array of codepoints
; (integers >= 0 and < 10FFFFh); the space for this array should have been
; allocated by the caller; an upper limit for the size of the array in bytes
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
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

@mcdurdin
mcdurdin / kex_cryptoapi_cng.cpp
Last active October 29, 2019 09:05
RSA Key Exchange between CryptoAPI and CNG
/*
Example program to demonstrate sharing public keys from CryptoApi to CNG
Note: Reversing the process would allow sharing public keys from CNG to
CryptoApi. You would need to be careful of padding parameters and
versions.
License (yes, yes, BSD):
Copyright (c) 2013, Marc Durdin
@mikeash
mikeash / runtime-class.m
Created November 22, 2013 16:46
Creating a usable class purely at runtime using the Objective-C runtime APIs.
// clang -fobjc-arc -framework Foundation runtime-class.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface Person : NSObject
- (id)initWithFirstName: (NSString *)firstName lastName: (NSString *)lastName age: (NSUInteger)age;
@mmozeiko
mmozeiko / win32_crt_float.cpp
Last active February 16, 2024 14:24
Visual C/C++ CRT functionality
extern "C"
{
int _fltused;
#ifdef _M_IX86 // following functions are needed only for 32-bit architecture
__declspec(naked) void _ftol2()
{
__asm
{
@greggirwin
greggirwin / analog-clock-2.red
Last active June 17, 2016 23:24
Analog clock, refined, with informational comments
Red [
Title: "Red O'clock"
Author: "Gregg Irwin"
File: %analog-clock.red
Tabs: 4
Needs: View
Purpose: {
- Introduce some basic Red concepts, like functions and datatypes
- Show how the DRAW block and timer events work in the View system
}
@greggirwin
greggirwin / bubbles.red
Last active June 17, 2016 23:23
Animated bubbles
Red [
Title: "Bubbles"
Author: [REBOL version "Gabriele Santilli" Red port "Gregg Irwin"]
File: %bubbles.red
Tabs: 4
Needs: View
]
system/view/auto-sync?: no
@greggirwin
greggirwin / paint.red
Last active February 8, 2018 18:28
Red Paint (World's smallest paint program)
Red [
title: "Paint"
Author: [REBOL version "Frank Sievertsen" Red port "Gregg Irwin"]
File: %paint.red
Tabs: 4
Needs: View
version: 0.0.2
]
draw-blk: copy []
@greggirwin
greggirwin / calculator.red
Created June 19, 2016 00:04
Red Calculator
Red [
Title: "Calculator"
File: %calculator.r
Version: 0.0.1
;Date: 18-Jun-2016
Author: [
REBOL version ["Jeff Kreis" "Allen Kamp" "Carl Sassenrath"]
Red port "Gregg Irwin"
]
Purpose: "Simple numeric calculator."