Skip to content

Instantly share code, notes, and snippets.

@Costava
Costava / high-dpi-canvas.html
Last active January 14, 2017 15:47 — forked from joubertnel/gist:870190
HTML5 Canvas - Rendering of Text on High-DPI Screens
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>
@Costava
Costava / matlab_graphing.m
Last active October 1, 2016 19:03
MATLAB graphing basics. Plot points and graph equations on the same graph. Set specific ranges of axes. Specify the number of decimal places to show for ticks on axes. Specify font and font size.
% Graph data points along with prediction and fit equations
clf;% Clear the graph
% Define data points
x = [0.25, 0.50, 0.75, 1.00, 1.25];
y = [1.23, 0.92, 0.76, 0.68, 0.61];
% Mark data points on graph as blue squares
% Last two arguments are optional (Default is blue circles)
@Costava
Costava / IterationOverFiles.bat
Last active November 8, 2015 17:34
Iterate over files with batch. Do work on every tenth PNG image, like deleting every tenth frame of a video if you have all of the frames as images.
:: Iterate over all .png images in current directory
:: and do work on every 10th image.
:: Assumes files are named [anything][x].png
:: where x starts at 1 (doesn't matter whether 001, 01, 1) and increments by 1.
:: Every 10th image has [x] that ends in 0.
:: The easiest way to run this script is to put it in the same directory
:: as all your images, then change to that directory in the command prompt
:: and enter the name of the file to execute it, e.g. myscript.bat
@Costava
Costava / emacs-highlight-changes-since-save.el
Last active April 23, 2016 07:43
In Emacs, automatically highlight the changes since the last save.
; Paste into your Emacs initialization file (.el)
(add-hook 'after-save-hook 'highlight-changes-since-save)
(defun highlight-changes-since-save()
(progn
(highlight-changes-mode 0)
(highlight-changes-mode 1)))
@Costava
Costava / getPrimeNumbers.js
Created September 28, 2016 16:56
JavaScript implementation of the Sieve of Eratosthenes for finding prime numbers
/**
* Returns a list of the prime numbers in range [0, max) in order
* Implementation of the Sieve of Eratosthenes
* https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
* @param {number} max
* @returns {number[]}
*/
function getPrimeNumbers(max) {
// A list of booleans where index 2 being true corresponds to 2 being prime
var isPrime = [];
@Costava
Costava / cordova-android.md
Last active March 2, 2017 05:28
Build a Cordova project for Android and test it on a physical Android device.

Cordova with Android

Goal

Build a Cordova project for Android and test it on a physical Android device.

Platform: Windows 8.1

Problem

@Costava
Costava / pic32_blink_led.c
Last active September 30, 2020 06:17
Straightforward LED blinking program for PIC32 devices.

SDL 2.0.9

The title bar of a window is the bar that would have the minimize, maximize, and close buttons.

When you click the title bar of an SDL window to regain focus, the window may begin receiving keyboard events as expected but never mouse events (except for one mouse event at the time of the click).

How to reproduce problem:

  1. Call SDL_SetRelativeMouseMode(SDL_TRUE)
  2. Alt+tab away from the SDL window
  3. Click the title bar of the SDL window