-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from devgraduan/master
Various Update
- Loading branch information
Showing
19 changed files
with
452 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Sign in with Apple | ||
|
||
[What the Heck is Sign In with Apple?](https://developer.okta.com/blog/2019/06/04/what-the-heck-is-sign-in-with-apple) | ||
|
||
## Go to Apple Developer Portal https://developer.apple.com/ | ||
|
||
### Create App ID | ||
|
||
Set Bundler ID - follow apple convention reverse dns styling. For com.example | ||
|
||
Enabled Sign in with Apple capabilities. | ||
|
||
### Create Service ID | ||
|
||
Ensure Sign in with Apple is enabled and configured | ||
|
||
#### Sign in with Apple Configuration | ||
|
||
Choose Primary App ID | ||
|
||
Configure Website URLs - Apple doesn't support localhost | ||
|
||
After finish, you will get `client_id`. Store `client_id` for later use. | ||
|
||
### Private Key | ||
|
||
In Apple Developer dashboard page, go to `Keys`. | ||
|
||
Enable Sign in with Apple | ||
|
||
Configure Sign in with Apple | ||
|
||
After finish, download key and save it safely, you won't be able to redownload this key anymore. Also store `key_id` for later use. | ||
|
||
## Generate Client Secret | ||
|
||
We're using Ruby scripts to generate client secret. | ||
|
||
Install JWT - `gem install jwt` | ||
|
||
Create `client_secret.rb` or any name you preferred. | ||
|
||
```rb | ||
|
||
require 'jwt' | ||
|
||
key_file = 'key.txt' | ||
team_id = '' | ||
client_id = '' | ||
key_id = '' | ||
|
||
ecdsa_key = OpenSSL::PKey::EC.new IO.read key_file | ||
|
||
headers = { | ||
'kid' => key_id | ||
} | ||
|
||
claims = { | ||
'iss' => team_id, | ||
'iat' => Time.now.to_i, | ||
'exp' => Time.now.to_i + 86400*180, | ||
'aud' => 'https://appleid.apple.com', | ||
'sub' => client_id, | ||
} | ||
|
||
token = JWT.encode claims, ecdsa_key, 'ES256', headers | ||
|
||
puts token | ||
|
||
``` | ||
|
||
Execute `client_secret.db` - `ruby client_secret.rb` | ||
|
||
## Integrate with Laravel | ||
|
||
https://socialiteproviders.com/Apple/#installation-basic-usage | ||
|
||
https://bannister.me/blog/generating-a-client-secret-for-sign-in-with-apple-on-each-request | ||
|
||
## Sending email to private Apple email | ||
|
||
When user sign in to your site using Sign In With Apple. They may choose to hide their email using private Apple email. | ||
|
||
This private Apple email will blocked all unauthorized sender. | ||
|
||
To allow our transactional mail service (such as Mailgun) to send email to our users, we need to add our domain, subdomain and email address into "Sign in with Apple for Email Communication". | ||
|
||
Sign in to Apple Developer page, [https://developer.apple.com](https://developer.apple.com). | ||
|
||
Go to Services, [https://developer.apple.com/account/resources/services/list](https://developer.apple.com/account/resources/services/list). | ||
|
||
In the section "Sign in with Apple for Email Communication", click configure button. | ||
|
||
Inside Configuration page, add domain, subdomain and email address in Email Sources section. | ||
|
||
Reference: | ||
|
||
[https://medium.com/@nmpyt21/mandrill-send-to-apple-private-email-e7514f74d8be](Mandrill Send to Apple Private Email) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,14 @@ example | |
|
||
## Option is removed | ||
|
||
[Read more here](https://github.com/Homebrew/homebrew-core/issues/31510) | ||
[Read more here](https://github.com/Homebrew/homebrew-core/issues/31510) | ||
|
||
## Issues | ||
|
||
### You should find replacements for the following formulae: ilmbase [email protected] | ||
|
||
`brew uses --installed ilmbase` | ||
|
||
`brew uninstall ilmbase` | ||
|
||
[https://apple.stackexchange.com/a/435422](https://apple.stackexchange.com/a/435422) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,30 @@ After each upgrade, need to reinstall all Php extension manually and update thei | |
|
||
https://stackoverflow.com/a/51584213 | ||
|
||
## Common Issues | ||
|
||
### dyld: Library not loaded: /usr/local/opt/icu4c/lib | ||
|
||
[https://stackoverflow.com/a/54873233](https://stackoverflow.com/a/54873233) | ||
|
||
``` | ||
brew upgrade icu4c | ||
brew upgrade // or upgrade all packages | ||
brew cleanup | ||
``` | ||
|
||
## Error: [email protected] has been disabled because it is a versioned formula! | ||
|
||
``` | ||
brew tap shivammathur/php | ||
brew install shivammathur/php/[email protected] | ||
brew link [email protected] | ||
``` | ||
|
||
[https://stackoverflow.com/a/74856087](https://stackoverflow.com/a/74856087) | ||
|
||
## References | ||
|
||
* [Php Redis](https://github.com/phpredis/phpredis) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Caddy | ||
|
||
## Cloudflare | ||
|
||
Ensure SSL/TLS encryption is set to full mode | ||
|
||
## Install | ||
|
||
https://caddyserver.com/docs/install#debian-ubuntu-raspbian | ||
|
||
After installation, run `caddy stop`. This is to ensure there is no port is in use. | ||
|
||
## Caddyfile | ||
|
||
Most of my project is Laravel and it is much easier to use Caddyfile to store all neccessary configuration. | ||
|
||
```Caddyfile | ||
my-website.com { | ||
# Resolve the root directory for the app | ||
root * /var/www/my-website/public | ||
# Provide Zstd and Gzip compression | ||
encode zstd gzip | ||
# Allow caddy to serve static files | ||
file_server | ||
# Enable PHP-FPM | ||
php_fastcgi unix//run/php/php7.4-fpm.sock | ||
} | ||
``` | ||
|
||
## References | ||
|
||
https://ohdear.app/news-and-updates/how-we-used-caddy-and-laravels-subdomain-routing-to-serve-our-status-pages | ||
|
||
https://laravel-news.com/unlimited-custom-domains-vapor | ||
|
||
https://caddyserver.com/docs/caddyfile-tutorial | ||
|
||
https://jorgeglz.io/blog/setting-up-laravel-applications-with-caddy-2/ | ||
|
||
https://caddy.community/t/serving-tens-of-thousands-of-domains-over-https-with-caddy/11179 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Spaces | ||
|
||
## Issues | ||
|
||
### Slow response time for small file | ||
|
||
### High probability slow response to serve video file | ||
|
||
### High probability slow upload for file less than 1mb and large than 500mb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Prettier | ||
|
||
Prettier is a opinionated code style fixer for minimalists. It support html, js, css, json and etc. It doesn't support php. | ||
|
||
## Installation | ||
|
||
`yarn add --dev --exact prettier` | ||
|
||
### Config | ||
|
||
create config file | ||
|
||
`node --eval "fs.writeFileSync('.prettierrc','{}\n')"` | ||
|
||
### Ignore | ||
|
||
We may exclude any folders in our project to prevent Prettier to run on them. | ||
|
||
`nano .prettierignore` | ||
|
||
Prettier ignore node_modules folder by default. | ||
|
||
## Blade Support | ||
|
||
Blade file is not supported by Prettier by default. We need to install additional plugin to allow Prettier to support blade. | ||
|
||
`yarn add --dev @shufo/prettier-plugin-blade` | ||
|
||
then inside Prettier config file, we need to update it: | ||
|
||
`nano .prettierrc` | ||
|
||
```json | ||
{ | ||
"plugins": ["@shufo/prettier-plugin-blade", "prettier-plugin-tailwindcss"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.blade.php"], | ||
"options": { | ||
"parser": "blade", | ||
"tabWidth": 1 | ||
} | ||
} | ||
] | ||
} | ||
|
||
``` | ||
|
||
## Usage | ||
|
||
`yarn prettier --write .` | ||
|
||
If blade plugin is installed, we need to change the command: | ||
|
||
`yarn prettier --write resources/**/*.blade.php .` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Read Me | ||
|
||
## ES6 | ||
|
||
http://es6-features.org/#Constants | ||
|
||
## Build Tools | ||
|
||
https://esbuild.github.io/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Handling invalid utf8 | ||
|
||
An URL with an invalid UTF-8 parameter would be one where a parameter in the URL's query string contains a character that is not valid UTF-8 encoding. | ||
|
||
Here is an example of an URL with an invalid UTF-8 parameter: | ||
|
||
`http://www.example.com/search?q=invalid%C3%28UTF%29` | ||
|
||
In this example, the %C3%28 and %29 sequences in the query string parameter q are not valid UTF-8 characters, and therefore, the entire parameter is considered invalid UTF-8. When processing URLs with query string parameters, it's important to ensure that all parameters are valid UTF-8 to avoid potential security or compatibility issues. | ||
|
||
Laravel validation may allow utf8 to slip in, this may cause unexpected error when we parsing json or when we're running SQL. To avoid this bug we may fix encoding with this plugin: | ||
|
||
`https://doc.nette.org/en/utils/strings#toc-fixencoding` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Issues | ||
|
||
## count Slow | ||
|
||
This can be seen when your query is using pagination. | ||
|
||
pagination is slow because it count result for pagination. It will be much worse if inside your query contain whereHas. This is because whereHas is subQuery, and subQuery is slow by nature. | ||
|
||
## whereHas Slow | ||
|
||
need to replace with join instead | ||
|
||
## Mysql Date Slow | ||
|
||
* [MySQL performance problem using indexed datetime column](https://dba.stackexchange.com/questions/73598/mysql-performance-problem-using-indexed-datetime-column) | ||
* [DATE() MONTH() etc. functions slow down query](https://stackoverflow.com/questions/37777883/date-month-etc-functions-slow-down-query/37777987) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Laravel Pint | ||
|
||
Laravel Pint is an opinionated PHP code style fixer for minimalists. Pint is built on top of PHP-CS-Fixer and makes it simple to ensure that your code style stays clean and consistent. | ||
|
||
## Installation | ||
|
||
`composer require laravel/pint --dev` | ||
|
||
## Usage | ||
|
||
`./vendor/bin/pint` - run pint for the whole project | ||
|
||
`./vendor/bin/pint sample.php` - run pint for single php file | ||
|
||
`./vendor/bin/pint -v` - run pint in verbose mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.