Over the xmas period i found out that most of the files in my documents folder were corrupt. I didnt want to delete them all so i decided to see if Python could help and sure enough it did.
So i wrote a script below to;
- find all images in a folder and sub-dir’s
- open then with a python library and see if the file is corrupt
- move them to a folder and rename them
Massive help from people on stackoverflow.com
Im currenlty running my way though Laravel 5 the PHP framework and following some tutorials. If your starting this framework you will most likely run into the error below when you run your migrations;
Illuminate\Database\QueryException : SQLSTATE: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table
users add unique
The fix is simple;
Open the AppServiceProvider file and add the following line to the boot function;
class AppServiceProvider extends ServiceProvider
* Bootstrap any application services.
* @return void
public function boot()
//add this line to fix the error
* Register any application services.
* @return void
public function register()
how to add bootstrap:
npm install firstname.lastname@example.org jquery tether --save
add the scripts and styles to your “.angular-cli.json”
add the following the styles and scripts section;
create new project:
create new component:
ng g component components/mynewcomponent
create new service:
ng g service services/mynewservice
So over the christmas holidays ive been keeping myself busy by learning more about the Python language.
Having learnt a few basics i started to try the Django framework which ive seen mentioned quite a lot. Im reffering to windows mainly in this case see below for more detailed instructions;
Install python from the site below and install the necessary version for your Operating system.
Once you get that installed, verify that python is installed by typing “python” from the windows command prompt;
Install Django framework via command prompt;
pip install django
Create your first project its best to refer to the offical document and tutorials at;
From the offical site;
Creating a project
If this is your first time using Django, you’ll have to take care of some initial setup. Namely, you’ll need to auto-generate some code that establishes a Django project – a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings.
From the command line,
cd into a directory where you’d like to store your code, then run the following command:
<span class="gp">$</span> django-admin startproject mysite
This will create a
mysite directory in your current directory. If it didn’t work, see Problems running django-admin.
In addition to use an auto-increment key as the primary key, you may also use UUID columns. CakePHP will create a unique 36 character UUID (
Cake\Utility\Text::uuid()) whenever you save a new record using the
From the book;
So if you create your primary key field as char(36) , cakePHP3 will generate unique uuids rather than the stand auto-incremented 1,2,3 4 keys
Credit to stackoverflow again;
Heres a simple example of using the cache feature of cakephp. We want to grab a webpage contents from the web but we only want to do this once otherwise its going to be slow and waste resources.
The basic idea is that we check if the url is saved in cache, if it is then we read it in otherwise we must use curl to grab it.
CakePHP3’s Cache settings are in the config/app.php file;
* Configure the cache adapters.
'Cache' => [
'default' => [
'className' => 'File',
'path' => CACHE,
'url' => env('CACHE_DEFAULT_URL', null),
'duration' => '+60 minutes',//the duration object should cached for
/*'prefix' => 'mycacheprefix_',*/
CakePHP 3 Cache:
Ive finally gotten around to releasing this little app i was working on for Cakephp3. I decided a while ago to abandon Cakephp 2 and go with the new version 3.
Its been a steep learning curve so i wanted to learn as much as i could. So thats where this app/plugin came in.
The goal of the plugin was to allow a way to simply log tasks, changes or articles about the cakephp project your working on.
If your working on a website/project on your own you need a way to record your changes and tasks so i thought this would be an ideal way to learn and release something. Sure you could do the same with Github and better but i think its better to have something like this integrated into your application.
Screenshot: Version 1
Version 2 Screenshot:
Github & Source:
Cakephp 3 depends a lot on using composer, so youll need to get that first.; http://getcomposer.org/
Once youve set up composer you can create a brand new cakephp3 app by;
- Going to your web servers “htdocs” folder. I.e if your using xammp it should be; C:xampphtdocs
- Open a command windows here and type;
composer create-project --prefer-dist cakephp/app my_app_name
- Cakephp will create a folder in your htdocs folder called ” my_app_name”
- Open http://localhost/my_app_name
Cakephp 3 installation:
This is my first CakePHP plugin and first open-source project hosted on Github.
Its based on a jQuery Component by rawswift which adds a menu to the bottom of your site.
The project and full instructions are hosted on github, i will post a tutorial soon.