Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
# -*- coding: utf-8 -*-
$KCODE = 'u'
require 'csv'
File.open('tmp.csv', 'wb') do |csv_file|
# 输出标明文本编码为 UTF-8 的 BOM
csv_file.write("\xEF\xBB\xBF")
@anvyzhang
anvyzhang / pretty-print.scala
Created September 8, 2016 03:57 — forked from carymrobbins/pretty-print.scala
Pretty print Scala case classes and other data structures.
/**
* Pretty prints a Scala value similar to its source represention.
* Particularly useful for case classes.
* @param a - The value to pretty print.
* @param indentSize - Number of spaces for each indent.
* @param maxElementWidth - Largest element size before wrapping.
* @param depth - Initial depth to pretty print indents.
* @return
*/
private def prettyPrint(a: Any, indentSize: Int = 2, maxElementWidth: Int = 30, depth: Int = 0): String = {