Skip to content

Instantly share code, notes, and snippets.

View revsic's full-sized avatar

YoungJoong Kim revsic

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
const unsigned char EXIF_SIGN[] = { 0xFF, 0xD8, 0xFF, 0xE1 };
struct IFD_Field {
unsigned short tagID;
unsigned short typeID;
unsigned int countOfComponents;
@revsic
revsic / pycala.c
Created June 12, 2017 04:32
Pycala interpreter prototype.
#include <stdio.h>
#include <stdlib.h> //exit function
#include <string.h>
typedef void(* f)(char *arg);
typedef int(* c)(int i, int j);
void parse(char *inst);
void real(int index, int cnt);
char* trim(char *str);
@revsic
revsic / ThreeByteVM.cpp
Created September 24, 2017 08:36
2017 Layer7 CTF TBVM - Code Virtualized Protection based on Three Bytes System
#define LINUX
#define DEBUG
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifdef WIN
#include <Windows.h>
#endif
@revsic
revsic / hs-calculator.hs
Last active November 8, 2017 05:27
Haskell implementation of Calculator
import Data.List (isPrefixOf, sortBy)
import Data.Ord (comparing)
import Data.Vector.Unboxed (Vector, empty, snoc, (!?))
import qualified Data.Vector.Unboxed as V (length)
type BinaryOperator = Double -> Double -> Double
data BinOp = BinOp { name :: String, f :: BinaryOperator, prec :: Int }
main :: IO ()
@revsic
revsic / FastFibonacci.c
Created December 13, 2017 15:10
Fibonacci calculation via matrix multiplication in O(log2n).
#include <stdio.h>
#include <stdlib.h>
int basicMat[4] = { 1, 1, 1, 0 };
int calcMat[4];
int* mul(int mat1[4], int mat2[4]) {
int i, newMat[4];
newMat[0] = mat1[0] * mat2[0] + mat1[1] * mat2[2];
@revsic
revsic / ConvLSTMCell.py
Last active April 5, 2020 17:06
Tensorflow implementation of Convolutional LSTM
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@revsic
revsic / fold_ver1.cpp
Last active October 26, 2018 06:45
constexpr fold implementation with non-operator binary function
#include <iostream>
#include <tuple>
#include <utility>
template <typename F>
struct Fold {
F oper;
template <typename T>
struct Wrapper {
@revsic
revsic / unique_handler.cpp
Last active November 9, 2018 12:52
handler version of unique_pointer
#include <gsl/gsl>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <type_traits>
#ifdef __APPLE__
#include <experimental/optional>
template <typename T>
@revsic
revsic / fold_ver2.cpp
Last active October 26, 2018 12:15
cpp implementation of constexpr fold
#include <iostream>
template <typename F>
struct Fold {
F func;
template <typename Fs>
constexpr Fold(Fs&& func) : func(std::forward<Fs>(func)) {}
template <typename T, typename U>
@revsic
revsic / enumerate.cpp
Created October 27, 2018 09:33
cpp implementation of range based enumeration
#include <tuple>
template <typename T,
typename IterType = decltype(std::declval<T>().begin())>
struct Enumerate {
T object;
IterType iter_begin;
IterType iter_end;
size_t size;