Skip to content

Instantly share code, notes, and snippets.

View Ahmah2009's full-sized avatar
:electron:
Overthinking

Ahmad M ElShareif Ahmah2009

:electron:
Overthinking
View GitHub Profile
fulload() { dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null & }; fulload; read; killall dd
@Ahmah2009
Ahmah2009 / leap.erl
Created April 1, 2017 09:13
is leap year algorithm in Erlang
-module(leap).
-export([is_leap_year/1]).
is_leap_year(Year) when is_integer(Year), Year >= 0,Year rem 4 =:= 0, Year rem 100 > 0 ->
true;
is_leap_year(Year) when is_integer(Year), Year >= 0,Year rem 400 =:= 0 ->
true;
is_leap_year(_) -> false.
@Ahmah2009
Ahmah2009 / ls.go
Created May 16, 2017 07:10
List all files located in dir
package main
import (
"fmt"
"io/ioutil"
"log"
)
func main() {
files, err := ioutil.ReadDir("path to dir")
#!/bin/bash
# Script iptables by olto
# Réinitialisation
iptables -F
echo - Réinitialisation... : [OK]
# Suppression des chaînes utilisateurs
@Ahmah2009
Ahmah2009 / gist:e09d72ed6b2280b5c45e5eb568f1a743
Created November 8, 2018 11:14 — forked from dmytro/gist:7887843
Shell script for SYN flood DOS attacks prevention. Use sqlite3 to filter IP's
#!/bin/bash
SLEEP=120
MAX_CONN=20
MY_IP=0.0.0.0 # Configure your IP here
while true; do
(
echo "create table ips (ip string);"
echo 'begin transaction;'
netstat -an | grep -v ESTABLISHED | grep ${MY_IP}:80 | awk '{print $5}' | cut -f4 -d: | while read IP; do
@Ahmah2009
Ahmah2009 / common-divisors.erl
Last active March 27, 2019 12:45
Hacker Rank problems solve by Erlang @Ahmah2009
%% https://www.hackerrank.com/challenges/common-divisors/submissions/code/13608658
% Enter your code here. Read input from STDIN. Print output to STDOUT
% Your class should be named solution
-module(solution).
-export([main/0]).
-compile(export_all).
main() ->
{ok,[A]}=io:fread("", "~d"),
scanner(A).
@Ahmah2009
Ahmah2009 / reverseVowels.go
Created April 4, 2019 06:19
345. Reverse Vowels of a String leetCode
func reverseVowels(s string) string {
//A, E, I, O, and U
vowlesMap := map[byte]bool{
'a':true,'A':true,
'e': true,'E':true,
'i':true,'I':true,
'o':true,'O':true,
'u':true,'U':true}
vowlesValues := []byte{}
n:= 0
@Ahmah2009
Ahmah2009 / solveEquation.go
Created April 4, 2019 06:20
640. Solve the Equation Leetcode
import "strings"
import "strconv"
func solveEquation(equation string) string {
eqnSides := strings.Split(equation, "=")
leftHandSide, rightHandSide := eqnSides[0], eqnSides[1]
lHV,lHx := getSideSum(leftHandSide)
rHV,rHx := getSideSum(rightHandSide)
if lHx == rHx && lHV == rHV{
@Ahmah2009
Ahmah2009 / kClosest.go
Created April 4, 2019 06:23
973. K Closest Points to Origin leetcode
import "sort"
func kClosest(points [][]int, K int) [][]int {
sort.SliceStable(points,func(i,j int)bool{
point1 := points[i]
point2 := points[j]
return distance(point1[0],point1[1]) < distance(point2[0],point2[1])
})
return points[:K]
}
@Ahmah2009
Ahmah2009 / insert.go
Created April 4, 2019 06:27
57. Insert Interval leetcode
import "sort"
/**
* Definition for an interval.
* type Interval struct {
* Start int
* End int
* }
*/
func insert(intervals []Interval, newInterval Interval) []Interval {