Skip to content

Instantly share code, notes, and snippets.

View arcollector's full-sized avatar

Ruiz Martin arcollector

View GitHub Profile
#!/usr/bin/env ruby
# frozen_string_literal: true
# Allow utf-8 charactor in config value
# For example, APP_NAME=中文字符
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
# TODO: introduce a parameter which controls how to build relative path
def read_dot_env(envs_root)
import R from 'ramda';
const createElement = (tag: String): HTMLElement =>
document.createElement(tag);
const createTextElement = (text: String): HTMLElement =>
document.createTextNode(text);
const setElementText = (text: String, elem: HTMLElement): HTMLElement => {
R.compose(
@arcollector
arcollector / Tossing 2 coins - probability calculations.js
Last active February 11, 2017 22:02
Tossing 2 coins - probability calculations
(() => {
const toss = () => Math.random() >= .5;
const throws = [];
for(let i = 0; i < 10000; ++i) {
const isHead1 = toss(),
isHead2 = toss();
throws.push(
isHead1 && isHead2 ? 'HH' :
@arcollector
arcollector / plane_uv_calculation_using_intersection_point.c
Created January 29, 2017 20:59
plane_uv_calculation_using_intersection_point.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "../raytracing/helpers.h"
#include "../raytracing/vector.h"
#include "../raytracing/matrix.h"
int main(void) {
@arcollector
arcollector / pcx24and8toppm24.c
Last active December 7, 2016 23:54
PCX (24 bit / 8bit) to PPM (24 bit) converter in C
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct PCX_HeaderStruct {
uint8_t sig;
uint8_t ver;
uint8_t isCompress;
uint8_t bitsPerPixel;
@arcollector
arcollector / .vimrc
Last active February 17, 2021 15:00
read comment below!!!!
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/syntastic'
Plug 'scrooloose/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
Plug 'ryanoasis/vim-devicons'
Plug 'kien/rainbow_parentheses.vim'
Plug 'bling/vim-bufferline'
# Global initialisation file for SciTE
# For Linux, place in $prefix/share/scite
# For Windows, place in same directory as SciTE.EXE (or Sc1.EXE)
# Documentation at http://www.scintilla.org/SciTEDoc.html
# Globals
# Window sizes and visibility
if PLAT_WIN
position.left=0
@arcollector
arcollector / gist:47b35d9f2e2c9668c0d0
Created February 20, 2016 04:02
stochastic ray tracing - adapt part
var win = [ [],[],[],[],[] ];
var flags = [ [],[],[],[],[] ];
var winLength = 4;
function arand() {
return Math.random()/4 - 1/8;
}
function adapt(x,y, i,j, step) {
@arcollector
arcollector / gist:8131e3cdc06e9b796049
Last active August 29, 2015 14:22
Anti aliasing by filtering using a weighted averaging scheme
var table = [
[1,2,1],
[2,4,2],
[1,2,1],
];
var tableMaxDim = 3;
var tableSum = 16;
var filterStart = -1;
var filterEnd = 1;
@arcollector
arcollector / gist:2c83285a76a676b253fd
Last active August 29, 2015 14:21
DXF polygon codes
100
AcDbEntity
100
AcDbPolyFaceMesh // MESH VERTICES FOLLOWS
100
AcDbEntity
100
AcDbVertex
100