Skip to content

Instantly share code, notes, and snippets.

View Connicpu's full-sized avatar

Connie Hilarides Connicpu

View GitHub Profile
#![feature(prelude_import)]
#![no_std]
#![feature(proc_macro)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
#[macro_use]
extern crate serde_derive;
; Function Attrs: noinline norecurse nounwind readnone uwtable
define zeroext i1 @valid_token(i32) unnamed_addr #0 {
entry-block:
%1 = and i32 %0, -33
%2 = add i32 %1, -65
%3 = icmp ult i32 %2, 26
%.off14 = add i32 %0, -48
%4 = icmp ult i32 %.off14, 10
%or.cond17 = or i1 %4, %3
br i1 %or.cond17, label %bb12, label %bb10
#include <codecvt>
inline std::wstring WidenString(const std::string &narrow)
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(narrow);
}
@Connicpu
Connicpu / main.rs
Created April 1, 2016 20:57
Performing work on mutable slices across two threads
extern crate crossbeam;
fn main() {
let n = 100;
let mut data: Vec<_> = (0..n).collect();
{
let (left, right) = data.split_at_mut(n / 2);
crossbeam::scope(|scope| {
scope.spawn(|| {
#[derive(TLType)]
pub enum InputPeer {
#[tl_id(_7f3b18ea)]
Empty,
#[tl_id(_7da07ec9)]
SelfPeer,
#[tl_id(_1023dbe8)]
Contact { user_id: i32 },
#[tl_id(_9b447325)]
Foreign { user_id: i32, access_hash: i64 },
Push-Location
Set-Location HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\
if (!(Test-Path "Personalize")) {
New-Item "Personalize"
}
Set-ItemProperty "Personalize" -Name AppsUseLightTheme -Type DWORD -Value 0
Pop-Location
@Connicpu
Connicpu / doathing.rs
Last active December 20, 2021 11:01
Poking a Rust vtable from C++
#![feature(box_syntax)]
pub struct MyThing {
stuff: Vec<i32>,
}
pub trait DoAThing {
fn add(&mut self, item: i32);
fn remove(&mut self) -> i32;
}
int server_accept(int listener)
{
sockaddr_storage client_address; /* This is big enough to store an IPv4 or IPv6 address */
int address_size = sizeof(client_address);
int socket = accept(listener, &client_address, &address_size);
if (fork())
{
/* close now, it won't stop the connection until
* the child also closes it
template <typename T>
class rwlock
{
T obj;
SRWLOCK lock;
class guard
{
rwlock &rwl;
bool mut;
/*********************************
* CriticalSections.cpp
* Connor Hilarides
* Created 2014/08/07
* Copyright © 2014 DigiPen Institute of Technology, All Rights Reserved
*********************************/
#include "CriticalSections.h"