Skip to content

Instantly share code, notes, and snippets.

javadba / cua-mode.vim
Created April 12, 2020 17:09
"| File : ~/.vim/plugin/cua-mode.vim
"| Source :
"| 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:
"| It is based on Bram Molenaar's mswin.vim, g:cua_mode sets the behavior:
javadba /
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 :
public class Heredoc {
public static String S() {
StackTraceElement element = new RuntimeException().getStackTrace()[1];
javadba /
Created November 26, 2016 17:16 — forked from justinbellamy/
Install Autoconf and Automake on OS X El Capitan
# 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
export build=~/devtools # or wherever you'd like to build
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
Unless required by applicable law or agreed to in writing, software
javadba / ha-dfs-site.xml
Created October 23, 2015 00:22
ha hdfs-site.xml without kerberos
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
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 / 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
# Add Cloudera RPM-GPG-KEY and repo
rpm --import
rpm -ivh
# Install CDH4 Base
yum install hadoop-0.20-conf-pseudo