Skip to content

Instantly share code, notes, and snippets.

View leek's full-sized avatar

Chris Jones leek

View GitHub Profile
@leek
leek / fizzbuzz.js
Created September 9, 2014 06:58
FizzBuzz solutions in various languages.
for (var i = 1; i <= 100; i++) {
if (i % 15 === 0) {
console.log('FizzBuzz');
} else if (i % 3 === 0) {
console.log('Fizz');
} else if (i % 5 === 0) {
console.log('Buzz');
} else {
console.log(i);
}
@leek
leek / PhpunitController.php
Created January 6, 2012 15:47
PhpunitController for Symfony2
class PhpunitController extends Controller
{
public function runTestsAction($filterClass = null)
{
// Make sure PHPUnit is autoloaded
require_once('PHPUnit/Autoload.php');
set_time_limit(0);
$version = \PHPUnit_Runner_Version::id();
@leek
leek / rounded_corners_table.sass
Created January 20, 2012 02:39 — forked from Samnan/rounded_corners_table.sass
Here's how to do a table with rounded corners in CSS3 -- Updated: Fixed bug where bottom left corner wouldn't be rounded with only one TD in last TR
@import compass/reset
@import compass/css3/border-radius
table
border: none
border-collapse: separate
th, td
padding: 5px
thead
background-color: #f2f6fa
@leek
leek / pagination.html.twig
Created January 20, 2012 03:00
KnpPaginatorBundle - pagination template
<div class="pager">
{% if first is defined %}
<span class="first">
{% if current != first and first < 0 %}
<a href="{{ path(route, query|merge({'page': first})) }}">first</a>
{% else %}
first
{% endif %}
</span>
{% endif %}
@leek
leek / migrate.sh
Created March 15, 2012 07:10
Rackspace Cloud Sites Migration Utility Script
#!/bin/bash
#
# @author: Chris Jones <leeked@gmail.com>
# @version: 1.1.0
#
# Rackspace Cloud Sites only allows running scripts via their web-based "cron" tool.
# FTP this script into your Web directory and add it to the scheduled tasks section.
# Set the "Command Language" to: perl
# Set the "Command to Run" to: migrate.sh refreshdb
@leek
leek / ExampleController.php
Created March 23, 2012 07:44
Symfony2 Event Listener that allows you to set Response parameters and still use the @template annotation from the SensioFrameworkExtraBundle
<?php
namespace Example\AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller,
Symfony\Component\HttpFoundation\Request,
Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class ExampleController extends Controller
{
@leek
leek / post-receive-pivotal.rb
Created May 4, 2012 18:14 — forked from pewniak747/post-receive-pivotal
Ruby Git post-receive hook to update Pivotal Tracker
#!/usr/bin/env ruby
# encoding: UTF-8
# file: hooks/post-receive-pivotal
require 'net/http'
require 'nokogiri'
# Ruby 1.8.7
class String
def force_encoding(enc)
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@leek
leek / magento_urls.sql
Created July 8, 2013 21:53
Magento: Fix Hardcoded URL's in Database
UPDATE cms_block SET content = REPLACE(content, "http://www.example.com/", "{{store url=''}}");
UPDATE cms_page SET content = REPLACE(content, "http://www.example.com/", "{{store url=''}}");
--
-- AW_Blog Only
--
UPDATE aw_blog SET post_content = REPLACE(post_content, 'http://www.example.com/', "{{store url=''}}");
<?php
namespace app\controllers;
use app\models\Downloads;
class DownloadsController extends \lithium\action\Controller {
public function index() {
$this->request->privateKeys = array('id', 'user_id');