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 / mp3_to_wav.js
Last active April 24, 2024 19:42
Convert mp3 files to wav recursively using ffmpeg in node.js
// Convert mp3 files recursively to wav using [fluent-ffmpeg](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg) for [node.js](https://nodejs.org)
//
// 1. Install fluent-ffmpeg: `npm install fluent-ffmpeg`
// 2. Run this script: `node mp3ToWav.js [path/to/file/or/folder]`
convertMp3ToWav = function (input) {
let segments = input.split('/');
let filename = segments[segments.length - 1];
let extension = filename.split('.')[1];
@RaschidJFR
RaschidJFR / increment_version.js
Last active October 8, 2023 03:37
This script is a simple Cordova hook to incremente Version number each time you build.
#!/usr/bin/env node
// This script increments patch number (mayor.minor.patch) but you can
// choose to increment any other segment by modifying lines `45` to `53`.
//
// 1. Make sure you've installed *xml2js*: `$ npm install xml2js -D`
// 2. Save this file under `project_root/hooks/before_prepare/`
// 3. Done!
var fs = require('fs');
var xml2js = require('xml2js');
@RaschidJFR
RaschidJFR / bitbucket-pipelines.yaml
Last active December 16, 2022 18:53
Sentry: Angular ErrorHandler with Custom Errors, Sentry reporting and Version Bumping.
# Add this step to upload sourcemaps to Sentry
# Don't forget to build with `--source-map=true` to generate the sourcemaps.
# It's recommended that you don't upload them to your production hosting
- script: &script-sentry-release
- npm i @sentry/cli@1.66.0
- VERSION=$(npm run --silent version:describe)
- npx sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases -o $SENTRY_ORG new "$VERSION" --finalize -p $SENTRY_PROJECT
- npx sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases -o $SENTRY_ORG set-commits --auto $VERSION # make sure to add the repo in Sentry Dashboard
- npx sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases -o $SENTRY_ORG -p $SENTRY_PROJECT files "$VERSION" upload-sourcemaps ./sourcemaps
- npx sentry-cli --auth-token=$SENTRY_AUTH_TOKEN releases -o $SENTRY_ORG -p $SENTRY_PROJECT files "$VERSION" upload-sourcemaps ./www
@RaschidJFR
RaschidJFR / webpack.config.js
Last active May 11, 2022 18:35
Transpile Angular project with Babel + Webpack
/**
* ## Angular custom webpack config for compatibility with IE11
* ------------------------------------------------------------
* 1. Add this file to your project root. Add the modules list that needs transpiling (see below code).
* 2. Install dev dependencies:
*
* `$ npm i -D @angular-builders/custom-webpack:browser babel-loader @babel/core @babel/preset-env browserlist`
*
* 3. Add this to your `angular.json`:
*
@RaschidJFR
RaschidJFR / launch.json
Last active December 5, 2021 14:44
VSCode `Launch.json` for debugging Parse Server
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach", // Attach to a running node process (with `--inspect` flag)
@RaschidJFR
RaschidJFR / .htaccess
Last active November 7, 2021 19:00 — forked from julianpoemp/.angular-htaccess.md
Optimal .htaccess configuration for Angular 8, Angular 7, Angular 6, Angular 5 (and older) app in production incl. fix for the angular browser caching issue.
# Taken from [Angular Deploymenr](https://angular.io/guide/deployment) Guide.
#
# INSTRUCTIONS:
# 1. Place this file next to the app's index.html.
# 2. Optional: If you serve your app from a subfolder in your domain,
#
# Gist forked from: [julianpoemp](https://gist.github.com/julianpoemp/bcf277cb56d2420cc53ec630a04a3566)
# Check for new versions of this gist: https://gist.github.com/RaschidJFR/f6d21a03b0692f5c7a6a23954003f00b
# v1.1.0
@RaschidJFR
RaschidJFR / updates.service.ts
Created November 14, 2019 20:10
Ionic-Angular Updates Service (service worker)
// 1. Install Angular Service Worker: `$ ng add @angular/pwa --project app`
// 2. Generate icons: https://app-manifest.firebaseapp.com/
// 3. Add PWA icons for iOS in `index.html`:
// ```
// <link rel="apple-touch-icon" sizes="512x512" href="assets/icons/icon-512x512.png">
// <link rel="apple-touch-icon" sizes="192x192" href="assets/icons/icon-192x192.png">
// ```
// 4. Configure service worker in `ngsw-config.json`. Don't forget to add missing Ionic .svg files in `assetGroups[].resources.files`.
@RaschidJFR
RaschidJFR / version.js
Last active September 20, 2020 06:35
Print version information in different formats from `git describe`
#!/usr/bin/env node
// Use this script to parse version tags from git describe
// Use `node version -h` for help
const { spawn, exec } = require('child_process');
const program = require('commander');
program
.name('node version')
.usage('[--describe | --full | --numeric | --prerelease] [--tag <version.tag>]')
.option('-b, --build', 'Output describe info (without version): <PRE-RELEASE-PHASE(2)>.<PRE-RELEASE-VERSION(2)>.<COMMITS(2)>')
@RaschidJFR
RaschidJFR / pagination.service.ts
Last active August 1, 2020 00:13
Angular universal pagination service
import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { map, mergeMap, mapTo } from 'rxjs/operators';
import { from } from 'rxjs';
/**
* Check https://gist.github.com/RaschidJFR/ef9f342bc2549211df7c6f00d1a06237 for the latest version of the script
* @author Raschid JF Rafaelly <hello&commat;raschidjfr.dev>
* @example
*
@RaschidJFR
RaschidJFR / img-spinner.directive.ts
Created July 15, 2020 21:49
Angular spinner directive for loading images
import { Directive, Renderer2, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: 'img[ngxImgSpinner]',
exportAs: 'ngxImgSpinner'
})
export class ImgSpinnerDirective {
private _loading = true;
private _error = false;