Skip to content

Instantly share code, notes, and snippets.

View mnpenner's full-sized avatar
:octocat:

Mark Penner mnpenner

:octocat:
View GitHub Profile
@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
@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 )
}
@magnetik
magnetik / php-cli.php
Created June 20, 2012 12:14
Php command line parser
function parseArguments()
{
array_shift($argv);
$out = array();
foreach($argv as $arg)
{
if(substr($arg, 0, 2) == '--')
{
$eqPos = strpos($arg, '=');
if($eqPos === false)
@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 };
@jeppeburchardt
jeppeburchardt / msbuild node gyp
Created July 17, 2013 12:54
node gyp msbuild misssing registry warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64
@AlinaNova21
AlinaNova21 / apitoken.js
Created October 27, 2016 21:14
apitoken mod for screeps server
// Add a new function to player sandbox space
// Some Super Secret Secret (32 character hex string)
const secret = Buffer.from('DEADBEEF000000000000000000000000', 'hex')
const jwt = require('./lib/jwt')
module.exports = function (config) {
if (config.engine) {
config.engine.onPlayerSandbox = function (sandbox) {
sandbox.getAPIToken = function () {
let key = generateToken(sandbox.module.user)
@Nilpo
Nilpo / password_api_test.php
Created January 8, 2016 08:52
A simple PHP script for testing what cost you should use with your server for password_hash() in PHP 5.5.0+
<?php
/**
* This code will benchmark your server to determine how high of a cost you can
* afford. You want to set the highest cost that you can without slowing down
* you server too much. 8-10 is a good baseline, and more is good if your servers
* are fast enough. The code below aims for ≤ 50 milliseconds stretching time,
* which is a good baseline for systems handling interactive logins.
*/
function_exists('password_hash') or die("Please use PHP 5.5.0 or higher.");
@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 }
@danneu
danneu / base66.clj
Last active August 1, 2018 00:04
base66 encoder/decoder (encodes integer to url-friendly characters)
(def digits
(seq (str "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
".-_~")))
(def radix (count digits))
(defn encode
"Encodes Long to String."
'use strict';
import React from 'react';
export default class Clearfix extends React.Component {
render() {
const beforeStyle = {
display: 'table'
};