This file contains 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
/** | |
* An implementation for Quicksort. Doesn't | |
* perform as well as the native Array.sort | |
* and also runs the risk of a stack overflow | |
* | |
* Tests with: | |
* | |
* var array = []; | |
* for(var i = 0; i < 20; i++) { | |
* array.push(Math.round(Math.random() * 100)); |
This file contains 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
import { useEffect, useRef } from 'react'; | |
export const useEventEmitter = (eventEmitter, eventName: string, fn: () => void) => { | |
const subscription = useRef(null); | |
useEffect(() => { | |
subscription.current = eventEmitter.addListener(eventName, fn); | |
return () => { | |
if (subscription.current) { |
This file contains 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
import qualified Data.Set as Set | |
fInput [] = [] | |
fInput (_:b:c:others) = | |
(words b, c):fInput others | |
solve' _ target [] ans | |
| target /= [] = [] | |
| otherwise = ans | |
solve' dict target (p:ps) ans = |
This file contains 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
module Bogosort where | |
import Control.Monad.Primitive | |
import Control.Monad.ST | |
import Control.Monad.ST.Unsafe | |
import Control.Monad.Trans.State.Strict | |
import Data.Monoid | |
import qualified Data.Vector as V | |
import qualified Data.Vector.Generic.Mutable as VGM | |
import Data.Vector.Generic.Mutable (MVector) |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
.scrollbox { | |
overflow: auto; | |
width: 200px; | |
max-height: 200px; | |
margin: 50px auto; |
This file contains 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 transformOrigin(matrix, origin) { | |
const { x, y, z } = origin; | |
const translate = MatrixMath.createIdentityMatrix(); | |
MatrixMath.reuseTranslate3dCommand(translate, x, y, z); | |
MatrixMath.multiplyInto(matrix, translate, matrix); | |
const untranslate = MatrixMath.createIdentityMatrix(); | |
MatrixMath.reuseTranslate3dCommand(untranslate, -x, -y, -z); | |
MatrixMath.multiplyInto(matrix, matrix, untranslate); |
This file contains 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
/******************************************************************************* | |
* Copyright 2022 Paulo Torrens * | |
* * | |
* Permission is hereby granted, free of charge, to any person obtaining a copy * | |
* of this software and associated documentation files (the "Software"), to * | |
* deal in the Software without restriction, including without limitation the * | |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * | |
* sell copies of the Software, and to permit persons to whom the Software is * | |
* furnished to do so, subject to the following conditions: * | |
* * |
This file contains 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
brew install libfaketime --build-from-source | |
# usage | |
faketime -f "@2020-01-01 00:00:00" node app.js |
This file contains 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/env python3 | |
# | |
# This is a simple script to encrypt a message using AES | |
# with CBC mode in Python 3. | |
# Before running it, you must install pycryptodome: | |
# | |
# $ python -m pip install PyCryptodome | |
# | |
# Author.: José Lopes | |
# Date...: 2019-06-14 |
This file contains 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
import okhttp3.Call | |
import okhttp3.Callback | |
import okhttp3.Response | |
import java.io.IOException | |
import java.util.concurrent.CompletableFuture | |
fun Call.executeAsync(): CompletableFuture<Response> { | |
val future = CompletableFuture<Response>() | |
enqueue(object : Callback { | |
override fun onResponse(call: Call, response: Response) { |
OlderNewer