Skip to content

Instantly share code, notes, and snippets.

View nrkn's full-sized avatar

Nik nrkn

View GitHub Profile
@nrkn
nrkn / saveload.cs
Created March 8, 2011 22:51
Save/load arbitrary .NET objects
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace LosvRLLib {
/// <summary>
/// Usage:
/// <![CDATA[
/// var mapPersistence = new Persistence<Map>();
/// var map = mapPersistence.Load( "map.dat" );
///
@nrkn
nrkn / gist:2165487
Created March 22, 2012 23:33
My eyes the googles do nothing
Console.Write(
Enumerable
.Range( 0, 7 )
.Where( bit => bit % 2 == 0 )
.Aggregate(
String.Empty,
( result, bit ) => result + ( bit / 2 < 2 ? "apples" : "oranges" )
)
);
@nrkn
nrkn / gist:2165741
Created March 23, 2012 00:19
C# get valid chars
var validChars = (
Enumerable
.Range( '0', 10 )
.Concat( Enumerable.Range( 'A', 26 ) )
.Concat( Enumerable.Range( 'a', 26 ) )
.Select( i => (char) i )
);
@nrkn
nrkn / FileSystemToTree.cs
Last active December 17, 2015 22:49
Make a path into a collapsible tree
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace FileSystemToTree
{
class Program
{
static void Main(string[] args)
@nrkn
nrkn / fittedSize.js
Last active October 8, 2019 18:29
Get best fontSize to use to fit text in bounds in PDFKit
var Pdf = require( 'pdfkit' );
var fs = require( 'fs' );
var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in suscipit purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus nec hendrerit felis. Morbi aliquam facilisis risus eu lacinia. Sed eu leo in turpis fringilla hendrerit. Ut nec accumsan nisl. Suspendisse rhoncus nisl posuere tortor tempus et dapibus elit porta. Cras leo neque, elementum a rhoncus ut, vestibulum non nibh. Phasellus pretium justo turpis. Etiam vulputate, odio vitae tincidunt ultricies, eros odio dapibus nisi, ut tincidunt lacus arcu eu elit. Aenean velit erat, vehicula eget lacinia ut, dignissim non tellus. Aliquam nec lacus mi, sed vestibulum nunc. Suspendisse potenti. Curabitur vitae sem turpis. Vestibulum sed neque eget dolor dapibus porttitor at sit amet sem. Fusce a turpis lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;';
var temp = new Pdf();
function measureH
@nrkn
nrkn / iframe-rawgit.html
Last active August 29, 2015 14:19
Foundation Media Query Preview
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation Media Query Preview</title>
<style>
* {
margin: 0;
padding: 0;
@nrkn
nrkn / h5on-lite.css
Last active August 29, 2015 14:22
H5ON lite
js-object, js-array, js-string, js-number, js-boolean, js-null {
display: inline-block;
}
js-object > *, js-array > * {
display: table-row;
}
js-object > *:before, js-array > *:before {
display: table-cell;
@nrkn
nrkn / iframe.html
Created July 14, 2015 23:57
Medium.js invoke in iframe
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>iframe</title>
<style>
#edit {
outline: 1px solid #ccc;
min-height: 1em;
}
@nrkn
nrkn / LICENSE.txt
Last active March 8, 2018 04:49 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
const template = data =>
`<p>
Use the <strong>${ data.power }</strong>, ${ data.name }!
</p>`
document.getElementById( 'target' ).innerHTML = template( {name: "Luke", power: "force"} )