Skip to content

Instantly share code, notes, and snippets.

@nickav
nickav / noDangle.js
Last active May 3, 2019 04:13
Don't let your headers dangle!
/**
* Don't let your headers dangle!
*
* My super cool blog
* thing <<<< dangling!
*/
function noDangle(selector, minWords) {
selector = selector || 'h1,h2,h3,h4,h5,h6'
minWords = minWords || 1
@nickav
nickav / GithubLink.vim
Last active November 4, 2016 18:23
Get a Github link to the current cursor position
@nickav
nickav / redux-async-helpers.js
Last active October 18, 2017 14:56
Redux Async Wrappers
/**
* Redux async helpers.
*/
// Constants
const REQUEST = 'request';
const SUCCESS = 'succces';
const FAILURE = 'failure';
/** Request status can only be one of these: */
/*! track-focus v 1.0.0 | Author: Jeremy Fields [jeremy.fields@vget.com], 2015 | License: MIT */
// inspired by: http://irama.org/pkg/keyboard-focus-0.3/jquery.keyboard-focus.js
/**
* Tracks an element is focused via the mouse or keyboard. On mouse focus, adds
* the mouseClass to the element.
*
* Adapted from: https://github.com/ten1seven/track-focus/blob/master/src/javascripts/track-focus.js
*/
@nickav
nickav / lisp.js
Last active November 15, 2019 19:25
const isWhitespace = (char) =>
char === ' ' || char === '\n' || char === '\t' || char === '\r';
const isParen = (char) => char === '(' || char === ')';
const getLiteralType = (literal) => {
if (literal[0] === '"' && literal[literal.length - 1] === '"') {
return 'string';
}
#include "deps/glfw/include/GLFW/glfw3.h"
#include <stdio.h>
void shader_print_errors(GLuint id) {
GLint success;
glGetShaderiv(id, GL_COMPILE_STATUS, &success);
if (!success) {
GLchar infoLog[1024];
glGetShaderInfoLog(id, 1024, NULL, infoLog);
// Converts SQL query from named parameters :param to [param]
export const sqlParams = (
sql: string,
params: Record<string, any>
): [string, any[]] => {
const matches = sql.split(/([^:]:[A-z]+[A-z0-9])/g);
let i = 0;
const nextParams: any[] = [];
const nextSql = matches.map((str, index) => {
<a><b><c><d><style>*{background:#09042a}body *{position:fixed;padding:30;border-radius:50%;border:10px solid #09042a;margin:14 19}a{margin:104 90;box-shadow:4em 0 #e78481}c{margin:-146 -38}b,c{background:#f5bb9c}a,d{border-color:#e78481
@nickav
nickav / ReadDirectoryChangesW_craziness.cpp
Last active October 3, 2024 03:51
Example of how to poll ReadDirectoryChangesW on Windows
int main() {
char *path = "/path/to/my/directory";
print("watching %s for changes...\n", path);
HANDLE file = CreateFile(path,
FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<meta name="viewport" content="minimal-ui, width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title></title>
<meta name="description" content="">