Skip to content

Instantly share code, notes, and snippets.

View pravic's full-sized avatar

pravic

View GitHub Profile
@pravic
pravic / mangle.py
Created November 15, 2012 13:01
Clang MicrosoftMangle verification script
#!python
"""
Clang MicrosoftMangle verification script
Requirements:
* cl.exe and clang.exe must be accessible via %PATH%
* strings.exe utility from SysInternals suite
* xargs.exe from gnuwin32 or mingw sys
Description:
From de33fd77983d89cbf42c0710aec4b0ef2cff6a52 Mon Sep 17 00:00:00 2001
From: pravic <ehysta@gmail.com>
Date: Sat, 21 Sep 2013 12:49:49 +0400
Subject: [PATCH] fix long double for MSVC 12 (2013)
---
dmd2/root/port.c | 8 +++++---
vcbuild/strtold.c | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
#include <string>
#include <vector>
// 1. std::basic_string have continuos storage
std::wstring GetWindowTextW(HWND hWnd)
{
std::wstring text(::GetWindowTextLengthW(hWnd), L'\0');
size_t len = ::GetWindowTextW(hWnd, &text[0], text.size());
text.resize(len);
return std::move(text);
@pravic
pravic / core.rs
Last active April 8, 2016 07:09
msvc-target.json
#[lang = "sized"]
#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]
#[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
pub trait Sized {
// Empty.
}
pub trait Clone : Sized {
fn clone(&self) -> Self;
#[inline(always)]
@pravic
pravic / check-c.ll
Last active April 11, 2016 21:38
rustc-fastcall
; ModuleID = 'check.c'
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc18.0.0"
; Function Attrs: nounwind
define i32 @main() #0 {
entry:
%retval = alloca i32, align 4
store i32 0, i32* %retval, align 4
%call = call x86_fastcallcc i32 @"\01@outer_call@12"(i32 inreg 1, i8 inreg zeroext 2, i16 zeroext 3)
@pravic
pravic / option.rs
Created April 25, 2016 17:49
size-of-option
use std::mem::size_of;
#[repr(C)]
pub enum POption<T> {
PSome(T),
}
#[repr(C)]
pub struct SOption<T>(T);
@pravic
pravic / hola.cpp
Created April 27, 2016 07:23
Brackets balance
#include <vector>
int verify(const char* input) {
std::vector<char> stack;
while(const char c = *input++) {
if (c == '(' || c == '[' || c == '<') {
stack.push_back(c);
} else if (c == ')' || c == ']' || c == '>') {
if (stack.empty()) { return 0; }
char& prev = stack.back();
@pravic
pravic / disable-stdafx.patch
Created May 11, 2017 18:19
Disable stdafx.h in Sciter
diff --git a/include/sciter-win-main.cpp b/include/sciter-win-main.cpp
index 9f2699e..104b70a 100644
--- a/include/sciter-win-main.cpp
+++ b/include/sciter-win-main.cpp
@@ -1,4 +1,6 @@
-#include "stdafx.h"
+// It is better to disable stdafx.h by default.
+// And enable it explicitly via /Fstdafx.h compiler option (C/C++ - Advanced - Force Include File).
+// #include "stdafx.h"
@pravic
pravic / Cargo.toml
Last active May 14, 2017 05:52
scwindemo
[package]
name = "scwindemo"
version = "0.1.0"
[dependencies]
sciter-rs = "0.4.16"
@pravic
pravic / rust_snippets.py
Created July 24, 2018 18:05
Sublime snippets to VSCode
def parse_xml_snippet(root):
snippet = {}
description = None
for node in root:
if node.tag == 'content':
snippet['body'] = list(node.text.lstrip().splitlines())
elif node.tag == 'tabTrigger':
snippet['prefix'] = node.text