Skip to content

Instantly share code, notes, and snippets.

View astannard's full-sized avatar

Andy Stannard astannard

View GitHub Profile
@astannard
astannard / Git workflow
Created July 13, 2016 07:40
Git workflow for setting up initial project
#Initial Project Setup such as run a yeoman to setup a project
#initialize local git directory
git init
#add everything to git
git add .
#Now we actually commit the files to git with the message initial
git commit -m initial
@astannard
astannard / NPMPermissionIssues.txt
Last active July 13, 2016 07:20
NPM permission issue resolution
As per photusenigma at: https://github.com/npm/npm/issues/4815
Run these commands in a terminal window (note - DON'T replace the $USER part...thats a linux command to get your user!):
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules
...and...if you're on a mac (like I am), and still see errors after running these commands, then run this last one and you should be good. (Recommend you try testing before you do this one. I don't like changing the permissions on the ENTIRE /usr/local directory unless it really seems necessary!)
sudo chown -R $USER /usr/local
@astannard
astannard / lightning talk proposal.md
Last active June 13, 2016 11:59
React Conference lightning talk proposal

With all the plugins, boilerplate projects, SAAS and PAAS offerings plus great community support, what can be created in a weekend?

I will take you through the ups downs and highlights of using react at a Startup Weekend event, showing what can be achieved and how.

This will be a story of a wild weekend full of tips, framework and plugin summaries plus pictures from the weekend as the startup team attempt to validate an idea.

The talk will be a great insight into how react can help you rapidly prototype a business idea, with what went well and what went badly.

https://reactiveconf.com/

@astannard
astannard / gist:b975d757fe9c0b05b102edb192abb4f3
Created June 7, 2016 12:16
Lightning Seed - React Conference lightning talk proposal
With all the plugins, boilerplate projects, SAAS and PAAS offerings plus great community support, what can created in a weekend?
I will take you through the ups downs and highlights of using react at a Startup Weekend event, showing what can be achieved amd how.
This will be a story of a wild weekend full of tips, framework and plugin summaries plus pictures from the weekend as the startup team attempt to validate an idea.
The talk will be a great insight into how react can help you rapidly prototype a business idea, with what went well and what went badly.
https://reactiveconf.com/
@astannard
astannard / gist:067fe748081846a1656b
Created February 23, 2016 08:36
Javascript function constructors
//Function constructors use the New keyward that create a new object in memory that then becomes the this scope inside of the contructor functoim
//Using the prototype syntax to add methods to the constructed object means that multiple objects take up less memoryspace since a new copy of
//each function is not added into memory space for each object.
function Person(firstname, lastname){
this.firstname = firstname;
this.lastname = lastname;
}
var varl = new Persion('carl','brown');
@astannard
astannard / gist:5e786f024360c7d9f1f7
Created February 18, 2016 08:17
Javascript this
this varies depending on the execution context and can sometimes lead to unexpected behaviour
ways of tackling this are:
newname = functionname.bind(object); // calling the bind method which exists on all JS functions creates a copy of the function
// with this scoped to the value of the object passed into the bind method.
newname(arg1,arg2); // newname will then need to be executed
@astannard
astannard / gist:6273f4aa7aab9eed97ed
Last active January 27, 2016 09:54
Redux Notes
1/ 1 object to represent the whole set of app data
2/ State is read only
3/ Pure functions dont modify arguments and dont rely on anytihng other than arguments passed to them to calculate
4/ UI is a representation of application state,
5/ State changes use pure functions so you take the existing state and the action to calculate a new state from, then pass that back. (testable and predictable). The new state can still reference old objects that made up the previous state if these have not been modified
6/ Reducer function takes the state and action arguments to create new state. (an action is the minimum set of arguments needed to create a new state object from its previous state
7/ If reducer recieved undefined as its stateargument it must return what is to be considered the inital state of the application
8/ If a reducer recieves an unknow action it mus return the existing state
@astannard
astannard / gist:1eabd0e7877a5409a243
Created July 6, 2015 14:47
function to serialize a form to JSON
$.fn.serializeObject = function () {
var o = {};
var a = this.serializeArray();
$.each(a, function () {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
@astannard
astannard / gist:6d17552d83c83b9e4d56
Created April 14, 2015 07:38
iOS Swift Post Request Example
var request = NSMutableURLRequest(URL: NSURL(string: "https://api.nutritionix.com/v1_1/search/")!)
let session = NSURLSession.sharedSession()
request.HTTPMethod = "POST"
var params = [
"appId" : kAppId,
"appKey" : kAppKey,
"fields" : ["item_name", "brand_name", "keywords", "usda_fields"],
"limit" : "50",
"query" : searchString,
"filters": ["exists":["usda_fields": true]]
@astannard
astannard / gist:15ff8b5b2a7198c2ebff
Created February 4, 2015 10:47
create an ios in OSX from a folder
hdiutil makehybrid -o ~/Desktop/image.iso ~/path/to/folder/to/be/converted -iso -joliet