Skip to content

Instantly share code, notes, and snippets.

View emaxerrno's full-sized avatar
💭
I may be slow to respond.

Alexander Gallego emaxerrno

💭
I may be slow to respond.
View GitHub Profile
@emaxerrno
emaxerrno / gist:6298625
Created August 21, 2013 18:52
deletedtt.java
def tupleListForPageView(pvld: PageViewLogData): TupleList = {
import com.yieldmo.hadoop.scalding.DiscreteVariableStates._
val isCell = (Option(pvld.getCellular()) getOrElse false).asInstanceOf[Boolean]
val location = Option(pvld.getLocation()) getOrElse { new Location }
var metro = "other"
var country = "other"
Option(location).foreach { loc: Location =>
if (loc.getMetroCode != 0) metro = "" + loc.getMetroCode
Option(loc.getCountryCode) foreach { x: String => country = getCountry(x) }
}
def tupleListForPageView(pvld: PageViewLogData): TupleList = {
import com.yieldmo.hadoop.scalding.DiscreteVariableStates._
val network = if ((Option(pvld.getCellular()) getOrElse false).asInstanceOf[Boolean]) "cell" else "wifi"
val location = Option(pvld.getLocation()) getOrElse { new Location }
val (metro: String, country: String) = {
Option(location) map { loc: Location =>
val x1 = if (loc.getMetroCode != 0) "" + loc.getMetroCode else "other"
val x2 = Option(loc.getCountryCode) map { x: String => getCountry(x) }
(x1,x2)
} getOrElse {("other", "other")}
@emaxerrno
emaxerrno / launchtomcat
Created August 26, 2013 17:52
catalina stuff
#!/bin/bash
DESTINATION=/usr/local/Cellar/tomcat/7.0.41/libexec/webapps
SOURCE=/Users/agallego/workspace/tld/portal/target/ROOT.war
rm -rf $DESTINATION/ROOT*
cp $SOURCE $DESTINATION
/usr/local/Cellar/tomcat/7.0.41/bin/catalina run
@emaxerrno
emaxerrno / launchtomcat
Created August 26, 2013 19:55
Deploying wars
#!/bin/bash
DESTINATION=/usr/local/Cellar/tomcat/7.0.42/libexec/webapps
SOURCE=/Users/agallego/workspace/tld/portal/target/ROOT.war
export JAVA_OPTS=" -Xrunjdwp:transport=dt_socket,address=localhost:9999,server=y,suspend=n -Dshard_id=1027 $JAVA_OPTS"
case "$1" in
-i)
echo "Deploying intranet"
@emaxerrno
emaxerrno / init.el
Created August 27, 2013 17:56
Init.el
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
;; (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
@emaxerrno
emaxerrno / main.go
Created August 29, 2013 13:54
Etag.go
package main
import (
"bitbucket.org/agallego/log"
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
)
$ git for-each-ref refs/remotes/tags | cut -d / -f 4- | grep -v @ | while read tagname; do git tag "$tagname" "tags/$tagname"; git branch -r -d "tags/$tagname"; done
@emaxerrno
emaxerrno / .bashrc
Created September 16, 2013 03:39
worklog
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
@emaxerrno
emaxerrno / worklog.sh
Last active December 23, 2015 04:39
worklog
function workLog {
dirs=$(ls $HOME/workspace)
for d in $dirs
do
d=$HOME/workspace/$d
if [[ -d $d/.git ]]; then
cd $d
gituser=`git config user.name`
echo "Project: $(pwd):$gituser"
# git --no-pager log --author='$gituser' --oneline --decorate
@emaxerrno
emaxerrno / FactorProduct.m
Created September 20, 2013 03:10
coursera pmg: FactorProduct.m
% FactorProduct Computes the product of two factors.
% C = FactorProduct(A,B) computes the product between two factors, A and B,
% where each factor is defined over a set of variables with given dimension.
% The factor data structure has the following fields:
% .var Vector of variables in the factor, e.g. [1 2 3]
% .card Vector of cardinalities corresponding to .var, e.g. [2 2 2]
% .val Value table of size prod(.card)
%
% See also FactorMarginalization.m, IndexToAssignment.m, and
% AssignmentToIndex.m