Skip to content

Instantly share code, notes, and snippets.

View x5lcfd's full-sized avatar
:octocat:
coding.

x5lcfd x5lcfd

:octocat:
coding.
View GitHub Profile
@x5lcfd
x5lcfd / emacs-start.bat
Last active September 13, 2018 04:16
emacs related.
REM https://www.emacswiki.org/emacs/EmacsMsWindowsIntegration
c:\path\to\emacs\bin\emacsclientw.exe -c -n -a c:\path\to\emacs\bin\runemacs.exe
import numpy as np
import matplotlib.pyplot as plt
import time as time
total_random_points = int(input("\nNumber of random points for Monte Carlo estimate value of PI?\n>"))
start_time = time.time()
inside_circle = 0
// https://doxygen.postgresql.org/erand48_8c_source.html
#pragma once
#include <cmath>
#define RAND48_SEED_0 (0x330e)
#define RAND48_SEED_1 (0xabcd)
#define RAND48_SEED_2 (0x1234)
#define RAND48_MULT_0 (0xe66d)
@x5lcfd
x5lcfd / smallpt.cc
Last active September 9, 2018 08:55
the explanation of smallpt.
#include <iostream>
#include <random>
#include <cstdlib>
#include <cstdio>
#include "erand48.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif // !M_PI
// Place your settings in this file to overwrite the default settings
{
"editor.fontSize": 15,
"editor.fontFamily": "'Consolas', 'Inziu IosevkaCC SC'",
"editor.fontLigatures": true,
"editor.renderLineHighlight": "none",
"editor.letterSpacing": 0,
"editor.minimap.enabled": false,
"editor.occurrencesHighlight": false,
"editor.cursorBlinking": "smooth",
@x5lcfd
x5lcfd / ProFi.lua
Created August 13, 2018 12:48 — forked from perky/ProFi.lua
ProFi, a simple lua profiler that works with LuaJIT and prints a pretty report file in columns.
--[[
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php.
Example:
ProFi = require 'ProFi'
ProFi:start()
some_function()
another_function()
coroutine.resume( some_coroutine )
ProFi:stop()
/*
The C# version of https://github.com/cloudwu/lua-snapshot on https://github.com/topameng/tolua_runtime
*/
using System;
using System.Text;
using LuaInterface;
public static class Snapshot
{
private readonly static int TABLE = 1;
@x5lcfd
x5lcfd / google_array_size.cc
Created August 8, 2018 23:33
[GOOGLE_ARRAYSIZE]
#undef GOOGLE_ARRAYSIZE
#define GOOGLE_ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
@x5lcfd
x5lcfd / SimpleHTTPServerWithUpload.py
Created August 6, 2018 12:13 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@x5lcfd
x5lcfd / SimpleDistanceFieldRaymarcher.glsl
Last active August 3, 2018 11:24
a simple distance field raymarcher
// https://www.shadertoy.com/view/lltczj
// https://www.reddit.com/r/twotriangles/comments/1hy5qy/tutorial_1_writing_a_simple_distance_field/
const int MAX_ITER = 100;
const float MAX_DIST = 20.0;
const float EPSILON = 0.001;
float sphere(vec3 pos, float radius)
{
return length(pos) - radius;