Skip to content

Instantly share code, notes, and snippets.

View mqudsi's full-sized avatar

Mahmoud Al-Qudsi mqudsi

View GitHub Profile
mqudsi /
Created May 30, 2024 17:01
Check stack usage under rust
fn check_stack() {
let x = 17;
fn approximate_sp(var: *const i32) -> *const libc::c_void {
struct StackInfo {
size: usize,
start: * const core::ffi::c_void,
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.
// 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
#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.
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
// 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
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
Last active May 6, 2024 23:22
StreamSequence, a stream-to-ReadOnlySequenceSegment<byte> wrapper
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Buffers;
namespace MessageClient
class StreamSequence : IDisposable