Skip to content

Instantly share code, notes, and snippets.

View bigcalm's full-sized avatar

Iain Cuthbertson bigcalm

View GitHub Profile
@bigcalm
bigcalm / post-os-install-dev-setup.md
Last active May 24, 2020 14:11
Things I do / install after performing a fresh OS install

Post distro install things

Consider this a work in progress forever more.

Development

  • zip
  • unzip
  • ack
  • git
  • git-flow
@bigcalm
bigcalm / create_country_code_array_from_iso-3166-1_data.php
Created June 20, 2014 11:08
Create a PHP array from the iso-3166-1 data, found on Wikipedia, that can be copy/pasted into code
<?php
// idea based upon http://www.hashbangcode.com/blog/php-array-countries
// copy/paste from http://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements
$countriesString = "Afghanistan AF AFG 004 ISO 3166-2:AF
Åland Islands AX ALA 248 ISO 3166-2:AX
Albania AL ALB 008 ISO 3166-2:AL
Algeria DZ DZA 012 ISO 3166-2:DZ
American Samoa AS ASM 016 ISO 3166-2:AS
Andorra AD AND 020 ISO 3166-2:AD
@bigcalm
bigcalm / leech.php
Last active June 4, 2017 18:12
Soundcloud playlist download
<?php
$baseDir = "mp3s";
$soundcloudURL = "http://soundcloud.com/ninja-tune/sets/solid-steel-radio-shows/";
$urlBits = str_replace('http://', '', $soundcloudURL);
$urlBits = preg_replace('@/$@', '', $urlBits);
$urlBits = explode("/", $urlBits);
/**
* http://soundcloud.com/ninja-tune/sets/solid-steel-radio-shows/
<?php
namespace My\Bundle\BlockBundle\Block;
use Symfony\Component\HttpFoundation\Response;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Block\BaseBlockService;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
@bigcalm
bigcalm / fail_demo.html.twig
Created February 6, 2013 14:38
Using Symfony2, DQL and knplabs/knp-paginator-bundle - how to get around "Cannot count query which selects two FROM components, cannot make distinction"
<ul>
{% for project in pagination %}
<li>{{ project.name }} has {{ project.?? }} tasks</li>
{% endfor %}
</ul>
@bigcalm
bigcalm / FooRepository.php
Created February 4, 2013 08:41
Making an entity repository container aware in Symfony2.1
<?php
namespace Acme\DemoBundle\Repository;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Doctrine\ORM\EntityRepository;
/**
@bigcalm
bigcalm / 48bit_test1.php
Created January 22, 2013 23:28
Create a 48bit integer suitable for use with pack() in PHP
<?php
$topUp = 100;
list($integerPart1, $integerPart2) = convertTo48bit($topUp);
$packedInteger = pack("vV", $integerPart1, $integerPart2);
echo json_encode($packedInteger) . "\n";