Skip to content

Instantly share code, notes, and snippets.

@smoothdvd
smoothdvd / index.js
Created February 5, 2022 08:51
server/bootstrap/index.js
...
const grantConfig = {
...,
'our-provider': {
// 'our-provider' configuration here
...
},
...
}
...
@smoothdvd
smoothdvd / providers.js
Last active February 5, 2022 08:47
server/services/providers.js
...
switch (provider) {
case 'our-provider': {
// 'our-provider' code here
break;
}
...
}
...
@smoothdvd
smoothdvd / index.js
Last active February 5, 2022 08:52
server/services/index.js
'use strict';
const jwt = require('@strapi/plugin-users-permissions/server/services/jwt');
const providers = require('./providers');
const user = require('@strapi/plugin-users-permissions/server/services/user');
const role = require('@strapi/plugin-users-permissions/server/services/role');
const usersPermissions = require('@strapi/plugin-users-permissions/server/services/users-permissions');
module.exports = {
jwt,
@smoothdvd
smoothdvd / index.js
Created February 5, 2022 08:38
server/bootstrap/index.js
'use strict';
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
const _ = require('lodash');
@smoothdvd
smoothdvd / index.js
Last active February 5, 2022 08:40
server/index.js
'use strict';
const register = require('@strapi/plugin-users-permissions/server/register');
const bootstrap = require('./bootstrap');
const contentTypes = require('@strapi/plugin-users-permissions/server/content-types');
const middlewares = require('@strapi/plugin-users-permissions/server/middlewares');
const services = require('./services');
const routes = require('@strapi/plugin-users-permissions/server/routes');
const controllers = require('@strapi/plugin-users-permissions/server/controllers');
const config = require('@strapi/plugin-users-permissions/server/config');
'use strict';
module.exports = require('./server');
@smoothdvd
smoothdvd / schema.json
Last active January 22, 2022 02:24
In Strapi headless CMS V4, if you want add some specific type column (such as tstzrange type PostgreSQL offered), you can code like this
{
...
"attributes": {
"effective_range": {
"type": "string",
"columnType": {
"type": "specificType",
"args": [
"tstzrange"
]
@smoothdvd
smoothdvd / Dockerfile
Created March 18, 2020 05:41
Install ca certificates in docker
FROM ubuntu
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
for image_path in TEST_IMAGE_PATHS:
image = Image.open(image_path)
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = load_image_into_numpy_array(image)
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
output_dict = run_inference_for_single_image(image_np, detection_graph)
# Visualization of the results of a detection.
@smoothdvd
smoothdvd / checkPlayServices.java
Created March 30, 2017 07:45
Check the device to make sure it has the Google Play Services APK. If it doesn't, display a dialog that allows users to download the APK from the Google Play Store or enable it in the device's system settings.
/**
* Check the device to make sure it has the Google Play Services APK. If
* it doesn't, display a dialog that allows users to download the APK from
* the Google Play Store or enable it in the device's system settings.
*/
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {