Skip to content

Instantly share code, notes, and snippets.

View xxMrPHDxx's full-sized avatar
😃
Focusing

xxMrPHDxx

😃
Focusing
View GitHub Profile
@xxMrPHDxx
xxMrPHDxx / code.py
Created December 11, 2022 20:01
advent_of_code11
# We multiply all modulo of the monkeys and use it to keep
# the number small
modulo = 23 * 19 * 13 * 17
monkeys = [
{
'items': [79, 98],
'operation': lambda x: (x * 19)%modulo,
'test': lambda x: x % 23 == 0,
'throw': lambda arr, test, val: monkeys[2 if test else 3]['items'].append(val),
@xxMrPHDxx
xxMrPHDxx / main.py
Created May 6, 2021 00:27
Neural Network Python Numpy (Conv2D, MaxPooling2D, Flatten, Dense with ReLU and SoftMax)
from functools import reduce
import numpy as np
def product(arr):
return reduce(lambda a,b: a*b, arr, 1)
class Activation():
def forward(self, inputs):
raise RuntimeException('Unimplemented abstract function Activation::forward!')
sudo apt install libx11-dev
sudo apt install libgl1-mesa-dev
sudo apt install build-essential libxmu-dev libxi-dev libgl-dev libosmesa-dev
sudo apt install x11proto-randr-dev
sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
const canvas = document.querySelector('canvas#screen');
canvas.width = innerWidth;
canvas.height = innerHeight;
const ctx = canvas.getContext('2d');
const RED = 0, GREEN = 1;
const COLORS = ['red', 'green'];
// const COLORS = ['white', 'black'];
class Cell {
const express = require('express');
const app = express();
const port = process.env.PORT || 5000;
const server = app.listen(port);
app.use(express.static('public'));
console.log('Socket server is running at localhost:' + port);
let socket = require('socket.io');
@xxMrPHDxx
xxMrPHDxx / test.lua
Last active June 6, 2020 16:23
Lua test 1
local v1 = Vector:new(3, 7)
local v2 = Vector:new(4, 9)
print("Vector 1: x = " .. v1.x .. ", y = " .. v1.y);
print("Vector 2: x = " .. v2.x .. ", y = " .. v2.y);
print(v1.get_x);
print(v1.get_x());
--print("Method Vector 1 get_x: " .. Vector:get_x(v1));
{
"shell_cmd": "sfml \"${file_path}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c++",
"variants": [
{
"name": "Run",
"shell_cmd": "sfml \"${file_path}\" run"
}
@xxMrPHDxx
xxMrPHDxx / close.js
Last active December 23, 2019 04:32
function isClose(a,b,debug=false){
let differ=0, aa=a.split(''), bb=b.split('');
for(const letter of 'abcdefghijklmnopqrstuvwxyz'){
let aaa=aa.includes(letter), bbb=bb.includes(letter);
if(!((aaa && bbb) || (!aaa && !bbb))) {
differ++;
}
}
if(debug) console.log(differ);
return differ <= 2;
<html lang="en">
<head>
<!-- <script id="facebook-jssdk" src="https://connect.facebook.net/en_US/sdk.js" async defer></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<style type="text/css">
.icon {
width: 36px;
height: 36px;
background-repeat: no-repeat;
background-position: center;
@xxMrPHDxx
xxMrPHDxx / Promise.js
Created December 3, 2019 07:48
Custom Promise
class Promise {
constructor(action){
this.status = 'pending';
this.value = this.error = undefined;
action((value=>{
this.status = 'resolved';
this.value = value;
}).bind(this),(error=>{
this.status = 'rejected';