Skip to content

Instantly share code, notes, and snippets.

View guyb7's full-sized avatar

Guy Bloom guyb7

View GitHub Profile
//@version=5
indicator("", "", true)
var string[] buys = array.from("2021-12-13","2021-12-03","2021-12-02","2021-11-22","2021-11-15","2021-11-08","2021-11-08","2021-02-26","2021-01-25","2021-01-22","2020-10-30","2020-10-29","2020-10-26","2020-09-25","2020-08-18")
var string[] sells = array.from("2022-10-05","2021-10-25","2021-08-31","2021-01-13")
bar_date = str.format_time(time, "yyyy-MM-dd", syminfo.timezone)
plotchar(array.includes(buys, bar_date), "Buy", "B", location.belowbar, color = color.green, size = size.small)
@guyb7
guyb7 / Spinner.js
Created December 12, 2020 21:30
Simple react spinner with styled components
import styled, { keyframes } from 'styled-components'
const rotate = keyframes`
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
`
@guyb7
guyb7 / express-promises-middleware.js
Created December 5, 2017 14:03
A wrapper around Express middlewares to support promises
const asyncMiddleware = promise => {
return (req, res) => {
promise(req)
.then(data => {
res.status(200).json({
success: true,
...data
})
})
.catch(e => {
@guyb7
guyb7 / triggerClick.js
Created November 23, 2017 09:45
Trigger click, mousedown or other MouseEvents in JavaScript
/*
Common MouseEvents:
mousedown
mouseenter
mouseleave
mousemove
mouseout
mouseover
mouseup
*/
@guyb7
guyb7 / pearson_correlation_coefficient
Created August 27, 2014 17:37
PHP implementation of Pearson's product-moment correlation coefficient
<?php
// PHP implementation of Pearson's product-moment correlation coefficient
function corr($a, $b) {
$sum_ab = 0;
$sum_a = 0;
$sum_b = 0;
$sum_a_sqr = 0;
$sum_b_sqr = 0;
$n = min(array(count($a), count($b)));
for ($i = 0; $i < $n; $i++) {