Why clearRect Might Not be Clearing the Canvas Pixels

Sometimes the clearRect(x, y, width, height) method on the canvas context might not erase the previous graphics drawn. This usually happens when we’re drawing paths using methods like lineTo(), arc(), rect(), etc. and then stroking them with stroke() or filling their content area using fill(). Here’s an example of what I’m trying to convey.

Continue reading “Why clearRect Might Not be Clearing the Canvas Pixels”

Mini HTML/CSS/JS Code Playground (with Editors and Sandbox) in Less than 200 Bytes

Sometime back this thread on HackerNews gained quite some traction. Basically, it’s a small project called MiniCodeEditor which is a tiny and minimal version of an online code playground like CSSDeck.

Continue reading “Mini HTML/CSS/JS Code Playground (with Editors and Sandbox) in Less than 200 Bytes”

Basic Steps Taken to Diagnose and Fix a Compromised or Heavy Resource Consuming Server

Recently one of my servers most probably got hacked (compromised). As I logged into my linode manager it said 200% bandwidth usage and it was growing at about 1gb per 1-2 mins (checked with iftop). So I opened a support ticket and asked a couple of linode fellows for help.

Continue reading “Basic Steps Taken to Diagnose and Fix a Compromised or Heavy Resource Consuming Server”

Laravel Render a View and Store the Contents in a Variable

Sometimes one may want to load a View with some PHP data passed to it and store it in a variable inside the Controller’s action. This rendered view data might be later passed to another view which is finally loaded and dumped to the user’s screen.

Continue reading “Laravel Render a View and Store the Contents in a Variable”

Parse and Read Excel Files (xls/xlsx) With JavaScript

Recently there was a requirement in one of my projects to parse Excel files (with xls/xlsx extensions) in the browser (using javascript ofcourse). So I looked around a bit on the internet and found these two useful libraries:

js-xls
js-xlsx

Lets see how to work with each of them.

Continue reading “Parse and Read Excel Files (xls/xlsx) With JavaScript”

Manipulate and Extract/Burst PDF Files Into Images, Text and Other Components with Docsplit

Docsplit is a command line utility written in Ruby (can be used as a Ruby library too) that can be used for splitting apart documents like PDF (Portable Document Format) into their components like plain text, single pages, page images, metadata (title, author, etc.).

Continue reading “Manipulate and Extract/Burst PDF Files Into Images, Text and Other Components with Docsplit”

Convert (Split) PDF Files into Images with ImageMagick and GhostScript

Split PDF

ImageMagick is an excellent open source set of software tools that helps with converting, editing, displaying and composing image files. Almost all programming languages have extensions or libraries to interact with the ImageMagick API, although you could also use it via command line.

Ghostscript is a set of tools that can interpret PostScript page description language and PDF files too, to render or rasterize them.

Continue reading “Convert (Split) PDF Files into Images with ImageMagick and GhostScript”