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<stdio.h> | |
void main(){ | |
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
rm(list = ls()) | |
# Set SPSS-like contrast | |
options(contrasts=c(unordered="contr.sum", ordered="contr.poly")) | |
# plug-in operators | |
`%+%` <- function(a, b) paste(a, b, sep="") | |
`%beginwith%` <- function(s.main, s.sub){ | |
bl <- nchar(s.sub) | |
return(substr(s.main,1,bl)==s.sub) | |
} |
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/python | |
# SuperDualNumBros v0.9 by CWhy@guokr | |
# Python3 | |
from math import ceil, sqrt | |
Min, Max = 2, 99 | |
def getSameSum(nums): | |
x, y = 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
% Use case: | |
% we have test function m = f(x, y, z), where we vary x, y, and z to get different ms | |
% we want the result M where M(x, y, z) = f(x, y, z) | |
% but vectorized with one for loop | |
% Example: xs = 1:2 | |
% ys = 3:5 | |
% zs = 6:9 | |
[X,Y,Z] = meshgrid(xs, ys, zs); | |
test_instances = [X(:) Y(:) 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
close all; | |
f = figure('Name', 'Visualization','Color', [1 1 1]); | |
set(f, 'menubar', 'none'); | |
ax = axes(); | |
hold(ax,'on') | |
set(ax, 'Unit', 'normalized'); | |
set(ax, 'Position', [0.07 0.05 0.9 0.9]) |
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 numpy as np | |
import numpy.random as rd | |
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
def get_shells(center, radius, N): | |
# from http://stats.stackexchange.com/questions/7977 | |
r = radius |
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 os | |
import glob | |
import errno | |
import pandas as pd | |
import subprocess as sp | |
si = sp.STARTUPINFO() | |
si.dwFlags |= sp.STARTF_USESHOWWINDOW | |
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
<a href="javascript:{_l=window.location;window.location='http://'+_l.hostname+'.ezlibproxy1.ntu.edu.sg/'+_l.pathname;};">NTU Libraries Proxy Bookmarklet</a> |
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
# It is not very pythonic but I don't like a lot of [[[['''']]]]'''' symbols | |
class Fake_dict: | |
def __iter__(self): | |
for attr in dir(Fake_dict): | |
if not attr.startswith("__"): | |
yield attr |
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
(defn argmax [l] (key (apply max-key val (into {} (map-indexed vector l))))) |
OlderNewer