Skip to content

Instantly share code, notes, and snippets.

View arthurdenner's full-sized avatar
🤓
Always trying to improve my skills and knowledge to apply them everywhere.

Arthur Denner arthurdenner

🤓
Always trying to improve my skills and knowledge to apply them everywhere.
View GitHub Profile
@arthurdenner
arthurdenner / ferramentas-de-compilacao.md
Created February 3, 2022 15:54
Ferramentas de compilação

O browser entende JavaScript, mas browsers diferentes além de versões diferentes de cada browser suportam features diferentes do JavaScript.

Para verificar o nível de suporte de uma feature, normalmente usamos o site caniuse.com. Por exemplo, suporte para Array.prototype.map é bem grande enquanto suporte para Native Filesystem API é pequeno ainda.

Além disso, com bibliotecas como React e Vue, a gente escreve código que o browser não entende nativamente. E se adicionarmos TypeScript no meio, daí que complica mesmo, porque o browser não sabe interpretá-lo.

Para suportar os casos acima e outros mais, normalmente usamos ferramentas de compilação ou transpilação. Muitas vezes falamos de compilação quando estamos falando de transpilação, então não precisa focar na diferença, mas existe.

@arthurdenner
arthurdenner / parse-cloudinary.js
Created November 25, 2021 14:44
Parse Cloudinary URL with options
const parseCloudinaryUrl = (url) => {
const [apiKey, apiSecret, cloudName, options] = url
.split(/cloudinary:\/\/(\w+):(\w+)@(\w+)\??(.*)/)
.filter(Boolean)
return {
apiKey,
apiSecret,
cloudName,
options: Object.fromEntries(new URLSearchParams(options)),
@arthurdenner
arthurdenner / spin-the-wheel.html
Created September 10, 2021 08:05
Spin the wheel in Confluence
<style type="text/css">
text {
font-family: Helvetica, Arial, sans-serif;
font-size: 18px;
pointer-events: none;
}
#chart {
//position:absolute;
width: 500px;
height: 500px;
// Place the code below in the file below to reproduce it:
// https://github.com/remotion-dev/remotion/blob/main/packages/example/src/RemoteVideo/index.tsx
import {useRef} from 'react';
import {interpolate, useCurrentFrame, Video} from 'remotion';
const RemoteVideo: React.FC = () => {
const frame = useCurrentFrame();
const ref = useRef<HTMLVideoElement>(null);
return (
@arthurdenner
arthurdenner / fs-promises-proxy.js
Last active May 8, 2021 14:22
Intercepting fs.promises methods to customize behaviour at runtime with Proxies
// Original source code: https://github.com/ErickWendel/securing-files-using-nodejs-crypto-yt
// Proxy documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
// app.js
// `promises` is now a param instead of an import
async function run(promises) {
...
}
// index.js
@arthurdenner
arthurdenner / custom-matchers.ts
Last active May 20, 2020 12:13
Jest custom `toMatch` with string normalization
import { matcherHint, printReceived, printExpected } from 'jest-matcher-utils';
const matches = (received: string, expected: string | RegExp) =>
typeof expected === 'string'
? received.includes(expected)
: expected.test(received);
const normalize = (text: string) => text.replace(/\s+/g, ' ').trim();
expect.extend({
import 'package:flutter/material.dart';
class BasicAppBarSample extends StatefulWidget {
@override
_BasicAppBarSampleState createState() => _BasicAppBarSampleState();
}
class _BasicAppBarSampleState extends State<BasicAppBarSample> {
Choice _selectedChoice = choices[0];
@arthurdenner
arthurdenner / expansion_tile_sample.dart
Last active February 27, 2020 18:23
Custom version of expansion_tile_sample example from Flutter repo
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math';
import 'package:flutter/material.dart';
class ExpansionTileSample extends StatelessWidget {
@override
Widget build(BuildContext context) {
@arthurdenner
arthurdenner / generate-ios.sh
Last active January 3, 2020 17:21 — forked from monmonja/generate-ios.sh
generate ios from command line
# download this file to your project folder and excute
# chmod +x generate-ios.sh
# then run using
# ./generate-ios.sh
# flutter build defaults to --release
flutter build ios --no-codesign
# make folder, add .app then zip it and rename it to .ipa
mkdir -p Payload
@arthurdenner
arthurdenner / get-dependencies-list-yarn.js
Created November 5, 2019 15:51
Gist to get the commands to update your dependencies and devDependencies with yarn
const { dependencies, devDependencies } = require('./package.json');
const depKeys = Object.keys(dependencies).join(' ');
const devDepKeys = Object.keys(devDependencies).join(' ');
const depInstall = `yarn add ${depKeys}`;
const devDepInstall = `yarn add -D ${devDepKeys}`;
console.log(depInstall);
console.log('');