Skip to content

Instantly share code, notes, and snippets.

@Humoud
Humoud / syn-poc.rb
Last active August 13, 2016 09:39 — forked from KINGSABRI/syn-poc.rb
Build TCP/IP packet using packetfu lib, and send syn(or whatever you want) packet
#!/usr/bin/env ruby
# Full Contol on Ethnet, IP & TCP headers. Play with it ;)
# to test it: nc -lvp 4444
# as root: tcpdump -nvvvv 'tcp port 4444' -i wlan0 # change wlan0 to your interface
# or use packetfu to monitor as tcpdump
# on OSX exchange wlan0 to en0
## cap = PacketFu::Capture.new(:iface => 'wlan0' , :promisc=> true)
## cap.show_live(:filter => 'tcp and port 4444')
# libpcap should be installed
# gem install pcaprub packetfu
@Humoud
Humoud / optionals.swift
Created July 8, 2016 12:22
Optionals in Swift. What are they and how to work with them.
// Here we demonstrate working with Optionals in Swift
// in Swift, Optionals are basically the type which is allowed to hold (reference to be more accurate) a null (nil).
// We use "?" to declare an optional
var age: Int?
if age == nil {
// Since age is nil
// This will be executed
print("There is no age")
@Humoud
Humoud / functions.swift
Created July 7, 2016 15:14
Here we demonstrate functions in Swift. Concentrating on three points: Pass-by-Value, Pass-by-Reference, and External Name / Internal Name.
// Here we demonstrate functions in swift
// Concentrating on three points:
// * Pass-by-Value
// * Pass-by-Reference
// * External Name / Internal Name
//
// Drop this in a playground to see instant results.
func combineStr(str1: String, str2: String) -> String {
@Humoud
Humoud / facts_rules.pl
Created March 21, 2016 07:14
Some notes I gathered on Prolog. Consider this a mini intro to Prolog. Will improve this gist as I continue to learn Prolog.
/*
To run this:
open command prompt execute 'swipl'
then run ['path/to/this/file.pl'].
then query away.
*/
% FACTS
likes(jana, omar).
likes(omar, jana).
@Humoud
Humoud / regex-arabic.md
Last active March 21, 2025 00:55
Detecting arabic characters with regex.

Detect all Arabic Characters:

/[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufbc1]|[\ufbd3-\ufd3f]|[\ufd50-\ufd8f]|[\ufd92-\ufdc7]|[\ufe70-\ufefc]|[\uFDF0-\uFDFD]/

Summary:

  Arabic (0600—06FF, 225 characters)

  Arabic Supplement (0750—077F, 48 characters)
@Humoud
Humoud / Rails.rb
Last active March 16, 2016 08:47
A mix of notes, conventions, and snippets for working with RoR.
# This URL was useful: https://gist.github.com/iangreenleaf/b206d09c587e8fc6399e
############################################################
################### ROUTES ####################
############################################################
get 'welcome/home', to: 'welcome#home' # HTTP GET /welcome/home to controller: welcome action(Method): home.
# Should have controller WelcomeController < ApplicationController
# controller should have action(Method) home
# should have a template (view) in app/views/welcome/home.html.erb
@Humoud
Humoud / db-connect-test.php
Last active March 7, 2016 11:42 — forked from chales/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
###
# NOTE: This code won't work with PHP 7.
# MySQL is deprecated and will be removed in PHP 7 checkout MySQLi.
###
############## JUST FILL THESE VARIABLES ######
$dbname = 'name'; # Name of the Database in the MySQL Server
$dbuser = 'user'; # User name of the database in MySQL
$dbpass = 'pass'; # Password for the user of in database in MySQL
$dbhost = 'host'; # url/link to database
@Humoud
Humoud / Heroku_PostgreSQL.md
Created March 7, 2016 08:06
A cheat sheet for dealing with PostgreSQL database on Heroku.

General Commands

To reset a database (The closest thing to dropping a DB):

heroku pg:reset DATABASE --confirm db-name

Pushing you local database with it's data:

heroku pg:push local-db-name heroku-db-name --app app-name

Rails Specific Commands

Runing migrations and seed script on the database

heroku run rake db:migrate

@Humoud
Humoud / docker.md
Last active March 30, 2016 13:41
Docker notes from this video: https://www.youtube.com/watch?v=qidknGXzvf0

Note: dm is an alias for docker-machine

List Machines

dm ls

Create Docker Machine

dm create -d virtualbox hello-world

View Machine's Env Vars

dm env hello-world

@Humoud
Humoud / ActiveRecord.md
Last active March 30, 2016 06:45
A cheat sheet for Rail's Active Record.

Assume we have model Car

# Get all cars with color red
Car.where( color: "red" )

Retrieve all users that have field 'company' not nil