Skip to content

Instantly share code, notes, and snippets.

@archfizz
archfizz / random-background-color.html
Created August 16, 2013 10:58
Changes the background of a webpage to a random hex color and displays that hex value on the page.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Random Background Color</title>
<style>
h1 { color: white; text-align: center; font-family: sans-serif; }
</style>
</head>
<body>
require "bundler/capistrano"
set :application, "your_app"
# multistage
set :stages, ["staging", "production"]
set :default_stage, "staging"
require "capistrano/ext/multistage"
@archfizz
archfizz / build.xml
Last active December 17, 2015 03:08
A boilerplate Ant build script for a PHP app using Composer and PHPUnit, ideal for Jenkins CI.
<?xml version="1.0" encoding="UTF-8"?>
<project name="my-project" default="build">
<target name="build" depends="phpunit" />
<target name="composer" description="Installing dependencies with Composer">
<exec executable="wget" failonerror="true">
<arg value="-nc" />
<arg value="http://getcomposer.org/composer.phar" />
</exec>
@archfizz
archfizz / rmext.sh
Created April 14, 2013 11:16
Remove file extension from one file or from all files in working directory
## To remove a file extension from a given file
## Load the following function
rmext () {
if test -f "$1"
then
F=$1
E=${F#*.}
mv $1 `basename $1 .$E`;
fi
@archfizz
archfizz / gist:5232596
Created March 24, 2013 16:44
Work in progress - Symfony. 2 multiple file uploads
{{ form_widget(form.post_image, { 'attr': {'multiple': 'multiple' }}) }}
$form = $this->createFormBuilder()
->add('files','file',array(
"attr" => array(
"accept" => "image/*",
"multiple" => "multiple",
)
))
->getForm();
<?php
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @Entity
*/
class Document
{
@archfizz
archfizz / google-map-with-markers.js
Last active December 14, 2015 12:58
Just an example of adding Google Maps to webpage with markers (no jQuery required)
function initializeMaps() {
var GOOGLE_API_KEY = "";
var location = "Bristol";
var country = "UK";
var geocoder = new google.maps.Geocoder();
var markerBounds = new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById( "map_canvas" ), {