Skip to content

Instantly share code, notes, and snippets.

View Qambar's full-sized avatar

UncleAaroh.eth Qambar

  • Remote
  • 07:24 (UTC +01:00)
View GitHub Profile
@primaryobjects
primaryobjects / mmds-q2a.R
Last active November 7, 2016 10:14
Mining Massive Datasets Quiz 2a: LSH (Basic)
#
# Quiz 2a
#
#
# Q1
# The edit distance is the minimum number of character insertions and character deletions required to turn one string into another. Compute the edit distance between each pair of the strings he, she, his, and hers. Then, identify which of the following is a true statement about the number of pairs at a certain edit distance.
#
packages <- c('combinat', 'stringdist')
@primaryobjects
primaryobjects / mmds-q1.R
Last active March 16, 2020 22:11
Mining Massive Datasets Quiz 1
# Q1
#
# Suppose we compute PageRank with a β of 0.7, and we introduce the additional constraint that the sum of the PageRanks of the three pages must be 3, to handle the problem that otherwise any multiple of a solution will also be a solution. Compute the PageRanks a, b, and c of the three pages A, B, and C, respectively. Then, identify from the list below, the true statement.
#
# Matrix
#
# A B C
# A 0 0 0
# B 0.5 0 0
# C 0.5 1 1
@primaryobjects
primaryobjects / mapReduce.R
Last active December 8, 2020 22:03
Map Reduce example in R. Demonstrates applying a map and reduce function to an input array, resulting in a hash of key/value pairs. This example maps a method to find prime divisors of each input value and then reduces the result by summing the input value for each prime divisor. See demo at http://www.r-fiddle.org/#/fiddle?id=tyir23SG&version=1
is.prime <- function(num) {
if (num == 2) {
TRUE
} else if (any(num %% 2:(num-1) == 0)) {
FALSE
} else {
TRUE
}
}

Although you may have great version control in place, sometimes stuff gets inadvertently overwritten or messed up…in this case it's always good to do a quick backup before you do anything potentially serious. I've written a little Bash shell hack which I thought might be useful:

In your ~/.bash_profile (or ~/.bashrc if you load that in your .bash_profile) file, add the line:

alias bag='b=$(basename `pwd`);cd ..;tar -cvf  $b"_"$(date +'%Y-%m-%d_%H-%M-%S')".tar.gz" "./"$b"/";cd $b'

...then re-load your bashrc by running 'source ~/.bash_profile' or 'source ~/.bashrc'.

When you're then in your working directory, simply run 'bag' which will create a time-stamped, gzipped tar file in the directory above the one you're in, containing the contents of the directory you're currently in. Such as:

@FokkeZB
FokkeZB / README.md
Created September 20, 2013 09:38
URL schemes for iOS and Android (2/2)