Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@kevinwkc
kevinwkc / gremlin-cheat-sheet.md
Created June 17, 2019 01:14 — forked from jeremysears/gremlin-cheat-sheet.md
Gremlin Cheat Sheet in Groovy

Gremlin Cheat Sheet in Groovy

Gremin traversal examples taken from the excellent DS330: DataStax Enterprise Graph course.

Creating Vertices and Vertex Properties

Add a Vertex

Vertex u = graph.addVertex("user");
       u.property("userId","u2016");
 u.property("age",36);
@kevinwkc
kevinwkc / count.sh
Created October 15, 2018 20:16 — forked from mehikmat/count.sh
Hadoop commnad to run bash script in hadoop cluster-This script counts the number of lines in input file and writes count to output file
#!/bin/sh
# 's_\^\*~_\n_g' is the line delimiter in input file replace with yours
sed 's_\^\*~_\n_g'| wc -l

This cheat sheet originated from the forum, credits to Laurent Poulain. We copied it and changed or added a few things.

Evaluation Rules

  • Call by value: evaluates the function arguments before calling the function
  • Call by name: evaluates the function first, and then evaluates the arguments if need be
    def example = 2      // evaluated when called
    val example = 2      // evaluated immediately

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o

@kevinwkc
kevinwkc / aes_geom_explore.R
Created March 22, 2018 13:09 — forked from trinker/aes_geom_explore.R
ggplot2: aesthetics and geoms exploration
In this post I have a few goals:
1. Become (re-)familiar with available geoms
2. Become (re-)familiar with aesthetic mappings in geoms (stroke who knew?)
3. Answer these questions:
<ul>
<li>How often do various geoms appear and how often do they have required aesthetics?</li>
<li>How often do various aesthetics appear and how often are they required?</li>
<li>What geoms are most similar based on mappings?</li>
</ul>
@kevinwkc
kevinwkc / bash-cheatsheet.sh
Created October 16, 2017 17:40 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@kevinwkc
kevinwkc / gitBash_windows.md
Created June 23, 2017 23:33 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows is bundled with "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on). If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corrisponding directories. Sometimes the windows binary have funny prefixes, so you should rename the exe file to the

@kevinwkc
kevinwkc / pasteUsingSepAndCollapseInR.R
Created June 2, 2017 01:56 — forked from briandk/pasteUsingSepAndCollapseInR.R
Understanding `sep` and `collapse` in R using `paste()
# The difference between the `sep` and `collapse` arguments
# in paste can be thought of like this:
#
# paste can accept multiple *vectors* as input, and will
# concatenate the ith entries of each vector pairwise
# (or tuplewise), if it can.
#
# When you pass paste multiple vectors, sep defines what
# separates the entries in those tuple-wise concatenations.
#
#' Calculate a dep_var for the iris dataset based on the iris dataset.
#'
#' @param by character. \code{length} to go by \code{Petal.Length} or \code{width} to go by \code{Petal.Width}.
iris_with_dep_var <- validations::ensure(pre = list(by %in% c("length", "width")),
  function(by = "length") {
    if (identical(by, "length")) {
      plyr::ddply(iris, plyr::.(Species), summarize, dep_var = ifelse(any(Petal.Length >= 4), 1, 0))
    } else {
      plyr::ddply(iris, plyr::.(Species), summarize, dep_var = ifelse(any(Petal.Width >= 4), 1, 0))