Skip to content

Instantly share code, notes, and snippets.

View alancoleman's full-sized avatar
:octocat:

Alan Coleman alancoleman

:octocat:
View GitHub Profile
@alancoleman
alancoleman / django-website.sh
Last active May 16, 2024 13:24
How to make a website with Python and Django
# This Gist is a list of resources and commands to accompany The Hackershack YouTube series.
# For this attempt I am using Linux / Ubuntu and the demo is on a mac, so I will note any differences as I go along
# BASICS (E01)
# https://www.youtube.com/watch?v=rA4X73E_HV0
# How to install ZSH on Ubuntu:
# https://www.redswitches.com/blog/install-zsh-#ubuntu/#:~:text=Zsh%2C%20or%20Z%20Shell%2C%20is,commands%2C%20and%20improved%20customization%20options.
@alancoleman
alancoleman / gist:56827605553aeabe96bccb6fcfa0f236
Last active May 14, 2024 09:11
Some basic docker commands
## Containers
# Show running containers
docker ps
# Show all containers
docker ps --all
docker ps -a
# Show all container ids
docker ps -q
# Create a container
# Compare branches
# Show name of files only
git diff [branch1] [branch2] --name-only
# Merge branches
# Merge with no auto commit
git merge [branch] --no-commit --no-ff
@alancoleman
alancoleman / php-csv-scrubber
Created November 23, 2016 10:18
PHP Script to scrub and save a csv file. This little script is designed to be used from the terminal, or an emulator like Konsole. The script is called and the csv to be processed is carried across as an argument, something like this: php csv_scrub.php /home/[you]/files/test.csv
echo "\n*** CSV Scrub ***\n"; // Message console
$csvFile = $argv[1]; // Define $csvFile from Konsole argument
/* File */
if (empty($csvFile)) { //Throw error if $csvFile not defined
echo "\n*** ERROR: Filename not specified ***\n"; // Message console
die();
} else {
@alancoleman
alancoleman / AddCompleteCampaignsUsingBatchJob.php
Last active July 29, 2016 09:12
AddCompleteCampaignsUsingBatchJob.php Using an already existing Campaign
<?php
ini_set('xdebug.var_display_max_depth', -1);
ini_set('xdebug.var_display_max_children', -1);
ini_set('xdebug.var_display_max_data', -1);
/**
* This code sample illustrates how to use BatchJobService to create a complete
* campaign, including ad groups and keywords.
*
@alancoleman
alancoleman / multidimensional_arr_sort.php
Created July 1, 2015 16:11
Sorting a multidimensional array
/*
array (size=4)
0 =>
array (size=2)
'screen_id' => string 'A0E6457F-EF4F-4BEF-811A-0ACE00AE6225' (length=36)
'name' => string 'Level 1 - Stalls' (length=16)
1 =>
array (size=2)
'screen_id' => string 'A34D24F8-B1C5-4E26-A1FE-91A3C13A4F10' (length=36)
'name' => string 'Level 2 - Dress Circle' (length=22)
@alancoleman
alancoleman / update_replace.sql
Created July 1, 2015 07:59
Replace characters in a column using update
UPDATE [table] SET url = REPLACE (url, 'a', 'b') WHERE [column] LIKE '%alan%';
-- Produces 'blbn'
@alancoleman
alancoleman / update_column_with_incremented_value.sql
Last active August 29, 2015 14:11
Update a table column with an incremented value
UPDATE table AS t
SET t.id = '';
SET @rank:=0;
update table AS t
set t.id =@rank:=@rank+1
@alancoleman
alancoleman / backup_database_table_using_mysqldump.sh
Created June 3, 2014 11:48
Backup database table using mysqldump
mysqldump -u [user] -p[password] database_name table_name > destination/backup_file.sql
@alancoleman
alancoleman / filter_email_on_domain.sql
Created April 17, 2014 11:56
Filtering email addresses on domains
AND (SUBSTRING_INDEX(SUBSTR(email, INSTR(email, '@') + 1),'.',1)) IN('yahoo', 'ymail', 'bt', 'rocketmail', 'msn', 'live', 'hotmail')