Skip to content

Instantly share code, notes, and snippets.

@tournasdim
tournasdim / yaml
Last active April 19, 2024 22:42
Homestead.yaml file . Example directives for setting up shared folders (between host and guest machine), defining apache and php8.1 as default directives
---
ip: "192.168.56.56"
memory: 2048
cpus: 2
provider: virtualbox
folders:
- map: C:/Users/User/Documents/laravelstuff/my-projects
to: /home/vagrant/laravelstuff
@tournasdim
tournasdim / Vagrant
Created April 13, 2024 15:51
A Vagrant file for an Ubuntu PHP development server . Virtualbox 7 as Provider , Shell as Provisiner , Apache , PHP v8.1 , Mysql 8 , Composer .
# -*- mode: ruby -*-
# vi: set ft=ruby :
# this script loads an Ubuntu 22.04 LTS (Jammy Jellyfish) development server (!!!! not for production )
# If it doesn't load the php-module into apache2 server ( to verify use the "phpinfo();" into a index.php file )
# So we have to manualy login with "vagrant ssh" and use cli command for investigation
# 1) apachectl -M | grep php --> list of all apache's loaded modules (static , shared)
# 2) ls /etc/apache2/mods-available --> if php mod not listed, make an installation with apt-get
# sudo apt-get install libapache2-mod-php8.1 and sudo a2nmode php
# --- OR ---
@tournasdim
tournasdim / Schema.php
Created June 29, 2013 16:58
A list of Laravel's Schema commands (Laravel 4)
<?php
Schema::create('users' , function($table)
{
$table->increments('id'); Incrementing ID to the table (primary key).
$table->string('email'); VARCHAR equivalent column
$table->string('name', 100); VARCHAR equivalent with a length
$table->integer('votes'); INTEGER equivalent to the table
@tournasdim
tournasdim / Mail.php
Created June 25, 2013 07:38
Sending mail without attachment using the PHPMailer Class
<?php
/*
First downlaod the library from Google
http://code.google.com/a/apache-extras.org/p/phpmailer/
*/
require_once 'class.phpmailer.php';
$mail = new PHPMailer(true);
$to = "sendmailto@gmail.com";
@tournasdim
tournasdim / GravatarServiceProvider.php
Created June 29, 2013 18:28
A Laravel ServiceProvider example (Laravel 4)
<?php namespace Tournasdim\Getgravatar;
use Illuminate\Support\ServiceProvider;
class GravatarServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
@tournasdim
tournasdim / Bootstrap-nav.html
Created September 1, 2013 11:43
Bootstrap , navbar with Fontawesome and CDN links
<!doctype html>
<html>
<head>
<!-- http://fortawesome.github.io/Font-Awesome/get-started/ -->
<meta charset="utf-8">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<title>Navbar with dropdowns</title>
</head>
@tournasdim
tournasdim / app.js
Last active January 28, 2018 12:39
#nodejs Enclosure . Fun Facts : Being that enclosures have access to their outer functions variables and parameters, this allows the enclosures to be called later after the function returns and still be able to have access to these variables.
// Reference : JavaScript for Experienced Developers
// https://www.youtube.com/watch?v=h50lRx3Myfo&list=PLknneukDQdN9sz45rtMkT3k0uq36d7rGj&index=141 (min 17:00)
function setFirstname(firstname) {
function appendLastName (lastname) {
console.log("My fullName is : " + firstname + " " + lastname );
};
return appendName;
}
@tournasdim
tournasdim / Bootstrap.php
Last active December 6, 2017 06:40
#Doctrine Doctrine 2 One-To-Many, Bidirectional example . Replacing "Simple Annotation Reader" by "Extended Annotation Reader) . Notions are now defined by "@Orm\xxx" instead of "@xxx" .
<?php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
//use Doctrine\ORM\Mapping\Driver\AnnotationDriver ;
//use Doctrine\Common\Annotations\AnnotationReader ;
require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../config/config.php';
@tournasdim
tournasdim / PDOExample.php
Created June 25, 2013 05:05
PDO prepared statement example (with/without POST-data)
<?php
// PDO without prepared statement
$connStr = 'mysql:host=localhost;dbname=world' ;
try
{
$conn = new PDO($connStr, 'root', '');
}
catch(PDOException $pe)
{
Help from here: http://gitm8.com/running-awus036nhr-in-virtualbox-kali/
and here: http://www.fixedbyvonnie.com/2015/04/welcome-to-kali-linux-part-2-of-3/#.VkPK8q6rTdQ
Adapter: http://www.amazon.com/gp/product/B0035APGP6
1. Download the VirtualBox image for Kali 2.0
2. Import it into VirtualBox
3. Set up the machine as normal
4. In the network tab disable the network interfaces
5. Change to the Ports tab
6. Change to the USB portion of the Ports tab