Skip to content

Instantly share code, notes, and snippets.

View ahmadarif's full-sized avatar
🎯
Focusing

Ahmad Arif ahmadarif

🎯
Focusing
View GitHub Profile
@ahmadarif
ahmadarif / app.context.ts
Created February 19, 2019 14:18
Medium: Nest Tutorial S1 - Application Context
import { NestApplication, NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
let context: NestApplication = null;
export const ApplicationContext = async () => {
if (!context) {
context = await NestFactory.create(AppModule) as NestApplication;
}
return context;
};
@ahmadarif
ahmadarif / base64FromUrl.js
Created February 8, 2019 09:33
Get base64 from URI
'use strict'
const fs = require('fs')
const path = require('path')
const axios = require('axios')
const url = 'YOUR_IMAGE_URL'
async function base64FromUrl(url) {
const pathFile = path.resolve(__dirname, 'code.jpg')
const writer = fs.createWriteStream(pathFile)
@ahmadarif
ahmadarif / readme.md
Created January 29, 2019 01:58
Custom Socket.io-Client for Angular

Dependencies

  • Socket.io client: npm install -S socket.io-client
  • Socket.io types definition: npm install -D @types/socket.io-client

Configuration

  • Copy socket.service.ts to project directory
  • Import SocketService in module providers
  • Inject SocketService to component class
    constructor (private readonly socket: SocketService) {
@ahmadarif
ahmadarif / readme.md
Last active January 22, 2019 12:42
Implementasi observe events di Angular HttpClient

Implementasi 1

this.uploadService.create(GANTI_DENGAN_OBJECT_CLASS_UPLOAD).pipe(
  catchError((err: HttpErrorResponse) => {
    const res = err.error as Response<null>;
    console.log('Uploading error:', res.message);
    return Observable.throw(null);
  }))
  .subscribe((event: HttpEvent<any>) => {
    switch (event.type) {
'use strict'
const Helpers = use('Helpers')
const Client = use('App/Elastic/connection-sp.js')
const ElasticSearch = Helpers.promisify(Client.search)
class SearchController {
async search({ request, response }) {
try {
const response = await ElasticSearch({
@ahmadarif
ahmadarif / kernel.js
Last active September 13, 2018 10:01
Running single Queue & Scheduler on boot of the web sever.
...
if (process.env.exec_mode === 'cluster_mode') {
if (Number(process.env.NODE_APP_INSTANCE) === 0) {
runKue()
runScheduler()
}
} else {
runKue()
runScheduler()
@ahmadarif
ahmadarif / User.js
Created September 12, 2018 07:32
Static field Javascript ES6
'use strict'
const Model = use('Model')
/**
* @class App/Models/User
*
* @property {string} id
* @property {string} username
* @property {string} email
@ahmadarif
ahmadarif / DestroySubscribers.ts
Created July 1, 2018 09:58
Decorator for unsubscribe Subscriber
import { Subscriber } from "rxjs";
/**
* @example
*
* @Component({})
* @DestroySubscribers()
* export class YourComponent {
* createSub: Subscription = new Subscription();
* subscribers: Subscription[] = [];

https://www.wowza.com/docs/how-to-encode-vod-using-ffmpeg-with-wowza-streaming-engine

OLD SYSTEM

ffmpeg -loglevel quiet -y -i input.mkv -s 256x144 -y -strict experimental -acodec aac -ab 24k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -sc_threshold 0 -pass 1 -b:v 50k -threads 16 output.mkv

ffmpeg -loglevel quiet -y -i input.mkv -s 640x360 -y -strict experimental -acodec aac -ab 64k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -sc_threshold 0 -pass 2 -b:v 400k -threads 16 output.mkv

ffmpeg -loglevel quiet -y -i input.mkv -s 1920x1080 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -sc_threshold 0 -pass 2 -b:v 2500k -threads 16 output.mkv
@ahmadarif
ahmadarif / MailchimpService.js
Created May 13, 2018 03:39
MailChimp Service for Adonis/NodeJS App
'use strict'
const Env = use('Env')
const Logger = use('Logger')
const axios = use('axios')
const Response = use('App/Class/Response')
class MailchimpService {
constructor () {
this.http = axios.create({