Skip to content

Instantly share code, notes, and snippets.

View javadba's full-sized avatar

StephenBoesch javadba

View GitHub Profile
@javadba
javadba / cua-mode.vim
Created April 12, 2020 17:09
cua-mode.vim
"|
"| File : ~/.vim/plugin/cua-mode.vim
"| Source : https://github.com/fabi1cazenave/cua-mode
"| Licence : WTFPL
"|
"| This file brings Notepad-like CTRL-ZXCV shortcuts to Vim, while preserving
"| all other Vim shortcuts -- like the CUA-mode does on Emacs:
"| http://www.emacswiki.org/CuaMode
"|
"| It is based on Bram Molenaar's mswin.vim, g:cua_mode sets the behavior:
@javadba
javadba / numpy-groupby.py
Last active May 20, 2019 06:17
numpy groupby
import numpy as np
from typing import AnyStr, Callable
AT = AnyStr
def groupby(arr: np.array, transformfn: Callable[[AT], AT], selectfn: Callable[[AT], AT] = None):
xarr = list(map(transformfn,arr))
keys, indx = np.unique(xarr, return_inverse=True)
K = len(keys)
recsByKey = list()
for i in range(K):
// Derived from : http://blog.efftinge.de/2008/10/multi-line-string-literals-in-java.html
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Heredoc {
public static String S() {
StackTraceElement element = new RuntimeException().getStackTrace()[1];
@javadba
javadba / cltools.sh
Created November 26, 2016 17:16 — forked from justinbellamy/cltools.sh
Install Autoconf and Automake on OS X El Capitan
#!/bin/sh
##
# Install autoconf, automake and libtool smoothly on Mac OS X.
# Newer versions of these libraries are available and may work better on OS X
#
# This script is originally from http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html
#
export build=~/devtools # or wherever you'd like to build
@javadba
javadba / ha-core-site.xml
Created October 23, 2015 00:30
ha core-site.xml without kerberos
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@javadba
javadba / ha-dfs-site.xml
Created October 23, 2015 00:22
ha hdfs-site.xml without kerberos
configuration>
<property>
<name>dfs.datanode.data.dir</name>
<value>/mnt/hadoop/hdfs/data</value>
<final>true</final>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
@javadba
javadba / getProcessingCpuLoad.scala
Created September 17, 2015 00:29
getProcessingCpuLoad thread
val latch = new java.util.concurrent.CountDownLatch(1)
val t = new Thread() {
override def run() = {
var x = 1.0
val startt = System.currentTimeMillis
for (i <- 1 to lnLoops) {
x = (x * math.pow(i, 1.2) * i) /
(math.pow(x, 1.5) * math.sqrt(i) * math.max(math.abs(math.cos(x)), 0.1) * math.pow(i, 1.21))
}
println(s"X=$x duration=${System.currentTimeMillis-startt}")
EtreCheck version: 2.2 (132)
Report generated 7/21/15, 7:36 PM
Download EtreCheck from http://etresoft.com/etrecheck
Click the [Click for support] links for help with non-Apple products.
Click the [Click for details] links for more information about that line.
Hardware Information: ℹ️
MacBook Pro (Retina, Mid 2012) (Verified)
MacBook Pro - model: MacBookPro10,1
@javadba
javadba / gist:5552140
Last active May 20, 2019 06:10
Concise string interpolation in python
def tostr(msg, inhash=locals()):
import io
outstr = io.StringIO()
print(outstr, msg % inhash)
return outstr.getvalue()
usage example:
s="Some message from %(froma)s \n on the %(day)d of %(month)s %(year)d \n Says %(message)s\n"
# Assumes you have Sun JDK installed already and JAVA_HOME set to that for root
# This is all basically a summary of various parts of https://ccp.cloudera.com/display/CDH4DOC/CDH4+Documentation
# Add Cloudera RPM-GPG-KEY and repo
rpm --import http://archive.cloudera.com/cdh4/redhat/6/x86_64/cdh/RPM-GPG-KEY-cloudera
rpm -ivh http://archive.cloudera.com/cdh4/one-click-install/redhat/6/x86_64/cloudera-cdh-4-0.x86_64.rpm
# Install CDH4 Base
yum install hadoop-0.20-conf-pseudo