Skip to content

Instantly share code, notes, and snippets.

View phatnguyenuit's full-sized avatar
💪
Working on ReactJS and TypeScript.

Phát Nguyễn (Fast) phatnguyenuit

💪
Working on ReactJS and TypeScript.
View GitHub Profile
@aleksejkozin
aleksejkozin / app.js
Created November 13, 2021 18:45
app.js
const {Pool} = require('pg')
const express = require('express')
const {auth, requiresAuth} = require('express-openid-connect')
const app = express()
// Enable OIDC support
// To login into the app use cirnotoss@gmail.com/Lol2021
app.use(
auth({
@phatnguyenuit
phatnguyenuit / compose.js
Last active September 16, 2020 02:24
JavaScript composition
/**
* Compose a list of function from right to left
* @param {...Function} funcs
*/
const compose = (...funcs) => {
return funcs.reduceRight((prevFunc, currentFunc) => (...args) => {
const params = prevFunc.apply(null, args);
return currentFunc.apply(null, Array.isArray(params) ? params : [params]);
});
};
@phatnguyenuit
phatnguyenuit / faker.ts
Last active May 5, 2020 07:27
Typescript Code Snippets
const asyncTask = (fakeResponse: object, ms: number) =>
new Promise(resolve => setTimeout(() => resolve(fakeResponse), ms));
const faker = async (data?: BaseRequestConfig) => {
const {
params: { page = 0, pageSize = 10 },
} = data || {};
const response: BaseResponse<SmsRequestListingData> = {
code: 2e5,
kind: 'success',
@phatnguyenuit
phatnguyenuit / product_of_array_except_self.py
Last active April 16, 2020 02:53
30-day-leetcoding-challenges
# Product of Array Except Self
def productExceptSelf(nums):
size = len(nums)
result = [1] * size
left = 1
right = 1
for i in range(size):
result[i] *= left
result[-1-i] *= right
@phatnguyenuit
phatnguyenuit / remove_adjacent_duplicates.js
Created September 18, 2019 03:12
Recursively remove all adjacent duplicates
function remove_adjacent_duplicates(str) {
return str.replace(/(\w)\1+/g, '');
}
remove_adjacent_duplicates("geeksforgeek") //gksforgk
@xrman
xrman / gist:4468f545b169969466bceb694d742dad
Created March 12, 2019 21:47
FastStone Capture Full Serial Key
Registration Code
Name : www.xyraclius.com
Serial : OOCRYIMDMDPWRETFPSUZ
@lotusirous
lotusirous / app.py
Created January 26, 2019 12:38
Example of flask blueprint and register logging to root logger
import logging
from flask import Flask
from werkzeug.utils import find_modules, import_string
def configure_logging():
# register root logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('werkzeug').setLevel(logging.INFO)
@amad-person
amad-person / gist:f0ef85a2123a2e1fcf8052dcf09eef90
Last active August 12, 2023 17:38
Bypass CSP restrictions in create-react-app Chrome extensions

While building a React Chrome extension using the create-react-app utility (v2.x), I came across the following error on loading my unpacked extension:

Refused to execute inline script because it violates the following Content Security Policy directive: “script-src ‘self’
blob: filesystem: chrome-extension-resource:”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-
GgRxrVOKNdB4LrRsVPDSbzvfdV4UqglmviH9GoBJ5jk=’), or a nonce (‘nonce-…’) is required to enable inline execution.

Basically, this error arises as Chrome (or almost any modern browser) will not allow inline scripts to get executed. This CSP restriction resulted in the above error as the build script in create-react-app bundles the .js files in <script> tags in the <body> of index.html.

@tterb
tterb / README-badges.md
Last active July 3, 2024 13:47
A collection of README badges

Badges

License

MIT License GPLv3 License AGPL License

Version

Version GitHub Release

@hodgesmr
hodgesmr / hijacking_flask_routing_for_fun_and_profit.py
Last active June 18, 2024 15:22
Automatically register Flask routes with and without trailing slash. This way you avoid the 301 redirects and don't have to muddy up your blueprint with redundant rules.
"""Flask Blueprint sublcass that overrides `route`.
Automatically adds rules for endpoints with and without trailing slash.
"""
from flask import Blueprint, Flask
class BaseBlueprint(Blueprint):
"""The Flask Blueprint subclass."""