Skip to content

Instantly share code, notes, and snippets.

View philsturgeon's full-sized avatar
🌳
Planting Trees

Phil Sturgeon philsturgeon

🌳
Planting Trees
View GitHub Profile
@philsturgeon
philsturgeon / import_cars_test.go
Created November 23, 2014 18:10
Test Remote CSV Downlaod
package main
import (
"testing"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
)
@philsturgeon
philsturgeon / gist:11284868
Created April 25, 2014 10:30
Python UTF-8 Fun
Traceback (most recent call last):
File "facebook_cover.py", line 44, in <module>
photo = graph.put_photo(image_resource, album_id=payload['page_id'])
File "/task/__pips__/facebook.py", line 219, in put_photo
data = urllib2.urlopen(req).read()
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 418, in _open
@philsturgeon
philsturgeon / gist:8826220
Created February 5, 2014 15:35
PHP - So close, but yet so far.
$ python
Python 2.7.5 (default, Oct 21 2013, 17:28:33)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
[>>> [1, 3, 5] + [345, 6]
[1, 3, 5, 345, 6]
>>>
$ php -a
Interactive shell
@philsturgeon
philsturgeon / Options.md
Last active January 3, 2016 09:38
Array Of Syntax should represent the following code https://wiki.php.net/rfc/arrayof

Option A)

Null content items break things.

foreach ($foos as $foo) {
    if (! $foo instanceof Face) {
        throw new Exception ('AAAGGGGGHHH!');
    }
}
@philsturgeon
philsturgeon / stuff.md
Last active January 2, 2016 17:59
Framework Stuff Names

Following the assumption that part of what makes something a "framework" is that it dictates architecture, the "sample application" or "application layer" is what should be called the "Framework". In which case those people would label these repos differently.

https://github.com/laravel/laravel/ - This is the "framework"

https://github.com/illuminate - This is the "component vendor", where multiple "components" or "packages" can be found.

https://github.com/laravel/framework - This is... something other than "framework". FuelPHP use foundation, or maybe "kernel", or... something.

For other projects this distinction is different.

We had a long discussion about all of this over email (should have done that sooner) and here are most of the points for anyone reading this:

If you want to add a line in a twitter bio about Laravel, DO IT. If you want to put on your LinkedIn profile that you use Laravel on your projects, DO IT. You’re not hurting PHP. You’re helping it and anyone who was around during PHP’s dark days should know this.

I never suggested you shouldn’t do it, or that you would “hurt PHP”. I said branding yourself as a “Laravel developer” first is damaging to yourself. Lots of people branded themselves as a CodeIgniter developer for a while. What good has that done them now?

People will not be confused by this. Employers will not be confused by this. As someone who has probably looked at 1000 resumes for Laravel developers I’ve never seen even one where the only reference to anything PHP or development related is Laravel.

Here’s one. http://www.linkedin.com/profile/view?id=263426041&amp;authType=OUT_OF_NETWORK&amp;authToken=a0_e

@philsturgeon
philsturgeon / examples.php
Created November 26, 2013 19:35
Proposed short logical assignment operator
<?php
$foo = null;
// If's - verbose and uneccassry
if (! $foo) {
$foo = 'default';
}
// Short Ternary syntax
@philsturgeon
philsturgeon / README.md
Last active December 22, 2015 09:59
MySQL Enum Quiz

Preperation

Read the SQL statements in instructions.sql.

Question

Only one of the following queries will produce 1, the other two will produce 0.

Which query will produce the number 1?

@philsturgeon
philsturgeon / Syntax Examples.md
Last active December 22, 2015 02:39
PHP Named Param History

Example A

Inside the function declaration all values are assigned to variables, so using variable syntax on the outside seems to make sense too.

$api->getFriends($screen_name = 'phpdrama', $include_user_entities = true);

Pro:

@philsturgeon
philsturgeon / gist:6378999
Last active December 21, 2015 22:59
PSR-2 Control Structures and Statements

Class/method blocks:

These things are "blocks" of code, always on their own lines because they are always by themselves.

<?php
class Foo
{
  public function doSomeShit() 
 {