Skip to content

Instantly share code, notes, and snippets.

@sjmulder
sjmulder / VroomJsTimeout.cs
Created April 18, 2017 09:03
Sample of how referencing setTimeout in a VroomJs context causes an error
/* Sample of how referencing setTimeout in a VroomJs context causes an
error.
Tested with NuGet package VroomJs 1.2.3 */
using VroomJs;
class Program
{
static void Main(string[] args)
@sjmulder
sjmulder / pascal.c
Created November 16, 2016 09:32
Pascal’s triangle using vector additions
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#define N 64
#define VECSZ ((N+1)/2)
int main(int argc, const char* argv[])
{
uint64_t vec[VECSZ] = {1};
@sjmulder
sjmulder / ParallelPrimes.cs
Last active November 5, 2015 12:30
Parallel primes in various languages
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Linq.Enumerable;
class Program
{
// unsorted!
@sjmulder
sjmulder / keybase.md
Last active May 13, 2019 07:36
Keybase proof

Keybase proof

I hereby claim:

  • I am sjmulder on github.
  • I am sjmulder (https://keybase.io/sjmulder) on keybase.
  • I have a public key whose fingerprint is 7208 4E6F EBC8 56A3 015F CC8F 7D49 EBB8 3868 FA52

To claim this, I am signing this object:

@sjmulder
sjmulder / objcppcli.mm
Last active April 29, 2022 17:32
Sample code for a hypothetical Objective-C++/CLI language.
#include <iostream>
#include <msclr/marshal.h>
#include <msclr/marshal_cppstd.h>
#import <Foundation/Foundation.h>
// Sample code for a hypothetical Objective-C++/CLI language
ref class ClrClass;
@class ObjCClass;
@sjmulder
sjmulder / shrubbery.py
Last active December 16, 2015 08:49
We want... a shrubbery!
def _0():
__=1
while _[9][_[5]]==0 and __>0 and _[3]<len(_[1]):
_[3]+=1
if _[1][_[3]]==_[1][0]:__+=1
if _[1][_[3]]==_[1][1]:__-=1
def _1():
__=1
while _[9][_[5]]!=0 and __>0 and _[3]>=0:
_[3]-=1
@sjmulder
sjmulder / lostfound.rb
Created November 7, 2012 14:14
Quickly search through a reflog
#!/usr/bin/ruby
# Some bash-fu should be able to do the same but I'm only a white belt
if ARGV.length < 1
$stderr.puts 'usage: lostfind <keyword> [<keyword> ...]'
else
reflog = `git reflog`
reflog.each_line do |line|
hash, _, message = line.split(' ', 3)
@sjmulder
sjmulder / format_css.py
Created October 26, 2012 18:53
Super basic Sublime Text 2 CSS formatter
from sublime import Region
from sublime_plugin import TextCommand
class LineIndenter:
def __init__(self, view, lines):
first = view.substr(lines[0])
self.lines = lines
self.base_indent = first[:len(first) - len(first.lstrip())]
self.depth = 0
@sjmulder
sjmulder / gist:2768809
Created May 22, 2012 12:40
My 12 line “publishing platform”
Dir.glob 'articles/*.md' do |path|
content = File.read(path)
slug = File.basename(path, ".md")
matches = /^# (.*)$/.match(content)
title = matches && matches[1] || slug
get "/articles/#{slug}" do
erb :article, :locals => {
:title => title,
:content => markdown(content)
}
@sjmulder
sjmulder / graceful-placeholders.js
Created February 22, 2011 11:37
Graceful degradation for browser not supporting the placeholder attribute
var setupPlaceholders = function () {
if (typeof document.createElement('input').placeholder !== 'undefined') {
return;
}
var clearPlaceholder = function () {
var input = jQuery(this);
if (input.hasClass('placeholder')) {
input.val('');
input.removeClass('placeholder');