Skip to content

Instantly share code, notes, and snippets.

View codegino's full-sized avatar

Carlo Gino Catapang codegino

View GitHub Profile
@codegino
codegino / MainActivity.java
Last active June 1, 2018 13:59
React Native MainApplication for android to enable react-native-navigation
package com.sampleapp;
import com.reactnativenavigation.controllers.SplashActivity;
public class MainActivity extends SplashActivity {
}
@codegino
codegino / .babelrc
Last active June 1, 2018 11:55
React native configs
{
"presets": [
"babel-preset-react-native-stage-0/decorator-support",
"flow",
"react-native"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
let assert = require("chai").assert;
const {
getAmountByCategoryInPeriod
} = require('./transaction-test-1.js');
const CATEGORIES = {
GROCERIES: 'groceries',
EATING_OUT: 'eating_out',
OTHER: 'other',
SALARY: 'salary',
@codegino
codegino / app-promises-problematic.js
Last active September 18, 2018 13:16
Async Await Example
const users = [{
id: 1,
name: 'Carlo',
schoolId: 101
},{
id: 2,
name: 'Gino',
schoolId: 123
}];
@codegino
codegino / async.js
Last active September 19, 2018 07:16
Advanced NodeJS
const https = require('https');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
const start = Date.now();
function doRequest() {
https.request('https://www.google.com', res => {
res.on('data', () => {})
res.on('end', () => {
const css: any = [];
for (let i = 0; i < document.styleSheets.length; i += 1) {
try {
const sheet: any = document.styleSheets[i];
const rules = ('cssRules' in sheet) ? sheet.cssRules : sheet.rules;
for (let j = 0; j < rules.length; j += 1) {
const rule: any = rules[j];
if ('cssText' in rule) { css.push(rule.cssText); } else { css.push(`${rule.selectorText} {\n${rule.style.cssText}\n}\n`); }
}
@codegino
codegino / BlurringImage-emotion.jsx
Last active June 29, 2022 14:20
Blurring Image
import React, {useState} from 'react';
import styled from '@emotion/styled';
import Image from 'next/image';
export function BlurringImage({
svg: [Svg, svgProps, rectangles],
img,
alt,
style,
blurLevel = 5,
@codegino
codegino / CustomImage.jsx
Last active November 17, 2021 09:58
Next Image with placeholder and error handler
function CustomImage({...props}: ImageProps) {
const [src, setSrc] = React.useState(props.src);
return (
<Image
onError={() => setSrc('/assets/image-error.png')}
placeholder="blur"
blurDataURL="/assets/image-placeholder.png"
{...props}
src={src}
@codegino
codegino / root.tsx
Created November 24, 2021 12:18
Remix Document Boilerplate
import {Links,LiveReload,Meta,Outlet,Scripts,ScrollRestoration} from "remix";
export default function App() {
return (
<Document>
<Layout>
<Outlet />
</Layout>
</Document>
);
@codegino
codegino / Button.test.tsx
Created November 30, 2021 09:22
Testing Improvement
import {render,fireEvent} from './custom-rtl'
describe('Outlined Button', (): void => {
test('Size of button should render correctly for variant outlined', (): void => {
const { container } = render(
<ButtonOutlined color="grey">
<SvgClose /> Text does not matter
</ButtonOutlined>
);