Skip to content

Instantly share code, notes, and snippets.

@iancormac84
iancormac84 / error_response.json
Last active August 13, 2019 23:43
Gist displaying GraphQL, JSON, and Rust code snippets for help question.
{
"errors":[
{
"message":"Variable \"$input\" expected value of type \"Owner\" which cannot be used as an input type.",
"locations":[
{
"line":1,
"column":19
}
]
@iancormac84
iancormac84 / Cargo.toml
Created November 25, 2018 13:57
Gist showing attempt to use Ole Automation to invoke OLE objects
[package]
name = "accessole"
version = "0.1.0"
authors = ["iancormac84 <wilnathan@gmail.com>"]
edition = "2018"
[dependencies]
failure = "*"
oaidl = { git = "https://github.com/ZerothLaw/oaidl-safe", branch = "develop" }
winapi = "0.3.6"
@iancormac84
iancormac84 / winapi-conversion.rs
Last active May 23, 2019 09:56
How to work with WINAPI string types.
pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> {
fn inner(s: &OsStr) -> io::Result<Vec<u16>> {
let mut maybe_result: Vec<u16> = s.encode_wide().collect();
if maybe_result.iter().any(|&u| u == 0) {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
"strings passed to WinAPI cannot contain NULs",
)
.into());
}
@iancormac84
iancormac84 / alchemy.rs
Last active April 19, 2018 23:50
Example of Chemical Element Modelling
pub trait UniqueProperties {
const ATOMIC_NUMBER: u32;
const SYMBOL: &'static str;
const PERIOD: u8;
}
pub struct Hydrogen;
impl UniqueProperties for Hydrogen {
const ATOMIC_NUMBER: u32 = 1;
04d5937dd8be48901e267084394019dffdbf0b5c7d8297f6ba0be733f16fbc2a91f1ad97b973f00421be37c4d48085893463552f14f7b2605f05138d2887bc640d
@iancormac84
iancormac84 / paint.rs
Created September 26, 2015 12:52
Example of creating a window with a PaintDc context and drawing to it using a brush. Probably incorrect.
// Copyright 2015 The Rust-Windows Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]