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
import cv2 | |
import numpy as np | |
from sklearn.cross_decomposition import PLSRegression | |
from sklearn.linear_model import LinearRegression | |
from sklearn.decomposition import PCA | |
import scipy.sparse as sp | |
import sys | |
reference_colors = [[115, 82, 68], [194, 150, 130], [98, 122, 157], [87, 108, 67], [133, 128, 177], [103, 189, 170], [214, 126, 44], [80, 91, 166], [193, 90, 99], [94, 60, 108], [157, 188, 64], [ | |
224, 163, 46], [56, 61, 150], [70, 148, 73], [175, 54, 60], [231, 199, 31], [187, 86, 149], [8, 133, 161], [243, 243, 242], [200, 200, 200], [160, 160, 160], [121, 122, 121], [85, 85, 85], [52, 52, 52]] |
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
#include <iostream> | |
#include <typeinfo> | |
#include <stdexcept> | |
using namespace std; | |
class A { | |
public: | |
virtual void print() { cout << "A" << endl; } | |
}; |
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
#include <functional> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <string.h> | |
using namespace std; | |
int f(int argc, char* argv[]) { | |
for(int i=0;i<argc;++i) cout << argv[i] << endl; | |
return 0; |
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
# regularize filenames | |
for f in `ls *.png`; do | |
echo $f | |
filename=`echo "$f" | cut -d'.' -f1` | |
echo $filename | |
mv $f $filename.png | |
done |
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
import java.util.Random; | |
import java.util.concurrent.*; | |
import java.util.Vector; | |
public class Main { | |
static class TimeConsumingTask implements Runnable { | |
public Vector<Integer> results = new Vector<>(); | |
@Override | |
public void run() { |
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
#include <iostream> | |
#include <memory> | |
#include <cstdlib> | |
#include <unordered_map> | |
#include <stdexcept> | |
using namespace std; | |
template <int MAX_TABLE_SIZE=1024> | |
class MemTracker { | |
pair<void*, bool> mem_tbl[MAX_TABLE_SIZE]; |
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
all_plates = 'ABC' | |
state = { | |
'A': [], | |
'B': [], | |
'C': [] | |
} | |
def print_state(): | |
print 'A:', state['A'], 'B:', state['B'], 'C:', state['C'] |
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
#include <math.h> // smallpt, a Path Tracer by Kevin Beason, 2008 | |
#include <stdlib.h> // Make : g++ -O3 -fopenmp smallpt.cpp -o smallpt | |
#include <stdio.h> // Remove "-fopenmp" for g++ version < 4.2 | |
struct Vec { // Usage: time ./smallpt 5000 && xv image.ppm | |
double x, y, z; // position, also color (r,g,b) | |
Vec(double x_=0, double y_=0, double z_=0){ x=x_; y=y_; z=z_; } | |
Vec operator+(const Vec &b) const { return Vec(x+b.x,y+b.y,z+b.z); } | |
Vec operator-(const Vec &b) const { return Vec(x-b.x,y-b.y,z-b.z); } | |
Vec operator*(double b) const { return Vec(x*b,y*b,z*b); } | |
Vec mult(const Vec &b) const { return Vec(x*b.x,y*b.y,z*b.z); } |
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
(define (change c) '(Change c)) | |
(define (insert c) '(Insert c)) | |
(define copy '(Copy)) | |
(define delete '(Delete)) | |
(define kill '(Kill)) | |
(define (cost x) | |
(length (filter (lambda (z) (not (eq? (car z) 'Copy))) x))) | |
(define (best edits) |
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
#include <iostream> | |
#include <queue> | |
#include <vector> | |
#include <climits> | |
#include <unordered_map> | |
using namespace std; | |
template <typename Key, typename Value, typename Comp=std::greater<Value>> | |
class priorty_queue { | |
public: |
NewerOlder