Skip to content

Instantly share code, notes, and snippets.

View mqudsi's full-sized avatar

Mahmoud Al-Qudsi mqudsi

View GitHub Profile
View env_dyn.patch
diff --git a/fish-rust/src/ b/fish-rust/src/
index 04a0a26be..416ed33f6 100644
--- a/fish-rust/src/
+++ b/fish-rust/src/
@@ -97,9 +97,8 @@ struct VarDispatchTable {
// TODO: Delete this after input_common is ported (and pass the input_function function directly).
fn update_wait_on_escape_ms(vars: &EnvStack) {
- let fish_escape_delay_ms = vars.get_unless_empty(L!("fish_escape_delay_ms"));
- let var = crate::env::environment::env_var_to_ffi(fish_escape_delay_ms);
mqudsi / error-reporter.js
Last active May 18, 2023 01:00
Client-side JavaScript error reporting library, compatible with ancient browsers.
View error-reporter.js
// JavaScript error reporting library.
// Copyright (c) Mahmoud Al-Qudsi, NeoSmart Technologies. All rights reserved.
// Licensed under the MIT License. This copyright notice should be preserved.
function addScript(url) {
document.write("<script type='text/javascript' src='" + url + "'><\/script>");
if (typeof (JSON) === "undefined") {
mqudsi / pthread_unsafe_unlock.c
Created September 27, 2022 20:39
Demonstration of unsafety of pthread_mutex_unlock
View pthread_unsafe_unlock.c
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static pthread_mutex_t mutex;
static void* thread1_entry(void * _arg) {
int *result = malloc(sizeof(int));
mqudsi /
Created December 17, 2021 22:01
A script to bisect vim portably
# set -x
# vim is really hard to run portably; I can't seem to get `set rtp=./runtime/`
# to actually work, so we build it with a prefix pointing to $PWD and then
# symlink `share/vim/` so it points to the files we need.
if mkdir share 2>&1 >/dev/null; then
ln -s $(pwd) share/vim
mqudsi /
Created October 20, 2021 18:18
Update a folder/file from the latest matching GitHub release
#!/usr/bin/env fish
# Declare some constants to be used later
set -g filename
set -g base_url
set -g release_file current_release.txt
if ! type -q wsl.exe
# Running on actual Linux
set filename omnisharp-linux-x64.tar.gz
mqudsi / UWP Modal Dialog.cs
Created August 20, 2021 16:14
Create a blocking/modal dialog with a new window on UWP. No dependencies.
View UWP Modal Dialog.cs
private async void Settings_Click(object sender, PointerRoutedEventArgs e)
var mainViewId = ApplicationView.GetForCurrentView().Id;
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
var popupClosed = new TaskCompletionSource<bool>();
Window settingsWindow = null;
var mainWindow = Window.Current;
mqudsi / WebView2Extensions.cs
Last active January 13, 2021 05:44
WebView2 Extension Methods
View WebView2Extensions.cs
// Copyright (c) Mahmoud Al-Qudsi, NeoSmart Technoogies. All rights reserved.
// Licensed under the MIT License.
namespace NeoSmart.WebExtensions
static class WebView2Extensions
private static readonly ILogger Logger = Serilog.Log.Logger;
public static void Navigate(this WebView2 webview, Uri url)
mqudsi / JsonRequest.cs
Created April 29, 2020 19:23
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 / StreamSequence.cs
Created April 29, 2020 19:17
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 /
Created December 23, 2018 00:30
A rust snippet to convert an anonymous function (or closure?) into an FFI-compatible callback
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) };