Skip to content

Instantly share code, notes, and snippets.

View johnmcc's full-sized avatar

John McCollum johnmcc

  • Glasgow, Scotland
View GitHub Profile
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
@johnmcc
johnmcc / 360.make
Last active October 6, 2015 01:17
Standard Drush make file
core = 7.23
api = 2
projects[drupal][version] = "7.23"
; Modules
projects[] = ctools
projects[] = devel
projects[] = entity
projects[] = features
projects[] = fences
@johnmcc
johnmcc / gist:3992655
Created November 1, 2012 09:15
Loading field collections as entities from Drupal templates
<?php
foreach($content['field_my_field_collection']['#items'] as $entity_uri) {
$item = entity_load('field_collection_item', $entity_uri);
foreach ($item as $entity_obj) {
dpm($entity_obj->field_my_individual_field);
}
}
?>
<?php
// Link to /download_file/$fid to force download rather than view in browser
/*
* Implements hook_menu()
*/
function download_file_menu(){
$items = array();
$items['download_file/%'] = array(
@johnmcc
johnmcc / gist:4556510
Created January 17, 2013 15:01
Embedding a view programmatically
<?php // view, display, any additional contextual filters ?>
<?php $view = views_embed_view("view_name", "display_name", $node->nid); ?>
<?php if(strpos($view, "view-content") !== FALSE){ ?>
<?php echo $view; ?>
<?php } ?>
@johnmcc
johnmcc / gist:5747325
Created June 10, 2013 08:44
Create zip archive with changes between two commits.
git archive -o latest.zip later-commit $(git diff --name-only earlier-commit later-commit)

Java problems.

Choose one:

Task 1

  • Write a guessing game where the user has to guess a secret number.
  • After every guess the program tells the user whether their number was too large or too small.
  • At the end the number of tries needed should be printed.
# USE THIS SCRIPT AT YOUR OWN RISK
# Make sure your work is backed up / in version control.
# Quick and dirty script to recursively replace all
# headers of the format ###heading with ### heading.
# (Works through all .md files in the directory, and subdirectories)
filelist = Dir.glob("**/*.md")
for filename in filelist

Online Shop.

Model an online shop.

You are tasked with creating an e-commerce platform. Your online store may sell anything you wish. It could be a niche, boutique store or a more general 'amazon' type. Customers will log in, add items to their basket and purchase them.

Your shop should include; A stock class with quantity, price and availability.

stops = ["Croy", "Cumbernauld", "Falkirk High", "Linlithgow", "Livingston", "Haymarket"]