Skip to content

Instantly share code, notes, and snippets.

View daeyun's full-sized avatar

Daeyun Shin daeyun

View GitHub Profile
void Inverse33(const double a[3][3], double inv[3][3]) {
int i, j;
double determinant = 0;
for (i = 0; i < 3; i++)
determinant =
determinant + (a[0][i] * (a[1][(i + 1) % 3] * a[2][(i + 2) % 3] -
a[1][(i + 2) % 3] * a[2][(i + 1) % 3]));
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
@daeyun
daeyun / daeyun_shin
Created October 17, 2015 03:36
daeyun shin
daeyun

Keybase proof

I hereby claim:

  • I am daeyun on github.
  • I am daeyun (https://keybase.io/daeyun) on keybase.
  • I have a public key whose fingerprint is C082 56CF 3D97 BBBF A18A FAE2 42CB 2976 346F 9688

To claim this, I am signing this object:

@daeyun
daeyun / gist:630b553bf299071e1dc3
Created June 18, 2015 16:56
bash colored echo with "set -x"
EchoRed() {
{ set +x; } 2>/dev/null
echo "$(tput setaf 1)${1}$(tput sgr0)"
set -x
}
EchoGreen() {
{ set +x; } 2>/dev/null
echo "$(tput setaf 2)${1}$(tput sgr0)"
set -x
function renderMesh(Mesh, vertexColors, az, el, upvec)
if ~exist('vertexColors', 'var'), vertexColors=zeros(size(Mesh.v,1), 1); end
if ~exist('az', 'var'), az=-45; end
if ~exist('el', 'var'), el=-120; end
if ~exist('upvec', 'var'), upvec=[0 1 0]; end
y=Mesh.v(:,2);
Mesh.v(:,2)=Mesh.v(:,3);
Mesh.v(:,3)=y;
/**
* C++11 coroutine example using Boost.Coroutine
* Created by daeyun on 1/13/15.
*/
#include <iostream>
#include <boost/coroutine/all.hpp>
template <typename T>
using coro = boost::coroutines::asymmetric_coroutine<T>;
using std::cout;
def levelsum(L, k):
if L.__class__ == int:
return L
total = 0
for element in L:
total += level_sum(element, k+1)
if k == 0:
return total
% DEFORM_SURFACE_TPS - Given a set of control points and mapping
% coefficients, compute a deformed surface f(S) using a thin plate spline
% radial basis function phi(r) as shown in [1].
%
% Usage: [fX, fY, fZ] = deform_surface_tps(X, Y, Z, control_points, ...
% mapping_coeffs, poly_coeffs)
%
% Arguments:
% X, Y, Z - h by w matrices of X, Y, Z components of the
% surface.
public class Main {
public static void main(String[] args) throws IOException {
SocketChannel socketChannel = SocketChannel.open();
try {
socketChannel.connect(new InetSocketAddress("localhost", 10100));
} catch (IOException e) {
// Connection error
}
@daeyun
daeyun / boggle.cpp
Last active December 27, 2015 21:49
C++ Boggle solver. Perform BSF on a graph of 26 vertices.
/* Author: Daeyun Shin */
#include<map>
#include<cassert>
#include<queue>
using namespace std;
map<char, map<char, bool> > graph;
int boggle(int board[4][4], const char * word) {
// populate the graph
for (int i = 0; i < 4; i++) {