This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Barrier { | |
constructor() { | |
this.time = 0 | |
this.state = 0 | |
} | |
start() { | |
return ++this.time | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec4 world() { | |
vec4 ndc = vec4( | |
2.0 * (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw - 1.0, | |
(czm_readDepth(depthTexture, v_textureCoordinates) - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2], | |
1.0); | |
vec4 eye = czm_inverseProjection * ndc; | |
return czm_inverseView * eye; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
class printer: | |
def __init__(self, *args): | |
self.args = args | |
def __enter__(self): | |
self.f = open(*self.args) | |
return partial(print, file=self.f) | |
def __exit__(self, *args): | |
self.f.__exit__(*args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import cv2 | |
import numpy | |
import pyautogui | |
# usage: | |
# after launch, a shot from the camera appears. | |
# mark four corners of the projector by clicking in order: top left, bottom left, bottom right, top right | |
# the program moves mouse when it sees the laser pointer on-screen | |
# the program never exits (you have to kill it) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import cv2 as cv | |
import dlib | |
from threading import Thread | |
import time | |
pose_model = dlib.shape_predictor("/usr/share/dlib/shape_predictor_68_face_landmarks.dat") | |
detector = dlib.get_frontal_face_detector() | |
def camera(source): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>X3D Viewer</title> | |
<script type='text/javascript' src='http://www.x3dom.org/download/x3dom.js'> </script> | |
<style> | |
canvas { | |
border: 1px solid gray; | |
} | |
</style> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tryIndent(event) { | |
if (event.code != "Tab") { | |
return; | |
} | |
event.preventDefault(); | |
var text = event.target; | |
var start = Math.max(text.value.lastIndexOf("\n", text.selectionStart - 1), 0); | |
var end = text.selectionEnd; | |
var str = text.value.slice(start, end); | |
var origLength = str.length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sstream> | |
#include <fstream> | |
#include <iostream> | |
#include <array> | |
class Buffer : public std::streambuf { | |
// we use ifstream here only for the sake of example | |
std::ifstream file; | |
std::array<char, 1024> data; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import asyncio | |
import asyncpg | |
from time import time | |
try: | |
import uvloop | |
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) | |
except: | |
pass # it will just be slower, no harm done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename It, typename OutIt, typename UnaryPredicate> | |
It move_if(It begin, It end, OutIt dst, UnaryPredicate pred) | |
{ | |
It last = end; | |
while (begin != last) { | |
if (pred(*begin)) { | |
*dst++ = std::move(*begin); | |
std::swap(*begin, *(--last)); | |
} else { | |
++begin; |