Skip to content

Instantly share code, notes, and snippets.

@tournasdim
tournasdim / app.js
Last active Jan 28, 2018
#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.
View app.js
// 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;
}
View Alpha AWUS036NH on Kali 2.0 VirtualBox
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
@tournasdim
tournasdim / gist:d317830a9d494dc502ad
Last active Dec 31, 2015 — forked from ah01/gist:762576
const.pde Arduino predefined constants
View gist:d317830a9d494dc502ad
//
// This sketch will print some of interesting predefined constants to Serial.
//
// For more information, look at
// http://electronics4dogs.blogspot.com/2011/01/arduino-predefined-constants.html
// helper macro
#define LINE(name,val) Serial.print(name); Serial.print("\t"); Serial.println(val);
void setup()
@tournasdim
tournasdim / new_gist_file.php
Created Jul 13, 2014
An example of PHP's preg_replace_callback
View new_gist_file.php
// This function is part of Laravel's ./Illuminate/Support/helpers.php:663:
function preg_replace_sub($pattern, &$replacements, $subject)
{
return preg_replace_callback($pattern, function($match) use (&$replacements)
{
return array_shift($replacements);
}, $subject);
}
@tournasdim
tournasdim / bootstrap.php
Created Jun 27, 2014
A simple example how to handle errors in Silex
View bootstrap.php
use \Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
$app->error(function (\Exception $e) use ($app) {
if ($e instanceof NotFoundHttpException) {
return $app->json(array('error' => 'Page Not Found'), 404);
}
$code = ($e instanceof HttpException) ? $e->getStatusCode() : 500;
return $app->json(array('error' => $e->getMessage()), $code);
});
@tournasdim
tournasdim / terminal
Created Jun 27, 2014
Assign permissions to Apache to specified web-directories (Cache dir)
View terminal
rm -rf app/cache/*
rm -rf app/logs/*
APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd' | grep -v root | head -1 | cut -d\ -f1`
sudo chmod +a "$APACHEUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
View symfony2.md

Symfony2

Files loaded on standard edition request (253)

  • Acme\DemoBundle\AcmeDemoBundle
  • Acme\DemoBundle\Controller\DemoController
  • Acme\DemoBundle\EventListener\ControllerListener
  • Acme\DemoBundle\Twig\Extension\DemoExtension
  • Assetic\Extension\Twig\AsseticExtension
  • Assetic\Extension\Twig\ValueContainer
@tournasdim
tournasdim / .gitignore
Created Jun 3, 2014 — forked from octocat/.gitignore
Using a global ".gitignore" file for common files . https://help.github.com/articles/ignoring-files
View .gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@tournasdim
tournasdim / index.html
Created May 31, 2014
Angular Google CDN links
View index.html
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-animate.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-cookies.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-resource.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-route.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-sanitize.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-touch.min.js"></script>
@tournasdim
tournasdim / index.php
Created May 31, 2014
A simple web-app build on top of Symfony's Request,Response,HttpKernel,Route,RouteCollection components
View index.php
<?php
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
use Symfony\Component\HttpKernel\EventListener\RouterListener;
use Symfony\Component\Routing\Matcher\UrlMatcher;