Skip to content

Instantly share code, notes, and snippets.

View RaschidJFR's full-sized avatar

Raschid J.F. Rafeally RaschidJFR

  • RaschidJFR
  • Toronto, Canada
View GitHub Profile
@RaschidJFR
RaschidJFR / lowend-preferences-config.xml
Created June 3, 2018 19:44
Ionic `configs.xml` splashscreen preferences for low-end android devices.
<!--
Some low-end android devices are too slow thus take too long to load the app,
which causes throwing error "can't load index.html".
Just add these settings after <preference name="SplashScreen" value="screen" /> in config.xml.
-->
<preference name="SplashScreenDelay" value="3000" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="loadUrlTimeoutValue" value="700000" />
<!--
@RaschidJFR
RaschidJFR / html_node_server.js
Last active July 31, 2018 19:20
Basic webserver with NodeJS and Express
#!/usr/bin/env node
// This script runs a simple server for HTML, CSS, JS files.
const publicFolder = 'www'; // Change this folder to point to your web files
const port = 8080; // Default port for web server but you can change it
// (Make sure you've installed the required dependencies)
const express = require('express');
const path = require('path');
const app = express();
@RaschidJFR
RaschidJFR / environment.dev.local.js
Last active February 6, 2019 20:17
Custom webpack config for environmental variables in Ionic v3
// Configuration for develpment build on local database
module.exports = {
ENV: Object.freeze({
prod: false,
databaseUrl: 'http://localhost:1337/*******'
})
}
@RaschidJFR
RaschidJFR / sign_apk.js
Last active April 13, 2019 23:59
Automatically sign and align apk built with Ionic v3
#!/usr/bin/env node
// ## Automatically sign and align apk ##
// Just run this script `$ node sign_apk.js`
const CONFIG_FILE_NAME = 'sign-apk.json';
const configFileStruct = {
"keystorePath": "relative/path/to/file.keystore",
"zipalignPath": "C:/Program Files (x86)/Android/android-sdk/build-tools/26.0.2/zipalign",
"apkPath": "C:/your-ionic-project-root/platforms/android/build/outputs/apk/android-release-unsigned.apk",
@RaschidJFR
RaschidJFR / tslint.json
Created August 11, 2019 23:12
My preferred Angular tslint settings
{
"rulesDirectory": [
"codelyzer"
],
"rules": {
"align": [true, "statements"],
"array-type": [true, "array"],
"deprecation": {
"severity": "warn"
},
@RaschidJFR
RaschidJFR / ftp-deploy.js
Last active August 24, 2019 02:34
Deploy to FTP/SFTP server
#!/usr/bin/env node
// This script uploads automatically a folder's content to an ftp server.
// For this gist's latest version check https://gist.github.com/RaschidJFR/d6d072d8d95e3f9b2ebd9729a8031f0b
//
// 1. Make sure you've installed as devDependencies the packages you'll need:
// * [node-flags](https://www.npmjs.com/package/node-flags) (needed)
// * [ftp-deploy](https://www.npmjs.com/package/ftp-deploy) (for normal FTP upload)
// * [ftp-diff-deployer](https://www.npmjs.com/package/ftp-diff-deployer) (for uploading diffs on normal FTP)
// * [sftp-upload](https://www.npmjs.com/package/sftp-upload) (for SFTP)
//
@RaschidJFR
RaschidJFR / ion-highligh-errors.scss
Created October 29, 2019 00:12
Helper SASS to force Ionic to show invalid item inputs
// This class forces Ionic to show invalid item inputs
.highlight-errors {
--show-inset-highlight: 1;
--show-full-highlight: 1;
ion-item.ion-invalid {
--highlight-height: 2px;
--inset-highlight-height: calc(var(--highlight-height) * var(--show-inset-highlight));
--full-highlight-height: calc(var(--highlight-height) * var(--show-full-highlight));
@RaschidJFR
RaschidJFR / P12-from-Windows.md
Created November 1, 2019 16:32
Create Apple Developer p12 signing Identity from Windows

Create Apple Developer p12 signing Identity from Windows

Before starting you'll need to install OpenSSL.

  1. Generate an RSA key (or use an existing one):

    openssl genrsa -out keyname.key 2048
    
  2. Create a certificate signing request (skip all question fields but Country Name, Common Name and Email Address).

@RaschidJFR
RaschidJFR / ION_LOCAL_SERVER_CONFIG.md
Last active November 4, 2019 22:01
Ionic v4: Configuration for connecting to local server database

Setup for connecting Android Emulatir with live reload to local host PC

How to create a configuration to run with $ ionic cordova emulate android -l -c local and let the emulator connect to host PC, accessing through 10.0.2.2 instead if localhost.

1 angular.json

Create the file environment.local.emulator.ts. Then appli these changes to angular.json.

  1. Add this snippet under project.app.architect.build.configurations:

"local-emulator": {

@RaschidJFR
RaschidJFR / emulate-mobile.css
Created November 7, 2019 22:34
Emulate mobile screen dimensions using CSS
/**
* Add the class `emulate-mobile` (programmatically) to `body` to emulate mobile resolution.
*
* @example
* const body = document.getElementsByTagName('body')[0] as HTMLBodyElement;
* body.classList.add('emulate-mobile');
*/
body.emulate-mobile {
--marginX: calc(50vw - 180px);
--marginY: calc(50vh - 320px);