Skip to content

Instantly share code, notes, and snippets.

View chinhnguyen's full-sized avatar
😎
Actively looking for remote contract work

Chinh Nguyen chinhnguyen

😎
Actively looking for remote contract work
View GitHub Profile
@chinhnguyen
chinhnguyen / api.ts
Created May 22, 2023 07:52
Ample Restful API example
interface Academic {
firstName: string
lastName: string
avatar: string
university: string
}
interface Question {
content: string
createdAt: Date
@chinhnguyen
chinhnguyen / single.html
Created May 21, 2023 15:08
Ample's widget iframe
<section>
<a id="ample-widget" href="https://sample.ampleviews.com/yle/index.html">Ample Commentaries</a>
<script async src="https://developers.ampleviews.com/scripts/widget.js"></script>
</section>
@chinhnguyen
chinhnguyen / ViewGroupBindingAdapters.kt
Created December 8, 2020 15:06
Disable all buttons inside ViewGroup with data binding
import android.view.ViewGroup
import android.widget.Button
import androidx.core.view.children
import androidx.databinding.BindingAdapter
@BindingAdapter("disableButtons")
fun ViewGroup.setDisableButtons(disableButtons: Boolean) {
children.forEach {
(it as? Button)?.isEnabled = !disableButtons
}
@chinhnguyen
chinhnguyen / .gitlab-ci.yml
Created January 7, 2020 09:22
gitlab deployment frontend to AWS S3 and CloudFront
image: ntr9h/node-awscli2:latest
deploy:
stage: deploy
when: manual
script:
- npm run upload
- npm run upload:post
@chinhnguyen
chinhnguyen / Dockerfile
Created January 7, 2020 08:48
Docker image for node:12.13.1 and awscli2
FROM node:12.13.1
LABEL maintainer="[email protected]"
LABEL nodeVersion="12.13.1"
LABEL awscliVersion="2.0.0"
LABEL version="1.0.0"
# https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux-mac.html
RUN curl "https://d1vvhvl2y92vvt.cloudfront.net/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN ./aws/install
{
"scripts": {
"upload": "aws2 s3 sync dist/ s3://yourpackage",
"upload:post": "aws2 cloudfront create-invalidation --distribution-id your-distribution-id --paths '/*'",
}
}
@chinhnguyen
chinhnguyen / .gitlab-ci.yml
Last active December 29, 2019 15:17
Programmatically create a version/release on JIRA upon creation of a SemVer tag on git
image: node:12
create_jira_version:
stage: post-deploy
only:
- tags
- /^(\d+\.)?(\d+\.)?(\*|\d+)$/
variables:
VERSION: $CI_BUILD_TAG
USER: $JIRA_USER:$JIRA_TOKEN
@chinhnguyen
chinhnguyen / muiStoriesOf.js
Last active October 5, 2019 13:10
Override storybook add to make it work with material UI
import React from 'react';
import { storiesOf as storybookStoriesOf } from '@storybook/react';
import { StylesProvider } from '@material-ui/styles';
const generateClassName = (rule, styleSheet) => `${styleSheet.options.classNamePrefix}-${rule.key}`;
// Putting material-ui to work with jest snapshot is having a style name issue as described here https://github.com/mui-org/material-ui/issues/9492
// This small gist override the storiesOf default from @storybook/react with wrapper for StylesProvide
// Later when the original storiesOf works, we can just replace this with the original version
@chinhnguyen
chinhnguyen / muiStoriesOf.js
Created October 5, 2019 13:07
Override storybook add to make it work with material UI
import React from 'react';
import { storiesOf as storybookStoriesOf } from '@storybook/react';
import { StylesProvider } from '@material-ui/styles';
const generateClassName = (rule, styleSheet) => `${styleSheet.options.classNamePrefix}-${rule.key}`;
export default function storiesOf(kind, module) {
let stories = storybookStoriesOf(kind, module)
let _add = stories.add
//add: (storyName: string, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>;
@chinhnguyen
chinhnguyen / muiStoriesOf.js
Created October 5, 2019 13:07
Override storybook add to make it work with material UI
import React from 'react';
import { storiesOf as storybookStoriesOf } from '@storybook/react';
import { StylesProvider } from '@material-ui/styles';
const generateClassName = (rule, styleSheet) => `${styleSheet.options.classNamePrefix}-${rule.key}`;
export default function storiesOf(kind, module) {
let stories = storybookStoriesOf(kind, module)
let _add = stories.add
//add: (storyName: string, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>;