Skip to content

Instantly share code, notes, and snippets.

Avatar

Ahmad Arafa ahmadmarafa

View GitHub Profile
@ahmadmarafa
ahmadmarafa / passwordStrength.js
Created Oct 18, 2020
react circular password strength indicator
View passwordStrength.js
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) {
View sharedWith.dart
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 Aug 24, 2019
antd fileupload on form submit
View FileUpload.js
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
TBolier\RethinkQL getNearest with filter
View php
<?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) ;
View Random.php
<?php
namespace Itx\Utilities ;
class Random
{
public static function guid()
{
return sprintf(
'%s-%04x-%04x-%04d-%s',
self::string(8),
View Api.dart
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 Feb 22, 2018
Get client ip and info using public apis ..
View Ip.php
<?php
class Ip
{
public function get()
{
if (isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
View gist:8cfe27839623bf2b6b96e089a4b6fbdb
<?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(
"ا"=>"أإاآ" ,
You can’t perform that action at this time.