Skip to content

Instantly share code, notes, and snippets.

Mahmoud Al-Qudsi mqudsi

Block or report user

Report or block mqudsi

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
@mqudsi
mqudsi / WebView2Extensions.cs
Created May 26, 2020
WebView2 Extension Methods
View WebView2Extensions.cs
namespace NeoSmart.WebExtensions
{
static class WebView2Extensions
{
private static readonly ILogger Logger = Serilog.Log.Logger;
public static void Navigate(this WebView2 webview, Uri url)
{
//webview.NavigateToString($"<meta http-equiv='refresh' content='0; URL='{url}' />");
webview.Source = url;
@mqudsi
mqudsi / JsonRequest.cs
Created Apr 29, 2020
Asynchronous Utf8JsonReader parser
View JsonRequest.cs
using System;
using Serilog;
using System.IO;
using System.Threading.Tasks;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Buffers;
using System.Net;
namespace MessageClient
@mqudsi
mqudsi / StreamSequence.cs
Created Apr 29, 2020
StreamSequence, a stream-to-ReadOnlySequenceSegment<byte> wrapper
View StreamSequence.cs
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Buffers;
namespace MessageClient
{
class StreamSequence : IDisposable
{
@mqudsi
mqudsi / ffi-fn-registration.rs
Created Dec 23, 2018
A rust snippet to convert an anonymous function (or closure?) into an FFI-compatible callback
View ffi-fn-registration.rs
use std::os::raw::c_void;
extern {
fn register_callback(callback: extern fn(*const c_void, u32), user: *const c_void);
}
fn register<F: Fn(u32)>(f: F) {
extern fn handler<F: Fn(u32)>(f_ptr: *const c_void, val: u32) {
let f = unsafe { &*(f_ptr as *const F) };
f(val)
}
@mqudsi
mqudsi / spawntest.c
Last active Mar 5, 2018
Test for correct posix_spawn behavior when pgrp = 0
View spawntest.c
#include <errno.h>
#include <signal.h>
#include <spawn.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define nullptr 0
View magic.js
$(document).ready(function () {
$("select.magic").each(function () {
var select = $(this);
if (!select.hasOwnProperty("removedExtraneous")) {
select.removedExtraneous = [];
}
var filterFunction = function () {
var oldVal = select.val();
select.children("option.extraneous").each(function () {
@mqudsi
mqudsi / gist:4197573
Created Dec 3, 2012
GCC replacement of hard-coded null %s parameter
View gist:4197573
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main:
Leh_func_begin1:
pushq %rbp
Ltmp0:
movq %rsp, %rbp
Ltmp1:
subq $16, %rsp
View gist:4154289

Premise: a small rant about software reliability.

I'm very serious about software reliability, and this is not just a good thing. It is good in a sense, as I tend to work to ensure that the software I release is solid. At the same time I think I take this issue a bit too personally: I get upset if I receive a crash report that I can't investigate further for some reason, or that looks like almost impossible to me, or with an unhelpful stack trace.

Guess what? This is a bad attitude because to deliver bugs free software is simply impossible. We are used to think in terms of labels: "stable", "production ready", "beta quality". I think that these labels are actually pretty misleading if not put in the right perspective.

Software reliability is an incredibly complex mix of ingredients.

@mqudsi
mqudsi / NameCase.cs
Created Apr 25, 2012
Function for correcting capitalization of user-entered names
View NameCase.cs
namespace NeoSmart
{
public static class Utils
{
//This function will only attempt to capitalize the first letter, etc. of a name
//if and only if the user appears to have entered all caps or all lowercase
public static string ProperCase(string stringToFormat)
{
System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;
@mqudsi
mqudsi / menu.lst
Created Nov 22, 2011
Sample EasyBCD NeoGrub configuration file used to dual-boot XP/Vista, hiding the Vista drive when booting into XP.
View menu.lst
# NeoSmart NeoGrub Bootloader Configuration File
#
# This is the NeoGrub menu.lst file, and should be located at x:\NST\menu.lst
# (where x = your "system" partition i.e. the one containing all of the boot files)
# Please see the EasyBCD Documentation for information on how to create/modify entries
# http://neosmart.net/wiki/display/EBCD
default 0
timeout 10
You can’t perform that action at this time.