Skip to content

Instantly share code, notes, and snippets.

View ahmedengu's full-sized avatar

Ahmed Aboumalwa ahmedengu

View GitHub Profile
@ahmedengu
ahmedengu / drupal\core\modules\user\src\Plugin\Validation\Constraint\ProtectedUserFieldConstraintValidator.php
Last active July 13, 2018 17:07
drupal 8 suppress error "Your current password is missing or incorrect; it's required to change the %name." if not changing password
<?php
namespace Drupal\user\Plugin\Validation\Constraint;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\user\UserStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
@ahmedengu
ahmedengu / amazon.py
Created June 17, 2018 09:15
web scrape of amazon seller reviews using python
import csv
import re
import sys
import time
import xlrd
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
var alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function _encrypt(plainText, options) {
let cipherText = "";
for (let c of plainText) {
let index = alphabets.indexOf(c);
if (index == -1) {
cipherText += c;
continue;
}
let newIndex = (index + options.key) % alphabets.length;
var TABLE = [['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
['B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A'],
['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B'],
['D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C'],
['E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D'],
['F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E'],
['G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F'],
['H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S'
@ahmedengu
ahmedengu / Client.java
Created March 19, 2017 11:10
RMI oxford dictionary api, JSON parsing using json-simple: https://code.google.com/archive/p/json-simple/downloads
import java.rmi.registry.LocateRegistry;
import java.util.Scanner;
/**
* Created by ahmedengu.
*/
public class Client {
private static OxfordInterface oxford;
@ahmedengu
ahmedengu / Client.java
Last active March 19, 2017 10:10
Multithreaded client-server with oxford dictionary api, JSON parsing using json-simple: https://code.google.com/archive/p/json-simple/downloads
import java.io.*;
import java.net.Socket;
import java.util.Scanner;
/**
* Created by ahmedengu.
*/
public class Client {
public static void main(String[] args) {
@ahmedengu
ahmedengu / index.js
Created March 10, 2017 03:26
Paddle.com Verifying Webhooks ( Signature ) for nodejs/expressjs , https://paddle.com/docs/reference-verifying-webhooks
/*
1- Install(using npm): Express, body-parser, php-serialize, crypto
* npm install --save express body-parser php-serialize crypto
2- read Paddle docs: https://paddle.com/docs/reference-verifying-webhooks
3- GoTo line 32 to set your public key, available here: https://vendors.paddle.com/account
4- Run it
5- Send post request to http://localhost:8080/paddleWebhook
* you can use https://requestb.in to get the payload from paddle request simulator
* paddle simulator (Webhook Alert Testing) : https://vendors.paddle.com/webhook-alert-test
6- Testing result should be like this:
@ahmedengu
ahmedengu / GoogleMapsAutoCompleteTest.java
Created December 30, 2016 20:51
Google Maps AutoComplete Test codenameone
package com.mycompany.myapp; // change to your package
import com.codename1.io.ConnectionRequest;
import com.codename1.io.JSONParser;
import com.codename1.io.NetworkManager;
import com.codename1.ui.*;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.util.Callback;
@ahmedengu
ahmedengu / GoogleMapsGeocodeTest.java
Created December 30, 2016 20:23
Google Maps Geocode Test codenameone , get coord from address , get address from coord
package com.mycompany.myapp; // change to your package
import com.codename1.components.ToastBar;
import com.codename1.io.ConnectionRequest;
import com.codename1.io.JSONParser;
import com.codename1.io.NetworkManager;
import com.codename1.maps.Coord;
import com.codename1.ui.Button;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
@ahmedengu
ahmedengu / GoogleMapsTestApp.java
Last active December 29, 2016 18:23
codenameone draw approximate on map given point and radius
package com.mycompany.myapp; // change to your package
// goto line 42
import com.codename1.googlemaps.MapContainer;
import com.codename1.maps.Coord;
import com.codename1.maps.providers.GoogleMapsProvider;
import com.codename1.ui.Display;
import com.codename1.ui.FontImage;
import com.codename1.ui.Form;
import com.codename1.ui.layouts.BorderLayout;