Skip to content

Instantly share code, notes, and snippets.

Arnav Singh Arnavion

Block or report user

Report or block Arnavion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lib.rs
#![deny(rust_2018_idioms, warnings)]
#![deny(clippy::all, clippy::pedantic)]
//! This crate defines a `launder` macro that can be used to create a borrow that is scoped to the block where this macro is invoked,
//! even if the expression to create the borrow returns a `'static` borrow.
/// This macro can be used to create a borrow that is scoped to the block where this macro is invoked,
/// even if the expression to create the borrow returns a `'static` borrow.
///
/// For example, dereferencing a raw pointer with `&*` creates a borrow with an arbitrary lifetime which can be `'static`.
@Arnavion
Arnavion / ip-flash.awk
Created Nov 18, 2019
Flash Raspberry Pi's IP address using its LED
View ip-flash.awk
#!/usr/bin/awk -f
BEGIN {
while (1) {
split(exec_line_match("ip addr show dev eth0", " inet "), ip_a_parts, " ")
split(ip_a_parts[2], ip_value_parts, "/")
split(ip_value_parts[1], ip_parts, ".")
reset();
@Arnavion
Arnavion / build.sh
Last active Nov 30, 2019
Steam in Docker
View build.sh
#!/bin/bash
# Start here. This builds the docker-games container image.
set -euo pipefail
mkdir -p ~/docker-games/
docker image rm -f docker-games || :
View d3d12.rs
RIDL!{#[uuid(0xc4fec28f, 0x7966, 0x4e95, 0x9f, 0x94, 0xf4, 0x31, 0xcb, 0x56, 0xc3, 0xb8)]
interface ID3D12Object(ID3D12ObjectVtbl): IUnknown(IUnknownVtbl) {
fn GetPrivateData(
guid: *mut GUID,
pDataSize: *mut UINT,
pData: *mut c_void,
) -> HRESULT,
fn SetPrivateData(
guid: *mut GUID,
DataSize: UINT,
View spellcheck.rs
// Implements ISpellCheckerFactory
// Implements IUserDictionariesRegistrar
pub struct SpellCheckerFactory {
_use_cocreateinstance_to_instantiate: (),
}
impl SpellCheckerFactory {
#[inline]
pub fn uuidof() -> GUID {
GUID {
View wbemcli.rs
RIDL!{#[uuid(0xdc12a681, 0x737f, 0x11cf, 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24)]
interface IWbemClassObject(IWbemClassObjectVtbl): IUnknown(IUnknownVtbl) {
fn GetQualifierSet(
ppQualSet: *mut *mut IWbemQualifierSet,
) -> HRESULT,
fn Get(
wszName: LPCWSTR,
lFlags: i32,
pVal: *mut VARIANT,
pType: *mut i32,
@Arnavion
Arnavion / taskschd.rs
Created Aug 14, 2018
winapi-tlb-bindgen-bin taskschd.dll
View taskschd.rs
RIDL!{#[uuid(0x79184a66, 0x8664, 0x423f, 0x97, 0xf1, 0x63, 0x73, 0x56, 0xa5, 0xd8, 0x12)]
interface ITaskFolderCollection(ITaskFolderCollectionVtbl): IDispatch(IDispatchVtbl) {
fn get_Count(
pCount: *mut i32,
) -> HRESULT,
fn get_Item(
index: VARIANT,
ppFolder: *mut *mut ITaskFolder,
) -> HRESULT,
fn get__NewEnum(
View oleexp.rs
STRUCT!{struct UUID {
Data1: i32,
Data2: i16,
Data3: i16,
Data4: [u8; 8],
}}
STRUCT!{struct PROPERTYKEY {
fmtid: UUID,
pid: i32,
@Arnavion
Arnavion / doc.md
Created Sep 8, 2017
tiny-async-await
View doc.md

A tiny crate that provides async and await macros to create futures::Futures and futures::Streams.

Code that uses these macros requires #![feature(conservative_impl_trait, generators)]

  • Returning a futures::Future

     #![feature(conservative_impl_trait, generators)]
    
     #[macro_use]
@Arnavion
Arnavion / cargoall.ps1
Created May 16, 2017
Recurse into workspace crates / subdirectories and run the given command
View cargoall.ps1
function cargoall ([ScriptBlock] $ScriptBlock) {
if (Test-Path '.\Cargo.toml') {
# Workspace root
(cargo metadata --no-deps --format-version 1 | ConvertFrom-Json).packages |
%{ ([System.IO.FileInfo] $_.manifest_path).Directory } |
%{
Write-Host -ForegroundColor Green $_.FullName
Push-Location $_
&$ScriptBlock
Pop-Location
You can’t perform that action at this time.