I hereby claim:
- I am cmcbride on github.
- I am cmcbride (https://keybase.io/cmcbride) on keybase.
- I have a public key ASA9sGOXeTsPKKs8InpZXzPbfGr3v0ehS9zIdPDK6pK1Rwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import org.apache.spark.mllib.linalg.{Vector, Vectors, Matrices} | |
import org.apache.spark.mllib.linalg.distributed.{IndexedRow, IndexedRowMatrix} | |
// Ensure a properly ordered local vector from a distributed RDD | |
// (Int,Double) corresponds to (index, value) where index is the proper order | |
def array_from_rdd( rdd: RDD[(Int,Double)] ) : Array[Double] = | |
rdd.sortBy(_._1).map(_._2).toArray | |
def vec_from_rdd( rdd: RDD[(Int,Double)] ) = | |
Vectors.dense( array_from_rdd( rdd ) ) |
// this is a basic bookmarklet to simply CfA proxy use, | |
// especially with the NASA ADS system. | |
// (assuming one has a CfA PIN to log into the proxy) | |
// | |
// to make it a bookmarklet, run it through: | |
// John Gruber's Bookmarklet-Builder | |
// http://daringfireball.net/2007/03/javascript_bookmarklet_builder | |
// OR | |
// http://subsimple.com/bookmarklets/jsbuilder.htm | |
// |
// this is a simple bookmarklet to make using NASA ADS simple at CfA | |
// (assuming one has a CfA PIN to log into the proxy) | |
// | |
// to make it a bookmarklet, run it through: | |
// John Gruber's Bookmarklet-Builder | |
// http://daringfireball.net/2007/03/javascript_bookmarklet_builder | |
// OR | |
// http://subsimple.com/bookmarklets/jsbuilder.htm | |
var public_url = "adsabs.harvard.edu"; |
/* some basic formatting guidelines for C code */ | |
--indent-level 4 | |
--tab-size 8 | |
--no-tabs | |
--line-length 100 | |
--braces-on-if-line | |
--braces-on-struct-decl-line | |
--cuddle-do-while |
#include <stdio.h> | |
void | |
func( ) | |
{ | |
static int x = 0; // x is initialized only once across three calls of func() | |
printf( " %d", x ); // outputs the value of x | |
x = x + 1; | |
} |
#include <stddef.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
void | |
print_size( char const * const desc, const size_t size ) | |
{ | |
printf(" %10s: %zu bytes\n", desc, size); |
(* ways to check if float is an integer *) | |
let is_int v = | |
v = (snd (modf v)) | |
;; | |
let better_is_int v = | |
let c = classify_float (fst (modf v)) in | |
c == FP_zero | |
;; |
// This is a slight modification of the original at: | |
// http://www.cap-lore.com/Languages/const.c | |
// | |
// Does "int const *" refer to a constant pointer, or a constant integer? | |
// The following shows what gcc thinks. | |
// gcc 4 rejects any of the lines below that are commented out. | |
typedef const int * cip; | |
typedef int const * icp; | |
typedef int * const ipc; | |
typedef int const * const icpc; |
(* find min/max of an array, type generic *) | |
let minmax a = | |
let start = a.(0), a.(0) in | |
let mm t e = (min (fst t) e , max (snd t) e ) in | |
Array.fold_left mm start a | |
;; |