Skip to content

Instantly share code, notes, and snippets.

View dselivanov's full-sized avatar

Dmitry Selivanov dselivanov

View GitHub Profile
library("miniCRAN")
sessionInfo()
available.packages()
pkgs <- as.data.frame(installed.packages())
pkgs <- names(pkgs$Package)
pkgList <- pkgDep(pkgs, repos=getOption("repos"), type="source", suggests = T)
dir.create(pth <- file.path("~/Downloads/", "miniCRAN"))
makeRepo(pkgList, path=pth, repos=getOption("repos"), type="source")
@dselivanov
dselivanov / glmnet-ref.r
Created January 13, 2016 11:03 — forked from kaneplusplus/glmnet-ref.r
A minimal glmnet implementation in R
soft_thresh = function(x, g) {
x = as.vector(x)
w1 = which(g >= abs(x))
w2 = which(g < abs(x) & x > 0)
w3 = which(g < abs(x) & x < 0)
ret = x
ret[w1] = 0
ret[w2] = x[w2]-g
ret[w3] = x[w3]+g
ret
devtools::install_github("dselivanov/text2vec@redesign")
library(text2vec)
library(data.table)
library(magrittr)
library(glmnet)
library(irlba)
data("movie_review")
system.time(txt <- movie_review[['review']] %>% tolower %>% regexp_tokenizer)
vocabObj <- new(Vocabulary,ngram_min = 1, ngram_max = 1)
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
@dselivanov
dselivanov / white-helv.css
Created November 23, 2016 16:09 — forked from SlavikBaranov/white-helv.css
Helvetica theme for RevealJS presentation
/**
* White theme for reveal.js. This is the opposite of the 'black' theme.
*
* By Hakim El Hattab, http://hakim.se
*/
section.has-dark-background, section.has-dark-background h1, section.has-dark-background h2, section.has-dark-background h3, section.has-dark-background h4, section.has-dark-background h5, section.has-dark-background h6 {
color: #fff; }
/*********************************************
* GLOBAL STYLES
# to install the latest stable version:
brew install scala --with-docs
# to install scala-2.10:
brew install https://raw.github.com/gist/4340744/scala.rb --with-docs
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch scala 2.9.2
brew switch scala 2.10.0