Skip to content

Instantly share code, notes, and snippets.

Avatar

Ferri Sutanto ghprod

  • Purwokerto, Indonesia
View GitHub Profile
@ghprod
ghprod / restart-service.sh
Last active Mar 17, 2021
Auto Restart PHP5-FPM When Down or Bad Gateway
View restart-service.sh
#!/bin/bash
if curl --head -sf http://yourdomain.com/some-script.php -o /dev/null; then
echo "PHP FPM is up"
else
service php5-fpm restart && service nginx restart && service mysql restart
echo "Opps .. service was down" | mail -s "PHP-FPM Service Down" yourmail@domain.com -aFrom:cron@yourmail.com
fi
@ghprod
ghprod / mirror.md
Last active Mar 4, 2021
Mirror Website Using Httrack Command Line
View mirror.md
mkdir ~/Mirror

cd ~/Mirror

httrack --connection-per-second=8 --sockets=8 --keep-alive --display --verbose --advanced-progressinfo --disable-security-limits -i -s0 -m -F 'Mozilla/5.0 (X11;U; Linux i686; en-GB; rv:1.9.1) Gecko/20090624 Ubuntu/9.04 (jaunty) Firefox/3.5' -#L999999 http://domain.com
@ghprod
ghprod / background-image.ts
Created May 24, 2016
Background Image Style Directive for Angular 2 and Ionic 2
View background-image.ts
import {Directive, ElementRef, Input} from '@angular/core';
@Directive({
selector: '[background-image]'
})
export class BackgroundImage {
private el: HTMLElement;
constructor(el: ElementRef) {
this.el = el.nativeElement;
@ghprod
ghprod / fade_on_scroll.dart
Created Jul 29, 2020 — forked from smkhalsa/fade_on_scroll.dart
A Widget that automatically fades its child based on scroll position
View fade_on_scroll.dart
import 'package:flutter/material.dart';
class FadeOnScroll extends StatefulWidget {
final ScrollController scrollController;
final double zeroOpacityOffset;
final double fullOpacityOffset;
final Widget child;
FadeOnScroll(
{Key key,
@ghprod
ghprod / app.js
Created Mar 15, 2014
Cordova Exit App Confirm
View app.js
document.addEventListener("deviceready", deviceisready, false);
function deviceisready(){
alert("Device Ready is called");
document.addEventListener("backbutton", function(e){
if ( $('.ui-page-active').attr('id') == 'mainpage') {
//window.location = "#exitDialog";
exitAppPopup();
}else{
history.back();
@ghprod
ghprod / bmi.dart
Created Sep 25, 2020 — forked from roipeker/bmi.dart
BMI Calculator clone with GetX (+ Theme modes)
View bmi.dart
import 'dart:async';
import 'dart:math' as math;
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:get/get.dart';
@ghprod
ghprod / helpers.php
Created Jun 12, 2014
Delete Laravel Cache By Pattern
View helpers.php
<?php
foreach (Cache::getMemory() as $cacheKey => $cacheValue)
{
if (strpos($cacheKey, 'mypackage') !== false)
{
Cache::forget($cacheKey);
}
}
@ghprod
ghprod / README.md
Created Aug 3, 2020 — forked from CodingDoug/README.md
Patterns for security with Firebase Authentication: offload work to Cloud Functions
View README.md

This is the runnable sample code from the blog post [Patterns for security with Firebase Authentication: offload work to Cloud Functions][1]. It discusses offloading work from a client app to Cloud Functions using an authentication trigger.

  1. Create a new Firebase project
  2. Enable email/password authentication
  3. Provision Cloud Firestore and apply the rules given in this gist
  4. Use the Firebase CLI to create a workspace for Functions using TypeScript
  5. Deploy the given HTML and JavaScript to Firebase Hosting (the CLI emulator will also work).
  6. Deploy the function code to Cloud Functions using the Firebase CLI
@ghprod
ghprod / main.dart
Last active Jul 31, 2020
GetX Debug Template
View main.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
initialRoute: '/',
@ghprod
ghprod / main.dart
Created Jun 28, 2020 — forked from PetreaLoredana/main.dart
This code generates a screen with a custom bidirectional and infinite scrollable PageView in Flutter. Replace your own assets names. More details can be found on Medium. https://medium.com/p/dfff43649c23/edit
View main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(CustomPageViewApp());
class CustomPageViewApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,