Skip to content

Instantly share code, notes, and snippets.

View a7md0's full-sized avatar

Ahmed Naser a7md0

View GitHub Profile
@anwarishak
anwarishak / model.php
Created April 30, 2012 14:33
Abstract "model" class in a custom PHP MVC framework - also forms the basis of the framework's ORM
<?php
/**
* Abstract class that serves as the Model in the MVC framework.
*
* A Model is a representation of the information in the application. A Model's
* data is saved in the database and the class is used to handle all the
* business logics. This class handles the standard create, read, update
* and delete operations. It must be extended to create the concrete
* implementation of a Model, and handle any other business logics specific to
@mucar
mucar / random_color_array.js
Created October 16, 2012 11:47
Javascript Random Color Array
var colorArray = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99', '#00B3E6',
'#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D',
'#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A',
'#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC',
'#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC',
'#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399',
'#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680',
'#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933',
'#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3',
'#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF'];
@Stanback
Stanback / nginx.conf
Last active July 24, 2024 18:44 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@kimus
kimus / ufw.md
Created March 2, 2014 22:46
NAT and FORWARD with Ubuntu’s ufw firewall

UFW

I use Ubuntu’s Uncomplicated firewall because it is available on Ubuntu and it's very simple.

Install UFW

if ufw is not installed by default be sure to install it first.

@alastairmccormack
alastairmccormack / x509_sha1_fingerprint.py
Created November 13, 2015 03:40
Gets a SHA1 fingerprint from an x509 certificate using Python and OpenSSL crypto module
from OpenSSL.crypto import load_certificate, FILETYPE_PEM
cert_file_string = open("esx.crt", "rb").read()
cert = load_certificate(FILETYPE_PEM, cert_file_string)
sha1_fingerprint = cert.digest("sha1")
print sha1_fingerprint
@luciopaiva
luciopaiva / android-apk-user-certificates.md
Last active April 18, 2024 07:46
Android APK HTTPS user certificates how-to

Android APK HTTPS user certificates how-to

Starting with Android Nougat, Google changed the way apps handle user certificates:

Apps that target API Level 24 and above no longer trust user or admin-added CAs for secure connections, by default.

This means that certificates issued by applications like [Charles][charles] or [mitmproxy][mitmproxy] are no longer accepted, so these proxies won't work for HTTPS traffic.

This tutorial explains what needs to be done to overcome that restriction and be able to sniff any Android app's HTTPS requests.

@joaopfsilva
joaopfsilva / iban.js
Created September 27, 2019 07:40
IBAN validator
// https://github.com/arhs/iban.js
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['exports'], factory);
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
// CommonJS
factory(exports);
} else {
// Browser globals
@jibiel
jibiel / assets.dart
Created April 3, 2021 03:48
Dark Mode-aware asset images in Flutter
/// lib/utilities/assets.dart
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
/// Usage:
///
/// The image file is located at lib/assets/images/path/to/image.png.
///
/// 1. Image has no dark mode variant.
@a7md0
a7md0 / TableSchema.cs
Last active April 30, 2021 17:50
Parse SqlDataReader.GetSchemaTable into useable object
using System;
using System.Data;
using System.Collections.Generic;
public class TableSchema {
private Dictionary<string, TableSchemaColumn> columns;
public TableSchema(DataTable dataTable) {
this.columns = new Dictionary<string, TableSchemaColumn>();
@Tallyb
Tallyb / fake-time.fixtures.ts
Created August 11, 2023 05:32
fake time fixture in playwright
import { test as base } from '@playwright/test';
const setFakeTime = async (dateTime: string, page: Page): Promise<void> => {
const fakeNow = new Date(dateTime).valueOf();
const setFakeTime = async (dateTime: string, page: Page): Promise<void> => {
const fakeNow = new Date(dateTime).valueOf();
await page.addInitScript(`{
// Extend Date constructor to default to fakeNow
Date = class extends Date {
constructor(...args) {