Skip to content

Instantly share code, notes, and snippets.

View lenilsondc's full-sized avatar

Lenilson de Castro lenilsondc

  • Méliuz
  • Brazil
View GitHub Profile
@lenilsondc
lenilsondc / .styled.tsx
Last active October 18, 2021 23:03
React Native typescript styled HOC
// Similar-ish to styled-components' interface but no theming and this one uses
// js to create style. It styles any component with a style property that matches
// StyleProp from react native and provides intelisense to the styles available
// on that particular component.
import React, { ComponentType } from 'react';
import { StyleProp } from 'react-native';
type StyleableProp = { style?: StyleProp<unknown> };
export function styled<P extends StyleableProp>(
@lenilsondc
lenilsondc / ion-safe-area-iphone-x.scss
Created September 2, 2020 15:03
Ionic to force iPhone X safe area insets for preview and screenshot
:root {
--ion-safe-area-top: 44px;
--ion-safe-area-bottom: 34px;
}
@lenilsondc
lenilsondc / profiles.json
Created April 13, 2020 11:00
GitBash for Windows Terminal
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{45a84344-802a-4122-840d-89db0ae8d015}",
"profiles":
{
"defaults":
{
},
"list":
[
@lenilsondc
lenilsondc / linked-list.ts
Created February 5, 2020 01:47
Simple generic LinkedList implementation in Typescript
export class LinkedList<T> implements Iterable<T> {
public first: LinkedListNode<T> = null;
public get isEmpty(): boolean {
return this.first === null;
}
public push(item: T): void {
this.first = new LinkedListNode<T>(item, this.first);
}
@lenilsondc
lenilsondc / binary-search-test.js
Created February 3, 2020 16:22
Javascript binary search example
function binarySearch(input, target) {
let x0 = 0;
let x1 = input.length - 1;
while (x0 <= x1) {
let x = Math.round(x0 + (x1 - x0) / 2);
if (target < input[x]) {
x1 = x - 1;
} else if (target > input[x]) {
@lenilsondc
lenilsondc / merge-sort-test.js
Created January 29, 2020 17:27
Testing merge sort implementation in javascript
function sort(input) {
if (input.length < 2) {
return input;
}
const q = parseInt(input.length / 2);
const a = input.slice(0, q);
const b = input.slice(q, input.length);
// Testing fibonacci different implementations
/*
F(n) = {
n = 0 : 1,
n = 1 : 1,
n > 1 : F(n-1) + F(n-2)
}
*/
function fib_full_recursive(n) {
@lenilsondc
lenilsondc / css-animated-gradient-background.css
Created September 26, 2019 11:04
CSS animated gradient background
body {
background-image: linear-gradient(45deg, #64b5f6, #ba68c8);
/* add room for animating the background position */
background-size: 200%;
background-position: right;
height: 100vh;
animation: bganim 20s infinite;
}