Skip to content

Instantly share code, notes, and snippets.

Will zflat

Block or report user

Report or block zflat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
zflat / csv2vcard.rb
Created Oct 25, 2017
Simple script to split a CSV into vcard files
View csv2vcard.rb
#! /usr/bin/ruby
# coding: utf-8
# Split a CSV into vcard files
infile =, ARGV), "r")
while (line = infile.gets)
vals = line.split( ",")
continue if vals.empty?
fname = File.join(File.expand_path(File.dirname(__FILE__)), "vcard","#{vals[0]}.vcf".gsub( " ", "").strip), "w:UTF-8") do |f|
zflat / bit_sum.c
Last active Oct 15, 2018
sum the bits of an integer
View bit_sum.c
#include <stdio.h>
#include <stdlib.h>
unsigned long bit_sum(unsigned long n) {
return n ? (1 + bit_sum(n & (n - 1))) : 0;
void main(int argc, char ** argv) {
char * p;
long n;
zflat / printer_pjl.rb
Created Jul 11, 2017
Printer Job Language sending commands
View printer_pjl.rb
#! /usr/bin/ruby
require 'socket'
# use printer IP address here
sock ='', '9100')
# Start
sock.write "\u{001B}%-12345X@PJL\n"
# commands
zflat / octocat.svg
Created Jun 9, 2017 — forked from johan/octocat.svg
Github octocat avatar, SVG format
View octocat.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
zflat /
Last active Mar 16, 2017
Count lines in csv files
# Count the number of rows in csv files not counting the header row
# (assuming the header has a column named "header_col")
cat *.csv | grep -w "header_col" -c -v
# recursive
find `pwd` | xargs cat | grep -w "user_id" -c -v
# also listing files in order
ls -lR --group-directories-first
zflat / save-git-stashes.bash
Created Oct 21, 2016
Save all stashes as patch files
View save-git-stashes.bash
git stash list | awk '{b= gensub(" ", "_", "g", $0); system("git stash show -p " substr($1, 0, length($1)-1) " > ~/Desktop/" b ".diff")}'
zflat /
Last active Aug 29, 2015
Getting freehub to run

Force downgrade to rubygems 1.8

  rvm rubygems latest-1.8 --force

Setup the MySQL database and user

Start the server:

  ./script/app start
zflat /
Created Sep 5, 2014
VM of old debian image
zflat /
Last active Aug 29, 2015
MySQL database backup
# See
# Backup
mysqldump -u user -pMyPassword databasename > databasename.sql
# Restore
# Drop the existing table
# Create the table
zflat / init.el
Created May 18, 2014
emacs initialization file ( ~/.emacs.d/init.el)
View init.el
;; Configure emacs
;; Set font
(set-face-attribute 'default nil :height 120)
;; disable splash screen
(load "~/elisp/autoloads" 'install)
;; custom-set-variables was added by Custom.
You can’t perform that action at this time.