Skip to content

Instantly share code, notes, and snippets.

@chrispsn
chrispsn / k_tech_tree.md
Last active March 26, 2024 01:00
k tech tree

k tech tree

Thought experiment:

Which k primitives can be implemented as k-strings, reasonably efficiently, with a handful of 'native' built-ins?

Not verified to be in dependency order yet... may depend on the choice of 'fundamental' primitives. Need to do speed tests too.

k9 syntax (download via Shakti). Got a better way to write one? Feel free to comment, you'll be credited!

@RMDarth
RMDarth / StructureFieldBitSize.cpp
Last active February 2, 2024 02:47
Compile-time size of the field in bit field struct (with C++11 restrictions)
// I've needed a constexpr way to get a size of the bit fields in struct (i.e. number of bits).
// Also, I needed it to work in Visual Studio 2015 (SP3), which is not yet fully support C++14,
// so constexpr functions could only use a single return statement and (almost) nothing more.
// After some time I've come up with this solution. It should work with any C++11 compiler.
// It has some limitations (it only works with unsigned fields).
// P.S.: With C++17 it could be done easier by using constexpr lambda expressions in macro.
#include <iostream>
#include <array>
// Helper constexpr functions
@dictvm
dictvm / nonchoppybluetooth
Created August 18, 2016 16:38
Okayish Bluetooth configuration for OS X El Capitan to work with Bose Soundlink Mini 2
{
"Apple Bitpool Max (editable)" = 80;
"Apple Bitpool Min (editable)" = 35;
"Apple Initial Bitpool (editable)" = 35;
"Apple Initial Bitpool Min (editable)" = 53;
"Negotiated Bitpool" = 80;
"Negotiated Bitpool Max" = 80;
"Negotiated Bitpool Min" = 80;
}
@tangentstorm
tangentstorm / oK-bot.js
Created September 11, 2015 22:44
K5 bot for #learnprogramming and #jsoftware on freenode
// An IRC bot for the k5 programming language,
// using oK from : https://github.com/JohnEarnest/ok
"use strict";
var irc = require('irc');
var ok = require('./ok/ok');
const MAXLINES = 8;
var client = new irc.Client('irc.freenode.net', 'oK-bot', {
channels: ['#jsoftware', '#learnprogramming']
@twotwotwo
twotwotwo / sorts.md
Last active December 9, 2023 08:41
Sorting 5x faster with Go: how it's possible, what didn't work so well, and what I learned

github.com/twotwotwo/sorts is a Go package with parallel radix- and quicksorts. It can run up to 5x faster than stdlib sort on the right kind of large sort task, so it could be useful for analysis and indexing/database-y work in which you have to sort millions of items. (To be clear, I don't recommend most folks drop stdlib sort, which is great, and which sorts depends on.)

While the process of writing it's fresh on my mind, here are some technical details, some things that didn't make the cut, and some thoughts about the process:

Concretely, what this looks like inside:

  • Both number and string versions are in-place MSD radix sorts that look at a byte at a time and, once the range being sorted gets down to 128 items, call (essentially) the stdlib's quicksort.

  • The [parallelization code

@steipete
steipete / DevelopmentEnviromentDetector.m
Last active October 30, 2019 03:49
Detect if you're currently running a development version or an App Store/Ad Hoc version.
static BOOL PSPDFIsDevelopmentBuild(void) {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
static BOOL isDevelopment = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// There is no provisioning profile in AppStore Apps.
NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]];
if (data) {
@mnpenner
mnpenner / color.js
Last active July 9, 2016 15:01
RGB <-> HSL+HSL, for Node.js
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param {number} r The red color value
* @param {number} g The green color value
* @param {number} b The blue color value
* @return {array} The HSL representation
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby