Skip to content

Instantly share code, notes, and snippets.

@KunYi
KunYi / f9_usart1
Last active August 29, 2015 13:56
STM32F429I change debug port, from UART4 to USART1
diff --git a/board/discoveryf4/board.c b/board/discoveryf4/board.c
index 5098469..4277cf4 100644
--- a/board/discoveryf4/board.c
+++ b/board/discoveryf4/board.c
@@ -7,26 +7,26 @@
#include <platform/stm32f4/usart.h>
struct usart_dev console_uart = {
- .u_num = 4,
+ .u_num = 1,
@KunYi
KunYi / test.c
Created May 31, 2018 05:02
for stack size testing
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
#include <alloca.h>
long long i;
int main(int argc, char** argv) {
char a;
@KunYi
KunYi / test.c
Created May 31, 2018 07:14
test stack
-----------------------------------------
; getSP functions
.text
.globl getSP
.type getSP, @function
getSP:
MOVQ %rsp, %rax
RET
------------------------------------------
@KunYi
KunYi / test4K.c
Created May 31, 2018 09:00
sub 4K sp for x86_64
-----------------------------------------
; sub 4K on Stack pointer register
-----------------------------------------
.text
.globl DecSp4K
.type DecSp4K, @function
DecSp4K:
MOVQ %rsp, %rax
SUB $(4096-8), %rsp
@KunYi
KunYi / gist:d9537814b4a315c02af75a93abc8b0fa
Created July 5, 2018 01:53
消失的回答 近期曝光的 50 分钟李笑来谈话录音内容是否戳了你的心?
from https://www.zhihu.com/question/283798564
录音听了几分钟就开始笑,内容基本符合我的认知,虽然一直很不喜欢李笑来,但在商言商,他确实很成功,至少比我成功的多。
李笑来这次谈话主要是围绕虚拟货币的,其实没啥好谈的,他讲的不是啥新鲜事,明眼人心里门清,只不过这些话不能公开讲罢了。
(如果你听到这些录音内容极度震惊,那很抱歉,你就是他说的傻逼中的一员,so sad....)
但我今天打算多说几句,算是分享一下自己的感悟。有些话公开场合确实没法说,就当是老年人的碎碎念吧。
01. 平民存在的意义就是当韭菜,你的社会价值=个人平均创造价值×被收割次数
02. 割韭菜也是有食物链的,通常是大国割全球,小国割国民,国内高层割中层、中层割底层。当然也有玩脱的时候,例如一战各帝国分赃不均大打出手结果引火烧身,例如明朝后期搞的老百姓活不下去大喊王侯将相宁有种乎,逼得皇帝上吊。但通常来说,最底层的韭菜(平民),只要尚能活命,就会一直忍耐下去。比如说通货膨胀,房价,下岗潮、股市……人类社会的变革无论好坏一定会出现牺牲品,那么关键时刻谁牺牲呢?当然是韭菜啦。(不过确实有些牺牲是伟大的,只能说这就是必须付出的代价吧)
void TestCopy()
{
BOOL cond = FALSE;
IFileOperation *FileOperation1 = NULL;
IShellItem *isrc = NULL, *idst = NULL;
BIND_OPTS3 bop;
SHELLEXECUTEINFOW shexec;
HRESULT r;
do {
@KunYi
KunYi / introrx.md
Created August 18, 2018 05:49 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@KunYi
KunYi / winutils.cs
Created September 19, 2018 01:31
C# snippets for Windows system
using System.Management;
static void installProductKey(string key)
{
var mbs = new ManagementObjectSearcher("Select Version From SoftwareLicensingService");
foreach (ManagementObject mo in mbs.Get())
{
mo.InvokeMethod("InstallProductKey", new object[] { key });
}
#include <wmiguid.h>
NTSTATUS status;
GUID smbiosGUID = SMBIOS_DATA_GUID; // defined in wmiguid.h
PVOID wmiObject = NULL;
PWNODE_ALL_DATA dataBuffer;
//
// Get a WMI block handle to the SMBIOS_DATA_GUID
@KunYi
KunYi / test.c
Created June 7, 2019 04:31
Note: Read/Write UEFI variables under Windows 7 and later
#include "stdafx.h"
void RasiePrivileges(void)
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken)) {