This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To measure timing | |
#' http://stackoverflow.com/questions/5849800/tic-toc-functions-analog-in-python | |
def tic(): | |
# Homemade version of matlab tic and toc functions | |
import time | |
global startTime_for_tictoc | |
startTime_for_tictoc = time.time() | |
def toc(): | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Sun Jun 4 11:48:48 2017 | |
@author: msuzen | |
""" | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
By msuzen GPLv3 | |
See Also: https://stackoverflow.com/questions/3133243/how-do-i-get-the-path-to-the-current-script-with-node-js | |
*/ | |
var fs = require('fs'); | |
var shapes = fs.readFile(process.cwd() + '/' + options.shapes, function(err, data) | |
{ | |
if(err) | |
console.log(err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
R Notes: | |
# tryCath Example | |
# http://stackoverflow.com/questions/12193779/how-to-write-trycatch-in-r | |
out <- tryCatch({ | |
pp <- find.package(packageName,lib.loc=lib.loc), | |
}, | |
error=function(cond) { | |
cat("packageName or lib.loc in ", | |
"packageRSubdirectoryLinesOfCode", | |
"does not seem to exist \n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# An example usage of apt from python programmatically | |
# | |
# | |
import apt # use apt-get to install somehow pip has an issue | |
import apt_pkg | |
apt_pkg.init_config() | |
apt_pkg.init_system() | |
cache = apt_pkg.Cache() # all cache packages | |
ipacks = [pack for pack in cache.packages] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Object-oriented programming is an exceptionally bad idea which could only have originated in California." | |
(Edsger Dijkstra, (Dutch computer Scientist, 1930-2002) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
(c) 2017 | |
Creative Commons Licence | |
This work is licensed under a Creative Commons Attribution 3.0 Unported License. | |
""" | |
import functools as ft | |
# Example on using arbitrary number of arguments | |
def msum(*nums): | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
RDD partition size retains from the parent | |
(c) 2017 | |
GPLv3 | |
Author: Mehmet Suzen (suzen at acm dot org) | |
*/ | |
// Generate 1 million Gaussian random numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (c) Copyright 2008-2015 Mehmet Suzen (suzen at acm dot org) | |
# Creative Commons Licence | |
# This work is licensed under a Creative Commons Attribution 3.0 Unported License. | |
# | |
rm(list=ls()) | |
library(glmnet) | |
library(R1magic) # https://github.com/msuzen/R1magic | |
set.seed(4242) | |
n <- 100 # observations | |
X <- model.matrix(~., data.frame(x1 = rnorm(n, 1, 1), |