Skip to content

Instantly share code, notes, and snippets.

View mqudsi's full-sized avatar

Mahmoud Al-Qudsi mqudsi

View GitHub Profile
@mqudsi
mqudsi / spawntest.c
Last active March 5, 2018 01:33
Test for correct posix_spawn behavior when pgrp = 0
#include <errno.h>
#include <signal.h>
#include <spawn.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define nullptr 0
@mqudsi
mqudsi / magic.js
Last active November 6, 2015 23:48
$(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 December 3, 2012 19:59
GCC replacement of hard-coded null %s parameter
.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
@mqudsi
mqudsi / gist:4154289
Created November 27, 2012 13:46
Redis Crashes

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 April 25, 2012 02:51
Function for correcting capitalization of user-entered names
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 November 22, 2011 17:17
Sample EasyBCD NeoGrub configuration file used to dual-boot XP/Vista, hiding the Vista drive when booting into XP.
# 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
@mqudsi
mqudsi / SHCopy.cpp
Created October 16, 2011 05:25
SHFileOperation for recursive folder copy
bool SHCopy(LPCTSTR from, LPCTSTR to)
{
Log(_T("Recursive file copy from %s to %s"), from, to);
SHFILEOPSTRUCT fileOp = {0};
fileOp.wFunc = FO_COPY;
TCHAR newFrom[MAX_PATH];
_tcscpy_s(newFrom, from);
newFrom[_tcsclen(from) + 1] = NULL;
fileOp.pFrom = newFrom;