Skip to content

Instantly share code, notes, and snippets.

View ahmed-abdelazim's full-sized avatar

Ahmed Abdeazim ahmed-abdelazim

View GitHub Profile
@ahmed-abdelazim
ahmed-abdelazim / escape.py
Last active March 10, 2020 12:15
convert XML files to format can be posted via postman
import os
if not os.path.exists('escaped'):
os.makedirs('escaped')
def escape(file):
with open(file, 'r') as f:
a_string = ''.join(f)
escaped = a_string.replace('"', '\\"')
escaped = escaped.replace('><', '>\\r\\n<')
@ahmed-abdelazim
ahmed-abdelazim / export.py
Last active January 14, 2022 13:13
Export / import AWS dynamodb table from json file with correct data types using python
from __future__ import print_function # Python 2/3 compatibility
import json
import boto3
# AWS_ACCESS = ""
# AWS_SECRET = ""
AWS_REGION = "eu-west-3"
TABLE_NAME = "users"
client = boto3.client(
@ahmed-abdelazim
ahmed-abdelazim / telegram.sh
Created February 28, 2020 20:15
Install Telegram via Official package
sudo apt-get install xz-utils
wget -O- https://telegram.org/dl/desktop/linux | sudo tar xJ -C /opt/
sudo ln -s /opt/Telegram/Telegram /usr/local/bin/telegram-desktop
@ahmed-abdelazim
ahmed-abdelazim / start-stop-ec2-instances.js
Created December 2, 2019 08:38 — forked from eddmann/start-stop-ec2-instances.js
Scheduled Start/Stop of EC2 Instances using Lambda and CloudWatch Events
// Demonstration video can be found at: https://youtu.be/roAerKVfq-Y
// StopEC2Instance
const AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const ec2 = new AWS.EC2({ region: event.instanceRegion });
ec2.stopInstances({ InstanceIds: [event.instanceId] }).promise()
<?php
class CdnWPFC{
public static function cloudflare_clear_cache($email = false, $key = false, $zoneid = false){
if(!$email && !$key && !$zoneid){
if($cdn_values = get_option("WpFastestCacheCDN")){
$std_obj = json_decode($cdn_values);
foreach ($std_obj as $key => $value) {
if($value->id == "cloudflare"){
$email = $value->cdnurl;
import time
import boto3
transcribe = boto3.client('transcribe' , region_name='us-west-2',aws_access_key_id='ACCESS_KEY_ID',aws_secret_access_key='SECRET')
transcribe.start_transcription_job(
TranscriptionJobName='RandallTest1',
Media={
'MediaFileUri': 'https://s3-us-west-2.amazonaws.com/randhunt-transcribe-demos/test.flac'
},
MediaFormat='flac',
LanguageCode='en-US',
@ahmed-abdelazim
ahmed-abdelazim / scrape.py
Created October 4, 2019 17:52
Scaraping from profiles.txt with skills
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException, NoSuchElementException
from selenium.webdriver.common.keys import Keys
from parsel import Selector
from time import sleep
import requests, json
import time
@ahmed-abdelazim
ahmed-abdelazim / scrape.py
Created October 3, 2019 19:23
Scaraping from profiles.txt
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException, NoSuchElementException
from selenium.webdriver.common.keys import Keys
from parsel import Selector
from time import sleep
import requests, json
import time
@ahmed-abdelazim
ahmed-abdelazim / service.sh
Created September 15, 2019 21:27
Create a service from bash script on Ubuntu ( for startup )
bootscript=/root/run.sh
servicename=customboot
cat > $bootscript <<EOF
#!/usr/bin/env bash
echo "$bootscript ran at $(date)!" > /tmp/it-works
EOF
chmod +x $bootscript
@ahmed-abdelazim
ahmed-abdelazim / default
Created September 11, 2019 21:15
Install Nginx - php on Ubuntu 18 and Digital Ocean php client
server {
listen 80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}