Skip to content

Instantly share code, notes, and snippets.

View josephdicdican's full-sized avatar

josephdicdican

View GitHub Profile
@josephdicdican
josephdicdican / api.dart
Last active March 31, 2022 21:40
Flutter Navigate without Context with example
abstract class API {
// sample usage: API.get('/endpoint', {'get': 'request'})
static Future<dynamic> get(String endpoint, [Map<String, dynamic>? params]) async {
// NOTE: helper methods not included
var uri = API.parseEndpoint(endpoint);
var httpHeaders = await API.getHttpHeaders();
final response = await http.get(uri, headers: httpHeaders);
var data = jsonDecode(response.body);
if (response.statusCode == 200) {
@josephdicdican
josephdicdican / lumen-deployment.md
Created January 31, 2020 15:02
Lumen Deployment

Lumen Framework Deployment Process

Root: lumenapi

  • always base under this root directory

Steps below apply when it is the first time setting up the lumenapi project.

  1. Create .env basing .env.example - change necessary configuration specially DB credentials
  2. Run composer install
  3. Run php artisan migrate - to make updates on database schema if there are any
@josephdicdican
josephdicdican / node-sass-error-npm-install.md
Last active January 6, 2020 09:03
Ionic Project - Node SASS Error on npm install

Ionic Project ([email protected]) Node SASS Error on npm install

Error

MINGW64 ~/Sites/bitbucket/**ionic-app (master)
$ npm install
npm WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-commonjs.
npm WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-node-resolve.
npm WARN deprecated [email protected]: babili has been renamed to babel-minify. Please update to babel-minify
@josephdicdican
josephdicdican / add-english-report-for-foreign-languages.md
Last active November 20, 2019 16:23
Add English Report for Foreign Language - iassess

Add English Report on Foreign Language Testing

Target: To be able to download English version reports from the test results of a foreign language tests.

Involved Tables:

Current setup

order_candidate_test_scores
@josephdicdican
josephdicdican / js-shallow-deep-copy. js
Created May 16, 2019 16:01
Javascript Shallow & Deep Copy
const combo_meal = {
rice: 1,
fried_chicken: 1,
drink: 1
};
let order1 = combo_meal;
// order1.drink = 0;
@josephdicdican
josephdicdican / generating-password-protected-zip-files-using-php.md
Last active May 3, 2019 09:31
Generating Password Protected ZIP Files using PHP

Alternative way of creating Password protected zip file when you are not ready to upgrade to php 7

<?php
$password = 'pass';
$outfile = 'download.zip';
$infile = 'file.txt';

header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=$outfile");
@josephdicdican
josephdicdican / add_remove_elements.md
Created October 24, 2018 10:24
Add/Remove element in reference array from a given array

Scenario:

  1. Item is shared to groups [6,5]
  2. I want to edit item to share to groups [5,4]
    • in result, 6 will be remove and 4 will be added while 5 is as is
<?php

    $shared_groups = [6,5];
 $group_ids = [5,4];
@josephdicdican
josephdicdican / mb_textwrap.php
Last active September 12, 2018 03:32
mb_textwrap - wrapping multibyte characters
<?php
if ( !function_exists('mb_str_split') ) {
function mb_str_split($string, $split_length = 1) {
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
$split_length = ($split_length <= 0) ? 1 : $split_length;
$mb_strlen = mb_strlen($string, 'utf-8');
function makeIterator(array) {
var nextIndex = 0;
console.log("nextIndex =>", nextIndex);
return {
next: function() {
return nextIndex < array.length
? { value: array[nextIndex++], done: false }
: { done: true };
}
@josephdicdican
josephdicdican / local_development_env_setup.md
Last active July 3, 2018 05:38
Local Development Env Setup (for mac users only)

1. Install mariadb for database

brew install mariadb

After install start mariadb

brew services start mariadb