Skip to content

Instantly share code, notes, and snippets.

@ble
ble / gist:7b2a3788d2a17c4f5d5d35fdd024b2cf
Created February 27, 2020 17:01
A functional, but not edgecase-safe, regex for rewriting a path in git patches
Yeouch! If it's not clear to you that this is a dangerous hack, ask a friend or a coworker why rewriting git patches is probably not what you want!
\(a\/\|b\/\|^ create mode \d\+ \|^ rename \|=> \|^rename \(from \|to \)\)\@<=$PATH_IN_QUESTION/
@ble
ble / simple.scala
Last active May 23, 2018 05:59
Expression parser
package ble
import scala.language.implicitConversions
package object parsimple {
import scala.util.parsing.combinator.{ JavaTokenParsers, ImplicitConversions }
import scala.util.parsing.input.CharSequenceReader
implicit def promoteToReader(cs: CharSequence): CharSequenceReader = new CharSequenceReader(cs)
@ble
ble / SimpleCombinatorExample.scala
Last active January 2, 2016 12:59
Simple parser combinator example
import scala.util.parsing.combinator._
import scala.util.parsing.input.CharSequenceReader
object Simple {
trait Expression
case class Add(lhs: Expression, rhs: Expression) extends Expression
case class Mul(lhs: Expression, rhs: Expression) extends Expression
case class Num(v: Double) extends Expression
@mixin flexbox( $display: flex, $direction: row, $wrap: wrap, $justify: start, $items: start, $content: start ) {
// <display> - flex | inline-flex
// <direction> - row | row-reverse | column | column-reverse
// <wrap> - wrap | nowrap | wrap-reverse
// <justify> - start | end | center | space-between | space-around
// <items> - start | end | center | baseline | stretch
// <content> - start | end | center | space-between | space-around | stretch
// @include flexbox( flex, row, wrap, start, start, start );
// @include flexbox( inline-flex, column, nowrap, center, start, stretch );
func Pic(dx, dy int) [][]uint8 {
result := make([][]uint8, dy);
for y := 0; y < dy; y++ {
result[y] = make([]uint8, dx);
}
return result
}
@ble
ble / main.go
Last active December 15, 2015 04:59
Get a default value for null columns by implementing databse/sql.Scanner
package main
import (
"database/sql"
"errors"
_ "github.com/mattn/go-sqlite3"
"log"
"os"
)

Disclaimer: This post is Meteor & Backbone beef. Both Meteor and Backbone are absolute genius, and far beyond anything I could dream to create. But IMO there are better tools. Prepare yourselves *gulp*, I need to get this off my chest.

First, Backbone. Why people? It revolutionized JavaScript, did wonderful things for the world, and served its purpose well. But now we have better tools, so let’s move on. It’s like Gentoo users proselytizing Gentoo to the masses, perpetuating it as most common Distro; where all this time, Ubuntu would have saved everyone countless hours. Not

@ble
ble / about.md
Created August 15, 2011 03:53 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer