Skip to content

Instantly share code, notes, and snippets.

View fael's full-sized avatar

Rafael Santos Sá fael

  • OLX
  • Lisbon, Portugal
View GitHub Profile
@basnijholt
basnijholt / cto_line.pine
Created September 18, 2021 08:23
CTO Line indicator for TradingView
//@version=4
study(title="CTO Line", shorttitle="CTO", overlay=true, resolution="")
smma(src, length) =>
smma = 0.0
smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length
smma
v1 = smma(hl2, 15)
m1 = smma(hl2, 19)
m2 = smma(hl2, 25)
v2 = smma(hl2, 29)
@edygar
edygar / move.ts
Last active October 30, 2020 09:09
Move files to their kebab-version
import * as path from "https://deno.land/[email protected]/path/mod.ts";
import * as fs from "https://deno.land/[email protected]/fs/mod.ts";
import { paramCase } from "https://deno.land/x/[email protected]/mod.ts";
const cwd = Deno.cwd();
// Files to be excluded during the walk
const skip = (await Deno.readTextFile(path.join(cwd, ".gitignore")))
.replace(/#.*/g, "")
.replace(/\s*\n/g, "\n")
import { useState, useMemo, useEffect } from "react";
import { interpret } from "xstate/lib/interpreter";
export default function useMachine(machine, { log = false } = {}) {
const [current, setCurrent] = useState(machine.initialState);
const service = useMemo(() => interpret(machine), []);
useEffect(() => {
service.onTransition(setCurrent).start();
export class MyComponent extends React.Component {
componentWillMount() {
const styleid = 'MyComponentStyles'
if (document.head.querySelector(`#${styleid}`) !== null) {
const styles = document.createElement('style');
styles.id = styleid;
styles.append('[foo]{ color: blue; }');
document.head.appendChild(styles);
}
}
@threepointone
threepointone / 0 basics.md
Last active March 21, 2023 01:53
css-in-js

A series of posts on css-in-js

0. styles as objects

First, an exercise. Can we represent all of css with plain data? Let's try.

let redText = { color: 'red' };
@sompylasar
sompylasar / ReduxClockProvider.js
Created December 8, 2017 23:43
Pure clock state with React, Redux, Redux-Saga. Do not use `Date.now()` or `new Date()` or `moment()` in `render()`, reading the current clock state is not pure (returns different values on each call). https://twitter.com/acdlite/status/939260579247562752
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
extractClockTimestamp,
} from './reduxClockReducer';
import {
ACTION_CLOCK_SUBSCRIBE,
@fIa5h
fIa5h / AMI_NR.js
Last active April 22, 2020 17:05
Ryan & Bruce
/*
New Relic GPT ad monitoring code
//
This snippet captures PageActions containing references to Google publisher tag ads
Should you have any questions about this, please reach out to me at [email protected]
Please note that you must be using New Relic's SPA browser agent.
//
*/
//
//first, make sure the newrelic object exists properly
@wojteklu
wojteklu / clean_code.md
Last active November 18, 2024 16:37
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

From zero to microservice with 𝚫 now

The following guide will show you how to deploy a simple microservice written in JavaScript using 𝚫 now.

It uses Open Source tools that are widely available, tested and understood:

  • Node.JS
  • NPM
  • Express