Skip to content

Instantly share code, notes, and snippets.

@mub
mub / sample.proto
Created February 21, 2017 04:33
DataMeta DOM to Protobuf export
// This Protobuf schema is generated by DataMeta exporter.
syntax = "proto3";
package org.ebay.datameta.examples.conv.protobuf;
enum BaseColor {
Red = 0;
Green = 1;
Blue = 2;
@mub
mub / AllFields.avsc
Created February 15, 2017 17:37
Avro schema export by DataMeta
{
"type": "record", "namespace":"org.ebay.datameta.examples.conv.avro.v1_0_0", "name" : "AllTypes",
"fields": [
{"name" : "id", "type": "int"} ,
{"name" : "count", "type": "long"} ,
{"name" : "isIt", "type": "boolean"} ,
{"name": "code", "type":{"name": "code", "type": "fixed", "size": 5}},
{"name" : "width", "type": ["float", "null"]} ,
{"name" : "height", "type": "double"} ,
@mub
mub / shareScreen.sh
Created May 5, 2015 06:55
screen -x sharing via dump text terminal
# Prepare the host
/bin/su - root
chmod u+s $(which screen)
chmod 755 /var/run/screen
/bin/rm -fr /var/run/screen/*
############################################
#### as User A
screen -d -m -S shared # can name the session any way
screen -ls
screen -x shared
@mub
mub / doubleTeeShowOff.sh
Created July 25, 2014 21:05
Unix/Linux shell scripting trail
#!/bin/zsh
#!/bin/bash
# This show how to dierect console output to the screen as one natural flow but split it to STDERR and STDOUT
# There are many recipes for this, but this is the only thing that works fine with both zsh and bash
# Remove the tee's -a flag to start the files anew, it means "append"
# define the output file name, you'll have 2 files in the end: $lFile.out for STDOUT and $lFile.err for STDERR
export lFile='try'
function tOut {
tee -a $lFile.out
@mub
mub / count-tweet-sentiment.awk
Last active August 29, 2015 13:57
For Mitch: perl vs awk benchmark
#!/usr/bin/awk -f
BEGIN {
while (( getline w < "positive-words.txt") > 0) {
if (! (substr(w,0,1) == ";") && (w != "")) good[w] = 1;
}
while (( getline w < "negative-words.txt") > 0) {
if (! (substr(w,0,1) == ";") && (w != "")) bad[w] = 1;
}
}
@mub
mub / .tmux.conf
Last active December 27, 2015 07:19
tmux goodies
# Whichever shell are now running
set-option -g default-shell $SHELL
set -g default-terminal "screen-256color"
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
# C-b is not acceptable -- Vim uses it (page back)
unbind C-b
set-option -g prefix C-a
bind-key C-a last-window
@mub
mub / BaileyBorweinPlouffePi.java
Last active December 14, 2015 23:39
PI Day special
import java.math.BigDecimal;
import java.math.RoundingMode;
import static java.math.BigDecimal.ONE;
import static java.math.BigDecimal.ZERO;
public class BaileyBorweinPlouffePi {
public static void mayn(String[] argv) {
double pi = 0;
final int iter = Integer.parseInt(argv[0]);
@mub
mub / deployFiles.cmd
Created February 9, 2013 05:57
Maven trail
mvn deploy:deploy-file -DgroupId=org.acme ^
-DartifactId=acme-foo-driver ^
-Dversion=0.1 ^
-Dpackaging=jar ^
-Dfile=acme-foo.jar ^
-DrepositoryId=acme.foo.releases ^
-Durl=http://mavensvr.acme.com/repositories/acme.foo.releases
:: Examples of adding either javadocs or sources to existing, note the -Dclassifier switch
:: User cases: to disable generating POM, add
:: -DgeneratePom=false -DpomFile=...
@mub
mub / parseHadoopFsLs.rb
Created February 5, 2013 21:54
Hadoop trail
# the RegEx to parse the result of hadoop fs -ls
@hdfs_ls_regex= %r{ \A
([rwxd\-]+) (?# permissions) \s+
([\-\d]+) (?# replicas) \s+
(\w+) (?# user) \s+
(\w+) (?# group) \s+
(\d+) (?# size) \s+
([\d\-]+) (?# date) \s+
([\d:]+) (?# time) \s+
@mub
mub / FireFoxVsChrome.ps1
Last active December 9, 2015 19:18
Windows Scripting trail
# Comparing Firefox, Google Chrome and Internet Explorer memory footprints
# also check: PeakWorkingSet, PrivateWorkingSet, PagedMemorySize etc
# ps is an alias for Get-Process, WS is short for "WorkingSet", -exp for "-expand"
function sumProc($partialName) { ps "$partialName*" | Measure-Object -prop WS -sum | select -exp Sum }
sumProc firef
sumproc chrome
sumproc iexp