Skip to content

Instantly share code, notes, and snippets.

View redblobgames's full-sized avatar
🥰

Amit Patel redblobgames

🥰
View GitHub Profile
@redblobgames
redblobgames / trello-to-text.js
Created October 6, 2020 16:40
Output trello json to a hierarchical text file (org mode but could easily be markdown instead)
#!/usr/bin/env node
/*
* I want to convert trello to a hierarchical text file (org mode)
*
* Trello can export to json. Save that json to a file. Then run this program.
*/
/*
* Notes about format:
*
@redblobgames
redblobgames / fdg-2019.md
Last active September 2, 2019 20:45
FDG 2019 - abstracts of the papers

SESSION: Applied games and gameful design

Knowledge assessment: game for assessment of symptoms of child physical abuse Richard Zhao, Christopher R. Shelton, Melanie D. Hetzel-Riggin, Jordan LaRiccia, Gregory Louchart, Adam Meanor, Heather J. Risser Article No.: 1 doi>10.1145/3337722.3337747

Using serious games as a form of training and education has been a growing trend. While there has been research into the adaptation of games for training, assessment of user knowledge as a whole for the purpose of creating tailored training content has not been closely examined. In this paper, we propose a general framework for creating an assessment game and show how Knowledge Assessment can be used to guide the focus of subsequent training modules. Using our framework, we address the frustration and anxiety expressed by medical and nursi

@redblobgames
redblobgames / x-section.xslt
Created July 27, 2019 14:23
Example of how I use xsltproc to expand section headings
<!--
I write my site with xhtml extended with my x: tags, then process it into
regular html using xsltproc. Here's an example of how I use xslt for sections.
1. Expand x: tags to a standard html tag:
<x:section> … </x:section> becomes <section> … </section>
2. Pass attributes down to the html tag:
<x:section class="example"> … </x:section>
becomes <section class="example"> … </section>
@redblobgames
redblobgames / dark-borders.el
Last active October 15, 2019 11:33
Emacs: dark fringe, line numbers
(set-face-attributes 'header-line nil :inherit 'sample :foreground "gray70" :background "gray20")
(set-face-attributes 'fringe nil :foreground "gray70" :background "gray20")
(cl-loop for buffer in '(" *Echo Area 0*" " *Echo Area 1*") do
(with-current-buffer buffer
(face-remap-add-relative 'default '(:family "Muli" :background "gray20" :foreground "white"))))
(set-face-attributes 'line-number nil :family "M+ 1m" :height 0.6 :foreground "#ccc" :background "gray20")
(set-face-attributes 'line-number-current-line nil :inherit 'line-number :foreground "white" :background "blue")
(when (fboundp 'global-display-line-numbers-mode)
(setq-default display-line-numbers-width 4)
@redblobgames
redblobgames / my-modeline.el
Last active April 2, 2021 14:56
amitp's modeline summer 2019
;; You'll need to have the s and powerline packages installed for this modeline to work
(require 's)
(require 'powerline)
(defvar my/mode-line-border 8)
(defvar my/modeline-height 22)
(set-face-attribute 'mode-line nil :family "M+ 1m" :height 120
:background "gray20" :foreground "white"
:weight 'normal
@redblobgames
redblobgames / make-instagram-photos.sh
Created June 2, 2019 03:02
Turn a panoramic photo into several square photos for Instagram, so that when you scroll they look like one seamless photo
#!/bin/bash
# As of 2017 Feb, Instagram allows multiple photos to be posted side by side.
# @idealisms posted some panoramas split up into separate photos.
# I wrote this script to generate those square photos from a panorama.
if [ -z "$1" ]; then
echo "Usage: $0 filename.jpg"
exit
fi
@redblobgames
redblobgames / INSTALL.CFG
Last active March 20, 2019 15:43
Configuration script in SRE 0.992a (SRE.CFG) vs SRE 0.993a (INSTALL.CFG)
;SRE
;Solar Realms Elite
;0.993a
let GAME := SRE
tell $GAME " " 0.993a " setup:"
if $doorfile == "" goto Local
getcwd CWD
tell "The " $GAME " directory is `" $CWD "'."
@redblobgames
redblobgames / README.md
Last active January 2, 2019 17:27 — forked from 1wheel/README.md
blend-alpha

(redblobgames updated this block to use premultiplied alpha - http://apoorvaj.io/alpha-compositing-opengl-blending-and-premultiplied-alpha.html)

I can't figure out why points with gl_FragColor = vec4(255, 255, 255, .1); get darker and then lighter when overlaid with increasing density. (note: it should be vec4(1.0, 1.0, 1.0, 0.1) not 0-255 --redblobgames)

I'm using these blending settings:

blend: {
  enable: true,
 func: {
@redblobgames
redblobgames / remove-alpha-on-canvas.js
Created September 19, 2018 20:41
Remove alpha channel on a canvas, so it's always transparent or always opaque
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const pixels = imageData.data;
for (let i = 3, n = canvas.width * canvas.height * 4; i < n; i += 4) {
pixels[i] = pixels[i] < 127? 0 : 255
}
ctx.putImageData(imageData, 0, 0);
@redblobgames
redblobgames / test-picojson-variant-tagged.cpp
Created May 17, 2018 22:06
traverse variant+picojson using tags for variants instead of integer indices
// Copyright 2018 Red Blob Games <redblobgames@gmail.com>
// https://github.com/redblobgames/cpp-traverse
// License: Apache v2.0 <http://www.apache.org/licenses/LICENSE-2.0.html>
#include "traverse.h"
#include "traverse-picojson.h"
#include "traverse-variant.h"
#include "traverse-picojson-variant-tagged.h"
#include "variant-util.h"