Skip to content

Instantly share code, notes, and snippets.

View nguyenchilong's full-sized avatar

Long Nguyen nguyenchilong

  • Vietnam
  • 06:47 (UTC +07:00)
  • LinkedIn in/longnc
View GitHub Profile
@nguyenchilong
nguyenchilong / waf-smoke-test.sh
Created April 15, 2025 07:38 — forked from ridjex/waf-smoke-test.sh
Lightweight Bash script to test basic WAF (Web Application Firewall) protections against common SQL injection and XSS payloads. Use this to quickly assess your web application’s surface against low-hanging injection vulnerabilities.
#!/bin/bash
# 🚀 Discover More: Testing Your Firewall in 60 Seconds: A Lightweight WAF Testing Script That Anyone Can Use
# Learn how this script works and the best practices for WAF testing.
# Read the full article here:
# 👉 https://medium.com/@kochuraa/testing-your-firewall-in-60-seconds-a-lightweight-waf-testing-script-that-anyone-can-use-a7a725fefcb7
# Safe WAF Tester Script
# Usage: ./waf-smoke-test.sh <URL> [-o output.md] [-H "Header: Value"]
# Examples:
@nguyenchilong
nguyenchilong / display_discount_percentage_badge
Last active August 22, 2021 18:28
How to Display the Discount Percentage on the Sale Badge?
/**
* Step 1: Copy the code here below
* Step 2: Add it to your functions.php file. Better option, install and add the code using Code snippets plugin
*/
add_action( 'woocommerce_sale_flash', 'sale_badge_percentage', 25 );
function sale_badge_percentage() {
global $product;
if ( ! $product->is_on_sale() ) return;
if ( $product->is_type( 'simple' ) ) {
$max_percentage = ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100;
@nguyenchilong
nguyenchilong / README.md
Created February 3, 2021 10:57 — forked from mrbar42/README.md
Secured HLS setup with Nginx as media server

Secured HLS setup with Nginx as media server

This example is part of this article.

This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:

  • Domain filtering
  • Referrer filtering
  • Embed buster
class CustomIcons {
CustomIcons._();
static const _kFontFam = 'CustomIcons';
static const IconData home = const IconData(0xe801, fontFamily: _kFontFam);
static const IconData medicine =
const IconData(0xe800, fontFamily: _kFontFam);
class AppState {
final IndexState indexState;
final OfferState offerState;
final NotificationState notificationState;
final OrderState orderState;
final AddressState addressState;
final NewsState newsState;
final AuthState auhtState;
final ProductState productState;
final QuestionState questionState;
import 'package:redux_remote_devtools/redux_remote_devtools.dart';
Future<Store<AppState>> createStore() async {
// make sure to replace '192.168.1.5' your ip
var remoteDevtools = RemoteDevToolsMiddleware('192.168.1.5:8000');
var store = Store<AppState>(
appReducer,
initialState: AppState.initial(),
middleware: []
final notificationReducer = combineReducers<NotificationState>([
TypedReducer<NotificationState, SyncNotificationsAction>(_syncNotifications),
]);
NotificationState _syncNotifications(
NotificationState state, SyncNotificationsAction action) {
for (var notification in action.notifications) {
state.notifications.update(notification.id.toString(), (v) => notification,
ifAbsent: () => notification);
}
List<Middleware<AppState>> createNotificationMiddleware([
NotificationRepository _repository = const NotificationRepository(),
]) {
final getNotifications = _createGetNotifications(_repository);
return [
TypedMiddleware<AppState, GetNotificationsAction>(getNotifications),
];
}
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:saidlty/data/model/notification_data.dart' as NotificationModel;
import 'package:flutter_redux/flutter_redux.dart';
import 'package:saidlty/redux/app/app_state.dart';
import 'package:saidlty/features/notifications/notifications_view_model.dart';
import 'package:saidlty/redux/action_report.dart';
class NotificationsView extends StatelessWidget {
mport 'package:redux/redux.dart';
import 'package:saidlty/data/model/notification_data.dart';
import 'package:saidlty/redux/action_report.dart';
import 'package:saidlty/redux/app/app_state.dart';
import 'package:saidlty/redux/notification/notification_actions.dart';
class NotificationsViewModel {
final Notification notification;
final List<Notification> notifications;
final Function(bool) getNotifications;