Skip to content

Instantly share code, notes, and snippets.

View MoustafaAMahmoud's full-sized avatar

Mostafa Mahmoud MoustafaAMahmoud

View GitHub Profile
@moroclash
moroclash / nvidia-reinstall.sh
Last active December 8, 2018 23:26 — forked from morgangiraud/nvidia-reinstall.sh
Script to reinstall manually nvidia drivers,cuda 9.0 and cudnn 7.1 on Ubuntu 16.04
# Remove anything linked to nvidia
sudo apt-get remove --purge nvidia*
sudo apt-get autoremove
#install important lib's
sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev curl python python3 gcc g++
# Search for your driver
apt search nvidia
package test
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.SparkSession
import scala.collection.mutable
class DisjointSet() extends Serializable {
private val parentMap = mutable.Map[Int, Int]()
@MoustafaAMahmoud
MoustafaAMahmoud / progfun04
Created August 19, 2017 14:27 — forked from nicokosi/progfun04
My notes from Coursera course "Functional Programming Principles in Scala" (https://class.coursera.org/progfun-004).
Notes from Coursera course 'Functional Programming Principles in Scala":
https://class.coursera.org/progfun-004
✔ Week 1: Functions & Evaluations @done (14-05-01 17:20)
✔ Lecture 1.1 - Programming Paradigms (14:32) @done (14-04-27 17:54)
3 paradigms: imperative, functional, logic
OO: orthogonal
imperative:
@duluca
duluca / awc-ecs-access-to-aws-efs.md
Last active December 9, 2023 11:36
Step-by-step Instructions to Setup an AWS ECS Cluster

Configuring AWS ECS to have access to AWS EFS

If you would like to persist data from your ECS containers, i.e. hosting databases like MySQL or MongoDB with Docker, you need to ensure that you can mount the data directory of the database in the container to volume that's not going to dissappear when your container or worse yet, the EC2 instance that hosts your containers, is restarted or scaled up or down for any reason.

Don't know how to create your own AWS ECS Cluster? Go here!

New Cluster

Sadly the EC2 provisioning process doesn't allow you to configure EFS during the initial config. After your create your cluster, follow the guide below.

New Task Definition for Web App

If you're using an Alpine-based Node server like duluca/minimal-node-web-server follow this guide:

@longcao
longcao / SparkCopyPostgres.scala
Last active December 26, 2023 14:47
COPY Spark DataFrame rows to PostgreSQL (via JDBC)
import java.io.InputStream
import org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils
import org.apache.spark.sql.{ DataFrame, Row }
import org.postgresql.copy.CopyManager
import org.postgresql.core.BaseConnection
val jdbcUrl = s"jdbc:postgresql://..." // db credentials elided
val connectionProperties = {
@nicokosi
nicokosi / notes-on-funprog2.md
Last active September 21, 2017 23:06
Notes on Coursera course "Functional Program Design in Scala" (https://www.coursera.org/learn/progfun2)

Week 1

lecture "Recap: Functions and Pattern Matching"

recursive function + case classes + pattern matching: example JSON printer (Scala -> JSON) pattern matching in Scala SDK: PartialFunction is a Trait with def isDefinedAt(x: A): Boolean

lecture "Recap: Collections"

  • Iterable (base class)
    • Seq
@NikitaMelnikov
NikitaMelnikov / StringExtension.scala
Created May 5, 2016 10:32
Safe substring with Scala
implicit class StringExtension(s: String) {
implicit def safeSubstring(start: Int, end: Int = 0): String = {
if (start < 0) {
var realStart = s.length - Math.abs(start)
var realEnd = end match {
case 0 => s.length
case e if e < 0 || e + realStart > s.length => s.length
case _ => realStart + end
}
@polyglotpiglet
polyglotpiglet / Rotation.scala
Created February 25, 2016 12:51
Matrix rotation
object Rotation extends App {
val matrix = Array(Array(1,2), Array(3,4), Array(5,6))
print(matrix)
print(transpose(matrix))
print(rotate90(matrix))
print(rotateMinus90(matrix))
def transpose(matrix: Array[Array[Int]]): Array[Array[Int]] = {