The ClanCats blog, no super fancy layout just all sort of information, stories and thoughts about coding, clancats and my other projects.

Navigation

Storing Shakespeare's "Hamlet" invisibly inside an image

So, along time ago i came up with an idea to be able the send around secret messages masked as normal images. I called it Jailbird. Did you ever found yourself stuck in jail and needed to send out some information to run your business, without the guardians noticing? Well than this library is the solution you have been looking for! Obviously im joking, this thing is an experiment. This practice is called Steganography. Today I…

How do I profile my PHP script performance on OSX?

Sounds easy eh? Well it is but i had to face some challenges to get things to work. And sharing is caring right ha! (sarcastic laughter*) The fast fast way If you don't have Xdebug installed and just wan't to short test how much time something inside your scripty script consumes, you could go the php way. Lets be honest it doesn't happen really often in the daily PHP life that you have to profile a…

How to do something every x clicks in PHP

There are many situations where you need to do somthing sometimes but not on every single request. There are many ways to archive this, you could implement a DB or file based counter. But if it is not important that it happens exactly after x request then this simple trick or snippet might help you out when you find yourself in a situation like: How do I cache my data for x requests? Or: Hmm how…

Writing a webserver in pure PHP - Tutorial

Well, this is pretty useless, but it is possible. But again its pretty.. uesless. This tutorial will hopefully help you to better understand how a simple webserver could work and that it's no problem writing one in PHP. But again using this in production would be trying to eat a soup with a fork. So just, .... just don't. Let me shortly explain why this is not a that good idea. PHP is a scripting language that…

Preventing users from sending their passwords to others.

Even if your application is rock solid there will always be that one user who complains beeing hacked. After some research through the logs you find out, that guy send his password to another one for whatever reason. There is no such thing as a 100% secure application, also you cannot expect the user being smarter than a fly. But you can stop him at least a bit from throwing his private data everywhere. A simple…

3 Vagrant settings you should check out to optimize your VM.

About a month ago I started switching my local environment to a Vagrant VM. ( I know im pretty late. ) Im still a vagrant noob but there are 3 things i've learned so far. Use NFS ( Network File System ) The default synced_folder driver (VirtualBox) works well until you start importing a bigger project. If you have more than about 100 files the performance is going suck. But there is a solution! By simply configuring the synced…

Amazon Elastic Transcoder PHP Example

Don't get me wrong the documentation of the amazon web services are great, but for the elastic transcoder I just wanted a little piece of example code so I don't have to filter an 300 line arguments array for a simple operation. Aws PHP SDK Don't forget to install the AWS PHP SDK using composer. "require": { "aws/aws-sdk-php": "2.7.*@dev" } Example I'm not going to explain how to setup the transcoding pipeline on the aws…

Useful PHP helpers: array_pick

A long time ago I added this helper to CCF's CCArr class. If you are doing a lot of Database operation you will come often to the point where you have to get a value from every row. Obviously it's not hard to write a loop doing that, but this way you will repeat yourself. This mini helper makes you write a little less code. Which is good! Usage Of course the implementation into your framework…