Skip to content

Instantly share code, notes, and snippets.

View mnpenner's full-sized avatar
:octocat:

Mark Penner mnpenner

:octocat:
View GitHub Profile
@jwcarroll
jwcarroll / screeps.d.ts
Created August 17, 2015 02:48
TypeScript Definition Files for The Game Screeps
declare var Game: screeps.IGame;
declare module screeps {
export interface IGame {
cpuLimit: number;
creeps: { [screepName: string]: ICreep };
flags: { [flagName: string]: IFlag };
map: IMap;
rooms: { [roomName: string]: IRoom };
@mnylen
mnylen / _.md
Last active April 23, 2021 21:17
Debounced fetching to reduce number of requests when doing API proxying through GraphQL

Simple implementation of debounced fetching in GraphQL to allow merging of multiple rest / database requests into one. Although this example uses GraphQL, the debouncedFetch / fetchProgramPlaycount implementations could probably be used in any context to achieve the same result.

This approach was first described by @leebyron at graphql/graphql-js#19 (comment)

For example this allows turning ten requests for playcounts from this GraphQL query into just one:

{
  latestPrograms(first: 10) {
    name,

playcount

'use strict';
import React from 'react';
export default class Clearfix extends React.Component {
render() {
const beforeStyle = {
display: 'table'
};
@fxg42
fxg42 / index.js
Last active February 26, 2016 21:41
Using Bluebird Promises, MongoDB and Babel's async/await with Bluebird's coroutines
import Promise from 'bluebird'
import MongoDB from 'mongodb'
Promise.promisifyAll(MongoDB)
async function findEveryone(db) {
const people = db.collection('people')
const everyone = await people.find().toArrayAsync()
return everyone.map( x => x.name )
}
@colintoh
colintoh / table.css
Created October 27, 2014 05:42
Table CSS
table { display: table }
tr { display: table-row }
thead { display: table-header-group }
tbody { display: table-row-group }
tfoot { display: table-footer-group }
col { display: table-column }
colgroup { display: table-column-group }
td, th { display: table-cell }
caption { display: table-caption }
@sergejmueller
sergejmueller / ttf2woff2.md
Last active March 9, 2024 13:37
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
@jerone
jerone / WE-Markdown.css
Last active January 12, 2022 01:19
Github Flavored Markdown Stylesheet for Web Essentials
html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
font-family: sans-serif;
}
body {
margin: 0;
padding: 30px;
min-width: 1020px;
@XVilka
XVilka / TrueColour.md
Last active April 8, 2024 14:02
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@branneman
branneman / better-nodejs-require-paths.md
Last active April 25, 2024 13:21
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@kmcallister
kmcallister / rust-backtrace
Last active January 16, 2016 05:47
Run a Rust program and print a stack backtrace on failure (old)
#!/bin/bash
### NOTE ### You probably don't need this anymore!
# Just set RUST_BACKTRACE=1
# Usage: rust-backtrace ./my-rust-prog args...
exec gdb -batch -n -x /dev/fd/3 --args "$@" 3<<ENDGDB
set height 0
set breakpoint pending on