Skip to content

Instantly share code, notes, and snippets.

View bergwerf's full-sized avatar

Herman Bergwerf bergwerf

View GitHub Profile
/* PHP similar_text JavaScript implementation
see: http://phpjs.org/functions/similar_text/ */
function similar_text(first, second, percent)
{
// discuss at: http://phpjs.org/functions/similar_text/
// original by: Rafał Kukawski (http://blog.kukawski.pl)
// bugfixed by: Chris McMacken
// bugfixed by: Jarkko Rantavuori original by findings in stackoverflow (http://stackoverflow.com/questions/14136349/how-does-similar-text-work)
// improved by: Markus Padourek (taken from http://www.kevinhq.com/2012/06/php-similartext-function-in-javascript_16.html)
// example 1: similar_text('Hello World!', 'Hello phpjs!');
@bergwerf
bergwerf / style.rst
Last active November 9, 2016 09:26
My personal coding style preferences!

A style guide

This used to be my preferred style some years ago. Nowadays I'm less opiniated and I try to follow standard conventions and use standard formatters, such as the excellent dartfmt for Dart.

Miscellaneous

This section contains the general code formatting style conventions. The exact

@bergwerf
bergwerf / generate_strings.dart
Created March 6, 2016 18:31
String set generator
// Copyright (c) 2016, Herman Bergwerf. All rights reserved.
/// String set generator
///
/// Generates a set of strings from an input string that contains optional
/// fragments. An optional fragment is written using square brackets. If a
/// fragment itself has multiple alternatives, you can use a vertical bar
/// character to separate them. If the final strings should all include at least
/// one of the alternatives provided by the square brackets, you should add a
/// exclamation mark before the opening bracket. Square brackets, vertical bars
@bergwerf
bergwerf / math_expressions.dart
Created November 9, 2016 09:30
Dart math_expressions to eqlib conversion code.
// Copyright (c) 2016, Herman Bergwerf. All rights reserved.
// Use of this source code is governed by an AGPL-3.0-style license
// that can be found in the LICENSE file.
import 'package:eqlib/eqlib.dart';
import 'package:eqlib/inline.dart';
import 'package:math_expressions/math_expressions.dart' as mexpr;
/// Maps mexpr types to default function strings.
final _mexprMap = new Map<Type, String>.from({
@bergwerf
bergwerf / pug.dart
Created February 8, 2017 11:34
PugJS for Dart by running a node process and communicating over stdio
// Copyright (c) 2017, Herman Bergwerf. All rights reserved.
// Use of this source code is governed by a MIT-style license.
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import 'package:logging/logging.dart';
final log = new Logger('pug');
@bergwerf
bergwerf / privacy_policy.md
Last active February 13, 2017 13:03
Logic Board (Android) privacy policy

Logic Board privacy policy

This document describes how Logic Board handles your privacy. To summarize: Logic Board itself functions entirely client side and does not share any data with external servers. All data is stored and processed on your phone.

Access to hardware in Android

Logic Board may request access to the following hardware based on what features you use:

@bergwerf
bergwerf / template.dart
Created February 26, 2017 17:34
HTML template in Dart?
renderPage() =>
html(
head([
title('Create category'),
defaultHead(),
style(include('../../styles/treeselect.css')),
]),
body([
breadcrumb(),
container([
@bergwerf
bergwerf / main.dart
Created February 27, 2017 16:57
HTML template framework prototype
import 'dart:mirrors';
class ElementBuilder {
final String tag;
ElementBuilder(this.tag);
dynamic noSuchMethod(Invocation invocation) {
final pArgs = invocation.positionalArguments;
@bergwerf
bergwerf / expr.pl
Created March 23, 2017 18:44
Perl EqDB expression array data building helpers
use strict;
{
# Jenkins one-at-a-time hash
package EqLib::Hash;
sub jenkins_oaat {
my $hash = 0;
foreach (@_) {
$hash += $_;
@bergwerf
bergwerf / dart.lang
Last active March 28, 2017 15:24
GtkSourceView syntax file for Dart
<?xml version="1.0" encoding="UTF-8"?>
<language id="dart" _name="Dart" version="2.0" _section="Script">
<metadata>
<property name="mimetypes"></property>
<property name="globs">*.dart</property>
<property name="line-comment-start">//</property>
<property name="block-comment-start">/*</property>
<property name="block-comment-end">*/</property>
</metadata>