Skip to content

Instantly share code, notes, and snippets.

@zflat
zflat / printer_pjl.rb
Created July 11, 2017 20:27
Printer Job Language sending commands
#! /usr/bin/ruby
require 'socket'
# use printer IP address here
sock = TCPSocket.new('000.000.000.000', '9100')
# Start
sock.write "\u{001B}%-12345X@PJL\n"
# commands
@zflat
zflat / octocat.svg
Created June 9, 2017 21:09 — forked from johan/octocat.svg
Github octocat avatar, SVG format
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zflat
zflat / count_csv_rows.sh
Last active March 16, 2017 21:51
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
zflat / save-git-stashes.bash
Created October 21, 2016 16:11
Save all stashes as patch files
git stash list | awk '{b= gensub(" ", "_", "g", $0); system("git stash show -p " substr($1, 0, length($1)-1) " > ~/Desktop/" b ".diff")}'
@zflat
zflat / notes.md
Last active August 29, 2015 14:06
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
zflat / notes.md
Created September 5, 2014 07:19
VM of old debian image
@zflat
zflat / export_dump.sh
Last active August 29, 2015 14:02
MySQL database backup
# See http://webcheatsheet.com/SQL/mysql_backup_restore.php
# Backup
mysqldump -u user -pMyPassword databasename > databasename.sql
# Restore
# http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/
# Drop the existing table
# Create the table
@zflat
zflat / init.el
Created May 18, 2014 23:14
emacs initialization file ( ~/.emacs.d/init.el)
;; Configure emacs
;; Set font
;; http://askubuntu.com/questions/23603/how-to-change-font-size-in-emacs
(set-face-attribute 'default nil :height 120)
;; disable splash screen
(load "~/elisp/autoloads" 'install)
(custom-set-variables
;; custom-set-variables was added by Custom.
@zflat
zflat / dump_sldlibs.bat
Last active August 29, 2015 14:00
Import SolidWorks type library for standalone application
:: Fix based on http://qt-project.org/forums/viewthread/13963
C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\bin\dumpcpp.exe "C:\Program Files\SolidWorks Corp\SolidWorks\sldworks.tlb" -n SWK -o sldworks
C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\bin\dumpcpp.exe "C:\Program Files\SolidWorks Corp\SolidWorks\swconst.tlb" -n SWK -o sldconst
# http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/
@@echo off
CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /x64
set QTDIR=C:\Qt\5.2.1
set PATH=%QTDIR%\bin;C:\Qt\qt-creator-opensource-src-3.0.1\bin;C:\Qt\jom;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
set QMAKESPEC=win32-msvc2010
cd C:\Qt\5.2.1
cmd