scroll down and right
Things I learn along the way, I keep here. Life, lessons and betterment through code.
scroll down and right
I never have time, so this will be quick.
Let’s say we want to find a pixel index amoung all that image data canvas returns with:
The formula is simple:
Basically, you need to draw this one out. Let’s say we have a 3×3 image. Each pixel would have it’s own zero based index. The width would be three. Each row would stretch from 0 – 2 and each column would stretch from 0 – 2.
Now let’s say we want to select the 7th pixel. We know the formula is:
index => (y * w + x)
So we can calculate the index by selecting Row 2 and Column 1. Just like battleship.
The only confusing part is why we should multiply by 4 at the end! It’s simple really, there are 4 values for every pixel (r,g,b,a).
To loop through and get the index for every pixel, might look something like:
Just wanted to post this. The source is pretty self explanatory and i’ll put up a github later once I clean up a few things.
I’ll explain later. Be patient, it takes a second to load.
So you’ve been making ajax calls and everything is going great.
Your onSuccess message looks something like this:
All of a sudden your QA professional says things aren’t working in iOS8!
No prob, bob. It’s actually that iOS8 and below doesn’t return a “responseURL” attribute of the xhr object. Look at the difference:
iOS8 xhr object:
This one is quick.
Usually you can do:
But sometimes you need to vertically center something without the use of transforms.
Here’s a little snippet:
If you don’t know the height of the parent (as is most cases) this might work:
And here’s a little demo. The “marker” div is using transforms. The “centered” div isn’t:
I know I know…
You’re afraid of the CLI, there’s not a good chrome extension and you can’t be bothered to boot up Firefox just for s3fox…
Dude, the CLI is so simps:
There’s a great post about securing your new linux server (ubuntu) here:
I wanted to summarize here and explain some details.
You should be all set! There’s of course more detail at the other page, but in general, these steps will ensure you have a decently secure system.
Now all you need to do is watch what you upload to the server!
If you lose your box tool:
You can get it back by selecting it, as I’ve done in the photo above, then hitting “cmd + shft + 5”
Super simple edit the file:
Uncomment the following:
Then add an .htaccess file to your root:
Restart MAMP and it should work like a charm!
So here’s the sitch yo:
You have kaleidoscope as your diff tool. You go to make a patch:
Then you realize that it’s opening kaleidoscope instead and not exporting your diff to a file.
Well the problem is you’re using the wrong program. Do something like this:
Now you’re using the right diff tool!
Then you can apply the patch like this: