Skip to content

Instantly share code, notes, and snippets.

@ewoo
ewoo / install-CUDA-docker-nvidia-docker.sh
Created June 19, 2018 18:39 — forked from dte/install-CUDA-docker-nvidia-docker.sh
Install CUDA, Docker, and Nvidia Docker on a new Paperspace GPU machine
#!/bin/bash
# 1. Install CUDA
echo "Installing CUDA..."
# Only install if CUDA is not already installed.
if ! dpkg-query -W cuda; then
# The 16.04 installer works with 16.10.
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
apt-get update
apt-get install cuda -y
@ewoo
ewoo / main.R
Created November 29, 2015 13:46 — forked from jameskyle/main.R
library(MDPtoolbox)
library(Matrix)
library(ggplot2)
library(grid)
library(gridExtra)
library(doMC)
cores <- detectCores() - (detectCores() / 2) / 2
registerDoMC(cores=cores)
set.seed(1234)
@ewoo
ewoo / randomProjection.R
Created October 29, 2015 15:51
A Random Projection function using "mlr" package in R.
# Written by Adam Acosta
randomProjection <- function(A, k) {
if (!is.matrix(A)) {
tmp <- as.matrix(A)
} else {
tmp <- A
}
p <- ncol(tmp)
set.seed(as.numeric(format(Sys.time(), '%S')))
R <- matrix(data = rnorm(k), nrow = k, ncol = p)
@ewoo
ewoo / tools-search-sp-definitions.sql
Created October 8, 2015 18:10
Search for a specific string inside a SQL stored procedure object.
DECLARE @find VARCHAR(1000)
SET @find = '%search string%'
SELECT
sp.name,
ISNULL(smsp.definition, ssmsp.definition) AS [Definition]
FROM
sys.all_objects AS sp
LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id
LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id = sp.object_id
@ewoo
ewoo / tools-search-view-definitions.sql
Created October 8, 2015 18:09
Search for a specific string inside a SQL View object.
DECLARE @search VARCHAR(1000)
SET @search = '%friendly%'
SELECT v.name, c.[Text]
FROM dbo.sysobjects AS v
INNER JOIN dbo.syscomments c ON c.id = v.id
AND CASE WHEN c.Number > 1 THEN c.Number
ELSE 0 END = 0
WHERE v.type = 'V' AND c.[Text] LIKE '%' + @search + '%'
@ewoo
ewoo / tools-table-rowcounts.sql
Last active October 8, 2015 18:11
List SQL tables and their corresponding row counts.
SELECT sysobjects.Name, sysindexes.Rows
FROM sysobjects
INNER JOIN sysindexes ON sysobjects.id = sysindexes.id
WHERE type = 'U'
AND sysindexes.IndId < 2
-- AND sysobjects.name LIKE 'SOMENAME_%'
ORDER BY sysindexes.Rows DESC
@ewoo
ewoo / Default (OSX).sublime-keymap
Last active September 17, 2015 13:39
My Sublime Text macro to insert date headers onto my work log. Depends on InsertDate package.
[
{"keys": ["super+d"], "command": "run_macro_file", "args": {"file": "Packages/User/insert-date.sublime-macro"}}
]
@ewoo
ewoo / sparc-rt-reporting-views.sql
Created July 12, 2015 22:29
Custom Reporting Views for RT
CREATE
ALGORITHM = UNDEFINED
DEFINER = `rt_user`@`localhost`
SQL SECURITY DEFINER
VIEW `TicketBaseProperties` AS
SELECT
`t`.`id` AS `TicketId`,
`q`.`id` AS `QueueId`,
`q`.`Name` AS `Queue`,
`t`.`Owner` AS `OwnerId`,
@ewoo
ewoo / barcode-input-handler.js
Last active August 29, 2015 14:24
Browser Keyboard Input Steam Handler (for parsing-out SGN barcodes)
$(document).ready(function() {
console.log("Ready!");
});
$("#target").submit(function(event){
event.preventDefault();
});
function parseBuffer(key, buffer){
var index = buffer.indexOf(key);
@ewoo
ewoo / SnakeCaseFormUrlEncodedMediaTypeFormatter.cs
Last active October 19, 2016 04:20
A custom MediaTypeFormatter for wrangling incoming form-url-encoded snake case (ruby-style) field names into regular property names such that ASP.NET Web API's plumbing can properly bind them to .NET model objects.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.ModelBinding;