Skip to content

Instantly share code, notes, and snippets.

View aymanfarhat's full-sized avatar
🏠
Working from home

Ayman Farhat aymanfarhat

🏠
Working from home
View GitHub Profile
#Copyright 2022 Google LLC.
#SPDX-License-Identifier: Apache-2.0
import os
import psutil
from google.cloud.storage import Client
def get_mem_mb():
return psutil.Process().memory_info().rss / (1024 * 1024)
#Copyright 2022 Google LLC.
#SPDX-License-Identifier: Apache-2.0
WITH
initial_log AS (
SELECT
commit_hash,
author_name,
author_email,
TIMESTAMP_SECONDS(author_date) AS author_date,
REGEXP_EXTRACT(file, "(tools|examples)/[^/]+/.*") AS type,
@aymanfarhat
aymanfarhat / bq_load.sh
Last active August 9, 2022 12:33
Example of extracting and flattening git logs and writing them into BigQuery
#Copyright 2022 Google LLC.
#SPDX-License-Identifier: Apache-2.0
bq --location="EU" load \
--replace \
--source_format="NEWLINE_DELIMITED_JSON" \
--autodetect \
your_dataset.your_table \
./logs.jsonl
@aymanfarhat
aymanfarhat / docker-compose.yml
Last active December 5, 2019 12:13
Example of docker-izing a wordpress setup in docker-compose
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
apt-get update
echo "[Install] Build essential"
sudo apt-get install build-essential
echo "[Install] Python software properties"
apt-get install python-software-properties
echo "[Install] git"
apt-get install git
$to = array('ayman@test.com');
// setup Swift mailer parameters
$transport = Swift_SmtpTransport::newInstance( 'smtp.sendgrid.net', 465, 'ssl');
$transport->setUsername('aymanfarhat ');
$transport->setPassword('mypass');
$swift = Swift_Mailer::newInstance( $transport );
// create a message (subject)
def file_to_list(fname):
f = open(fname)
lst = f.readlines()
return [line.rstrip('\n') for line in lst]
def list_to_file(fname, lst):
f = open(fname, "w")
f.write("\n".join(lst))
@aymanfarhat
aymanfarhat / yalla.sh
Created May 21, 2014 18:43
Start a project and its common windows with tmux
#!/bin/sh
if [ -z "$1" ] ; then
echo "usage: $0 <projectname> [/path/to/project]"
exit 1
fi
MYPROJECT=$1
if [ -z "$2" ] ; then
@aymanfarhat
aymanfarhat / code_team_guidelines.txt
Last active August 29, 2015 14:01
A list of guidelines that every dev team should decide on for a project
- Tab vs spaces
- Common Git workflow
- Code style to enforce
- variable naming conventions
- function naming convention
- Namespaces
- check PSR
- semantic versioning (http://semver.org/)
- JS linting with JSHint
- CSS pre-processor SASS vs LESS
@aymanfarhat
aymanfarhat / tweet_this.js
Created March 26, 2014 07:39
Simple Twitter intent generator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.ico">