Skip to content

Instantly share code, notes, and snippets.

View sanchezcarlosjr's full-sized avatar
🏛️
Studying computer science

Carlos Eduardo Sanchez Torres (sanchezcarlosjr) sanchezcarlosjr

🏛️
Studying computer science
View GitHub Profile
@DmitrySoshnikov
DmitrySoshnikov / infix-to-postfix-regexp.js
Created September 24, 2011 20:14
Infix to postfix notation RegExp converter
/**
* Infix to postfix notation RegExp converter
*
* To implement RegExp machine (NFA, DFA) we need
* to transform first RegExp string to postfix notation
* for more convinient work with the stack. This function
* does exactly this.
*
* See: http://swtch.com/~rsc/regexp/regexp1.html
*
int64_t ipow(int64_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1
@jhjin
jhjin / fastexp.cpp
Created December 13, 2016 22:14
A Fast, Compact Approximation of the Exponential Function (double precision)
// A Fast, Compact Approximation of the Exponential Function
// http://www.schraudolph.org/pubs/Schraudolph99.pdf
inline double fast_exp(double y) {
double d;
*(reinterpret_cast<int*>(&d) + 0) = 0;
*(reinterpret_cast<int*>(&d) + 1) = static_cast<int>(1512775 * y + 1072632447);
return d;
}
@reoring
reoring / gist:3ff898c90a81073ea37b96e0fef8746b
Last active October 25, 2022 02:50
docker-compose.yml for php and postgresql

html/index.php

<?php

phpinfo();

docker/Dockerfile

@asukakenji
asukakenji / 0-go-os-arch.md
Last active July 24, 2024 05:41
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@yjxiong
yjxiong / pnp.py
Last active February 3, 2024 03:32
SolvePnP for Head Pose Estimation
"""
Light weight head pose estimation with SolvePnP
Author: Yuanjun Xiong
"""
# parameters
fx = 1
# model points
@qpwo
qpwo / monte_carlo_tree_search.py
Last active July 22, 2024 09:10
Monte Carlo tree search (MCTS) minimal implementation in Python 3, with a tic-tac-toe example gameplay
"""
A minimal implementation of Monte Carlo tree search (MCTS) in Python 3
Luke Harold Miles, July 2019, Public Domain Dedication
See also https://en.wikipedia.org/wiki/Monte_Carlo_tree_search
https://gist.github.com/qpwo/c538c6f73727e254fdc7fab81024f6e1
"""
from abc import ABC, abstractmethod
from collections import defaultdict
import math
@corentinbettiol
corentinbettiol / zsh-agnoster.md
Last active January 22, 2022 23:42
Install agnoster theme in zsh in docker from vscode console.
  1. Install the fonts on your computer:

    git clone https://github.com/powerline/fonts.git
    cd fonts
    ./install.sh
    cd .. && rm -rf fonts
  2. Then, open the settings (ctrl+p > "settings json" > enter) in vscode.

import cv2
import mediapipe as mp
import numpy as np
mp_face_mesh = mp.solutions.face_mesh
face_mesh = mp_face_mesh.FaceMesh(min_detection_confidence=0.5, min_tracking_confidence=0.5)
cap = cv2.VideoCapture(0)
while cap.isOpened():
success, image = cap.read()
@hbruch
hbruch / postgis_geopandas_io_manager.py
Last active June 24, 2024 09:40
Dagster PostGIS GeoPandas IO Manager
# Copyright 2023 Holger Bruch (hb@mfdz.de)
#
# 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
#
# https://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,