Skip to content

Instantly share code, notes, and snippets.

@pavinjosdev
pavinjosdev / validate_cidr.php
Last active February 23, 2023 15:19 — forked from mdjekic/validate_cidr.php
PHP function for validating CIDR notation format (ipv4, ipv6)
<?php
/**
* Validates the format of a CIDR notation string
*
* @param string $cidr
* @return bool
*/
function validateCidr($cidr)
{
@davebarnwell
davebarnwell / PHP composer tools.md
Last active April 3, 2024 09:11
Global installation of PHP tools with Composer

Global installation of PHP tools with Composer

To install a composer package globally, you run the usual require command, but with the addition of the global modifier. So to install PHPUnit, you would run:

$ composer global require phpunit/phpunit
$ composer global require phpunit/dbunit
$ composer global require phing/phing
$ composer global require phpdocumentor/phpdocumentor
$ composer global require sebastian/phpcpd
@shadowhand
shadowhand / .gitconfig
Created March 9, 2016 02:34
You just need a bigger hammer!
[alias]
fixlock = ! git reset HEAD -- composer.lock && git co -- composer.lock && composer update --no-scripts && git add composer.lock
@garystafford
garystafford / v1-ubuntu-docker-node-apt-get.sh
Last active November 18, 2022 11:27
Install the latest versions of Node.js and npm into a Docker Ubuntu container, with or without need for root access. Easily update both applications to the latest versions. Creates a new user account ('testuser') and installs common npm packages.
###############################################################################
# Version 1: using ‘apt-get install’
# Installs using apt-get
# Requires update to npm afterwards
# Harder to get latest copy of node
# Requires sudo to use npm
###############################################################################
# create new docker ubuntu container
sudo docker run -i -t ubuntu /bin/bash # drops you into container as root
@wh1tney
wh1tney / deploy-static-site-heroku.md
Last active April 23, 2024 17:49
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions

@cuth
cuth / serve.js
Created April 14, 2014 17:21
Run a local express server on the current directory's static files using node
var host = "127.0.0.1";
var port = 1337;
var express = require("express");
var app = express();
app.use('/', express.static(__dirname + '/'));
app.listen(port, host);
console.log('Running server at http://localhost:' + port + '/');
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@pbuyle
pbuyle / FeatureContext.php
Last active January 25, 2024 23:25
Behat step-definition to verify visibility (not just presence) of Drupal form elements.
<?php
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
/**
@romaricdrigon
romaricdrigon / formController.js
Created August 21, 2013 07:46
Using AngularJS on Symfony2 forms
// An example controller binded to the form
function FormCntl($scope, $compile) {
// Consider using FosJsRouting bundle, if you want to use a Symfony2 route
$scope.formUrl = "http://url-to-fetch-my-form";
// Data from the form will be binded here
$scope.data = {};
// Method called when submitting the form
$scope.submit = function() {