Skip to content

Instantly share code, notes, and snippets.

View dalcib's full-sized avatar

Dalci de Jesus Bagolin dalcib

View GitHub Profile
@dalcib
dalcib / MdxContent.js
Created August 17, 2022 13:08 — forked from danieldunderfelt/MdxContent.js
MDX in React-native
// Use your MDX content with this component.
import React from 'react'
import MDX from '@mdx-js/runtime'
import components from '../utils/markdown/markdown'
// Renders a cimple loading spinner as a test
import Loading from './Loading'
const mdxComponents = {
const fs = require("fs");
const bundle = fs.readFileSync("path-to-webpack-bundle.html", "utf8");
const escaped = JSON.stringify(bundle);
const js = `export default ${escaped}`;
fs.writeFileSync("javascript-output-file.ts", js);
@dalcib
dalcib / .block
Created May 1, 2020 18:28 — forked from ganeshv/.block
Zoomable Treemap Template
license: gpl-3.0
@dalcib
dalcib / expo-firestore-persistence-hack.js
Created April 20, 2020 11:17 — forked from zwily/expo-firestore-persistence-hack.js
A fragile weaving of various modules together to convince the Firestore web SDK to use persistence in an un-ejected Expo app.
/*
expo-firestore-persistence-hack
A fragile weaving of various modules together to convince the Firestore
web SDK to use persistence in an un-ejected Expo app.
To use, first:
```
$ expo install expo-sqlite
@dalcib
dalcib / Counter.js
Created October 14, 2019 11:02 — forked from tannerlinsley/Counter.js
Global React State with Context and Immer
import { useCount, useIncrement, useDecrement } from './store.Count'
export default function Counter () {
const count = useCount()
const increment = useIncrement()
const decrement = useDecrement()
return (
<div>
<div>Count: {count}</div>
@dalcib
dalcib / gather.ts
Last active October 15, 2019 11:05 — forked from eenblam/gather-final.js
Naive JS implementation of tidyr's gather function. Intended for use with JSON-styled tabular data... like you'd get from d3.dsv
function withFields<S>(record: S, fields: (keyof S)[]) {
// Returns record with only properties specified in fields
return fields.reduce((acc: Partial<S>, key) => {
acc[key] = record[key]
return acc
}, {})
}
function splitRecord<S extends object>(record: S, ...fields: Array<keyof S>) {
let withGivenFields = withFields(record, fields)
@dalcib
dalcib / index.d.ts
Created June 22, 2017 13:10 — forked from pierre-H/index.d.ts
Expo TypeScript Definitions
declare module 'Expo' {
import { EventSubscription } from 'fbemitter';
import { Component } from 'react';
import { ViewStyle, ViewProperties, ColorPropType } from 'react-native';
/**
* Expo Accelerometer
*/
export namespace Accelerometer {
// TODO: good export type of x, y and z
@dalcib
dalcib / jsonSchemaInterface.ts
Created July 11, 2016 18:31 — forked from enriched/jsonSchemaInterface.ts
TypeScript interface for Json-Schema V4
/**
* MIT License
*
* Copyright (c) 2016 Richard Adams (https://github.com/enriched)
*
* 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
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');