Skip to content

Instantly share code, notes, and snippets.

View ahmadmarafa's full-sized avatar

Ahmad Arafa ahmadmarafa

View GitHub Profile
@ahmadmarafa
ahmadmarafa / ssllamp.sh
Created September 2, 2021 17:55
add SSL to localhost domains, sudo ./ssllamp.sh
#!/usr/bin/env bash
RAND=$(openssl rand -hex 12)
TEMP="/opt/lampp/temp/$RAND"
mkdir $TEMP
cd $TEMP
@ahmadmarafa
ahmadmarafa / passwordStrength.js
Created October 18, 2020 18:35
react circular password strength indicator
import React, { Component } from 'react'
const PasswordPower = (props) => {
const tests = [
[/^(?=.*[\d])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*])[\w!@#$%^&*]{8,}$/, 'strong password', '✓', '#a5dc86' , 0],
[/^((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{6,})$/, "medium", "!", '#f8bb86' , 16],
[/^[a-zA-Z0-9\-\_!@#$%^&*\.\(\)]{1,}$/, "week password", "❌", '#f27474' , 50]
]
if (props.password) {
for (let test of tests) {
class SharedWith extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 5),
width: double.infinity,
height: 40.0,
child: Stack(
children: <Widget>[
Positioned(
@ahmadmarafa
ahmadmarafa / FileUpload.js
Created August 24, 2019 12:11
antd fileupload on form submit
import React, { Component } from 'react'
import { Upload, Form, Icon } from "antd";
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
@ahmadmarafa
ahmadmarafa / php
Created May 23, 2019 00:30
TBolier\RethinkQL getNearest with filter
<?php
$connection = r\connect("127.0.0.1" , null , "myApp") ;
$point = r\point((float) $request->pickup["lng"] , (float) $request->pickup["lat"]);
$data = r\table("connected")->getNearest($point , ["index" => "last_location"])->filter(
r\row("doc")("service_id")->eq( $request->service )
)->run($connection) ;
<?php
namespace Itx\Utilities ;
class Random
{
public static function guid()
{
return sprintf(
'%s-%04x-%04x-%04d-%s',
self::string(8),
import 'dart:async' ;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
class Api
{
SharedPreferences prefs ;
String locale = "en" ;
Api() { this.init(); }
@ahmadmarafa
ahmadmarafa / Ip.php
Last active February 22, 2018 22:01
Get client ip and info using public apis ..
<?php
class Ip
{
public function get()
{
if (isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
@ahmadmarafa
ahmadmarafa / arabic_soundex.php
Last active September 2, 2021 17:58
arsoundex
<?php
/**
this is a simple method , which will return soundex of transliterated arabic string
*/
function arSoundex($string)
{
// remove any pounctions and any space etc ..
$string = preg_replace("/\\p{P}|\\p{M}/u", "" , $string);
$chars = array(
"ا"=>"أإاآ" ,