Skip to content

Instantly share code, notes, and snippets.

View byrnedo's full-sized avatar

Donal Byrne byrnedo

View GitHub Profile
@alexdiliberto
alexdiliberto / ember-cli-build.js
Last active November 7, 2017 08:34
Strip all console statements from a production ember application
/* eslint-env node */
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
let env = EmberApp.env();
let plugins = [];
if (env === 'production') {
@kesk
kesk / colourtail.sh
Last active February 10, 2016 12:53
# Colourised tail output for
function colourtail() {
tail $* | sed \
-e 's/==>.*<==/\x1b[95m&\x1b[0m/' \
-e 's/.*\bDEBUG.*/\x1b[96m&\x1b[0m/' \
-e 's/.*\bWARN.*/\x1b[93m&\x1b[0m/' \
-e 's/.*\bERR.*/\x1b[91m&\x1b[0m/' \
-e 's/^[a-z.]\+\.[A-Za-z]*\(Exception\|Error\):.*/\x1b[93;41m&\x1b[0m/' \
-e 's/^[ \t]*\bat .*/\x1b[37m&\x1b[0m/i'
}
@magickatt
magickatt / gist:6130199
Last active September 19, 2022 23:42
Output CSV to browser
<?php
// Headings and rows
$headings = array('ID', 'Name', 'Colour');
$array = array(
array(1, 'Apple', 'Green'),
array(2, 'Banana', 'Yellow'),
array(3, 'Orange', 'Orange'),
);
@nevang
nevang / JsBSONHandlers.scala
Last active March 8, 2016 22:29
Reader and writer in order to work with spray-json and reactivemongo. Based on https://github.com/zenexity/Play-ReactiveMongo.
import spray.json._
import reactivemongo.bson._
import reactivemongo.bson.handlers.{ BSONReader, BSONWriter, RawBSONWriter }
import scala.util.{ Try, Success, Failure }
import org.apache.commons.codec.binary.Hex
import org.joda.time.format.ISODateTimeFormat
import org.joda.time.{ DateTime, DateTimeZone }
import java.nio.ByteBuffer
import org.jboss.netty.buffer.ChannelBuffers
@splaspood
splaspood / bash_iniparse.sh
Created December 13, 2011 20:34
Parsing INI Files with Bash
cfg.parser () {
fixed_file=$(cat $1 | sed 's/ = /=/g') # fix ' = ' to be '='
IFS=$'\n' && ini=( $fixed_file ) # convert to line-array
ini=( ${ini[*]//;*/} ) # remove comments
ini=( ${ini[*]/#[/\}$'\n'cfg.section.} ) # set section prefix
ini=( ${ini[*]/%]/ \(} ) # convert text2function (1)
ini=( ${ini[*]/=/=\( } ) # convert item to array
ini=( ${ini[*]/%/ \)} ) # close array parenthesis
ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2)
ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite