Skip to content

Instantly share code, notes, and snippets.

View mudream4869's full-sized avatar
πŸͺ„
Mukyu Learning

η₯žζ₯½ε‚εΈ•ηͺ mudream4869

πŸͺ„
Mukyu Learning
View GitHub Profile
@mudream4869
mudream4869 / raytracing.py
Created March 22, 2017 16:37 — forked from rossant/raytracing.py
Very simple ray tracing engine in (almost) pure Python. Depends on NumPy and Matplotlib. Diffuse and specular lighting, simple shadows, reflections, no refraction. Purely sequential algorithm, slow execution.
import numpy as np
import matplotlib.pyplot as plt
w = 400
h = 300
def normalize(x):
x /= np.linalg.norm(x)
return x
@mudream4869
mudream4869 / ipm.cpp
Created August 19, 2017 15:30 — forked from censored--/ipm.cpp
IPM
#include <Eigen/Core>
#include <Eigen/Sparse>
using namespace std;
using namespace Eigen;
void sinitialize(VectorXd &s,double mu,unsigned int sizex,VectorXd &x)
{
for (unsigned int i=0;i<sizex;i++)
if (x[i]!=0)s[i] = mu/x[i];
else s[i]=0.1;
@mudream4869
mudream4869 / intbuffv1.cpp
Last active March 15, 2020 07:00
intbuffv1.cpp
#include <cstdio>
class IntBuff {
public:
IntBuff() = default;
explicit IntBuff(size_t sz) : sz(sz) {
if (sz) {
arr = new int[sz];
}
};
@mudream4869
mudream4869 / intbuffv2.cpp
Created March 15, 2020 07:51
intbuffv2.cpp
#include <algorithm>
#include <cstdio>
#include <memory>
class IntBuff {
public:
IntBuff() = default;
explicit IntBuff(size_t sz) : sz(sz) {
if (sz) {
arr = new int[sz];
@mudream4869
mudream4869 / intbuffv3.cpp
Created March 18, 2020 06:40
intbuffv3.cpp
#include <algorithm>
#include <cstdio>
#include <memory>
class IntBuff {
public:
IntBuff() = default;
explicit IntBuff(size_t sz) : sz(sz) {
if (sz) {
arr = new int[sz];
@mudream4869
mudream4869 / intbuffv4.cpp
Created March 19, 2020 14:27
intbuffv4.cpp
#include <algorithm>
#include <cstdio>
#include <memory>
class IntBuff {
public:
IntBuff() = default;
explicit IntBuff(size_t sz) : sz(sz) {
if (sz) {
arr = std::unique_ptr<int[]>(new int[sz]);
@mudream4869
mudream4869 / llvm-helloworld.cpp
Created April 16, 2021 04:11
LLVM Helloworld
#include <llvm/IR/Function.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Value.h>
#include <llvm/Support/raw_os_ostream.h>
#include <memory>
@mudream4869
mudream4869 / main.go
Created April 22, 2021 04:10
Fake quine with go embed
package main
import (
_ "embed"
)
//go:embed main.go
var s string
func main() {
@mudream4869
mudream4869 / python-sleep.py
Created February 10, 2022 15:23
interrupted sleep
import signal, time
class InterruptSleep(Exception):
pass
def main():
while True:
try:
time.sleep(60)
except InterruptSleep:
@mudream4869
mudream4869 / python-event-sleep.py
Created February 10, 2022 15:39
python-event-sleep.py
import threading, signal
exit = threading.Event()
def main():
while not exit.is_set():
exit.wait(60)
def quit(signo, frame):
exit.set()