Skip to content

Instantly share code, notes, and snippets.

@mlehman
mlehman / MultipleOutputsExample.scala
Last active April 11, 2022 06:54
Hadoop MultipleOutputs on Spark Example
/* Example using MultipleOutputs to write a Spark RDD to multiples files.
Based on saveAsNewAPIHadoopFile implemented in org.apache.spark.rdd.PairRDDFunctions, org.apache.hadoop.mapreduce.SparkHadoopMapReduceUtil.
val values = sc.parallelize(List(
("fruit/items", "apple"),
("vegetable/items", "broccoli"),
("fruit/items", "pear"),
("fruit/items", "peach"),
("vegetable/items", "celery"),
("vegetable/items", "spinach")
@mlehman
mlehman / hgrep.sh
Created June 22, 2016 18:00
history grep
# utility function for your profile to search history
hgrep(){
history | grep $1 | sort -k 2 | uniq -c -f 1 | sort
}
@mlehman
mlehman / ejson.sh
Last active December 14, 2015 18:22
MongoDB to Extended JSON with SED
sed -e 's/NumberLong("*\(-*[[:digit:]]*\)"*)/{ "$numberLong" : "\1" }/' -e 's/ObjectId("*\([[:alnum:]]*\)"*)/{ "$oid" : "\1
" }/'
;; Embedded Solr Example
(def server (create-solr-server
{:type :embedded :core "mycore" :dir "/home-path"}))
;; Http Solr Example
(def server (create-solr-server
{:type :http :host "localhost"}))
;; Adding Documents
(add server {:title "Don Quixote"
(def my-credentials
(struct credentials "my-token" "my-client-name"))
(get-users my-credentials)
(get-projects my-credentials)
(get-tags my-credentials)
(get-entries my-credentials)
(get-entries my-credentials
{:to "iso-date-string" :from "iso-date-string"})
TocClient tc = new TocClient();
tc.SignOn("myscreenname","password");
tc.Send("mybuddy","Hello!");
tc.SignOff();
TocClient tc = new TocClient();
tc.Message += new MessageEventHandler(OnMessage);
tc.SignOn("myscreenname","password");
tc.StartListening();
...
protected void OnMessage(object sender, MessageEventArgs e){
WriteLine("{0}: {1}",e.From, e.Message);
}
@mlehman
mlehman / Fluent.LogicTemplates.aspx
Created April 22, 2010 22:59
Fluent.LogicTemplates Example
<%@ Register TagPrefix="fluent" Namespace="Fluent.LogicTemplates" Assembly="Fluent.LogicTemplates" %>
<html>
<head>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e) {
if(!IsPostBack){
BindDataList();
}
}
@mlehman
mlehman / Fluent.DataGridAdapter.aspx
Created April 22, 2010 22:53
Fluent.DataGridAdapter Example
<%@ Register TagPrefix="fluent" Namespace="Fluent"
Assembly="Fluent.DataGridAdapter" %>
<html>
<head>
<script language="C#" runat="server">
protected void DataGridAdapter1_DataGridBinding(
DataGridAdapter sender, DataGridBindingEventArgs e) {
SqlDataAccessCommand command;
@mlehman
mlehman / Fluent.ListBoxValidator.aspx
Created April 22, 2010 22:26
Fluent.ListBoxValidator Example
<%@ Register TagPrefix="fluent" Namespace="Fluent" Assembly="Fluent.ListBoxValidator" %>
...
<asp:ListBox ID="ListBoxEmployees" SelectionMode="Multiple" Runat="server"/>
<fluent:ListBoxValidator
ID="ListBoxValidator1"
Runat="server"
ControlToValidate="ListBoxEmployees"
ErrorMessage="Please select an employee"