Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Code



  How to draw pentagram in HTML5 canvas

I wrote simple function to this magical symbol I like so much: 123456789101112131415161718192021222324252627282930<!doctype html><html><body>    <canvas id="c" width="500" height="500"></canvas>    <script> var ctx = (document.getElementById("c")).getContext("2d"); // draws rotated pentagram with or without cirlefunction pentagram( ctx, x, y, radius, rotate, circle ){    ctx.beginPath();&nbs...

   Html 5,Canvas,pentagram     2012-04-23 12:56:06

  Stop programming

You probably program too much. Just when you've really gotten into your work, when your brain is entirely wrapped around your code, when your hands, eyes, and thoughts are working in harmony, stop. Look up. Think about when you're going to finish for the day. Look forward to shutting off your computer. Get outside a little. ...

   Programming,Tips     2011-06-30 02:50:14

  Execute PHP from a .html File

How can I execute PHP code on my existing myfile.html page?:When a web page is accessed, the server checks the extension to know how to handle the page. Generally speaking if it sees a .htm or .html file, it sends it right to the browser because it doesn't have anything to process on the server. If it sees a .php extension (or .shtml, or .asp, etc), it knows that it needs to execute the appropriate code before passing it along to the browser. Here is the problem: You find the perfect ...

   PHP,HTML,PHP in HTML,AddType     2011-12-26 14:01:20

  Interview Programming Problems Done Right

Introduction Why 37signals Doesn't Hire Programmers Based on Brainteasers and my comment on HN generated a lot of responses, so much so that I'm writing this post to properly explain the essence of a good (IMHO) interview programming problem. Pascal's Triangle Pascal's Triangle is a shortcut for getting coefficients most often used binomial probability. The root element is 1. Every other element is the sum of the one or two above it (diagonally left and diagonally right). There are severa...

   Interview,Programming problem,Pascal,Triangle     2012-01-06 09:46:43

  New HTTP status code: 451 Unavailable for Legal Reasons

On June 11th,2012, Google proposed a new HTTP status code to indicate webpage contents which are not conform to law. The new HTTP status code is 451 Unavailable for Legal Reasons. Google Android Developer Advocate Tim Bray submitted the draft for the new HTTP status code, it will be used on some webpages which can not be served because of legal reasons. Visitors will know that the page cannot be seen because of the government censorship.According to the draft, responses using this status code sh...

   HTTP status,451,Tim Bray     2012-06-12 09:07:44

  All Programmers Are Self-Taught

When I was a teenager I played high caliber baseball. I’m competitive to a fault and when I decide I want to be good at something, results usually follow. Now I’m a third year undergrad studying computer science. There’s something critically different between programming and sports though: A pitching coach teaches you how to pitch, but a CS professor doesn’t teach you how to code. I was surprised that neither my TAs nor professors critiqued my code during my firs...

   Programming,Style,Habit,Self learning     2011-12-21 10:25:50

  Push docker image to remote AWS ECR

With the popularity of distributed and large-scale systems, there are more and more adoptions of cloud services. One of the most popular container in the market is Docker and one of the most popular cloud service provider is AWS. From development perspective, there is frequent need to push local docker image to remote ECR for debugging or testing purpose. Normally when a code change is done and the committed change would go through a series of process like code review, push to remote repo, merge...

   CLOUD,AWS,DOCKER,AWS ECR     2020-12-13 04:12:26

  Understanding an interesting JavaScript map function question

With the evolvement of JavaScript, lots of new features have been added this old but robust language.  Among them are lots of functional programming language related functions like map, filter, each etc. In this post, we will cover one function map and its interesting behavior. Before dive into the details, let first take an example, do you know the output of below function call? ['1', '7', '11'].map(parseInt) You may think that it's easy and the output would be [1, 7, 11] Can you try to ru...

   JAVASCRIPT,MAP,FUNCTIONAL PROGRAMMING     2019-06-14 08:34:46

  Name resolution order in JavaScript

To understand what value a variable has in JavaScript, we need to understand some concepts such as scope and name resolution order. JavaScript has two scopes; one is program level and the other one is function level. Unlike in C,C++ or Java, JavaScript has no block level scope. So a variable defined in a if block will still be available outside. For example, the below example: var foo = 1; function bar() { if (true) { var foo = 10; } alert(foo); } bar(); The alert will display 10 since the ...

   JavaScript,Scope,Name resolution     2013-07-10 01:29:28

  Twitter OAuth the easy way – simple post to twitter script

After Twitter introduced mandatory authentication with OAuth, many of the current scripts for posting content to Twitter don’t work anymore. OAuth can be great for more advanced authentication, but for a simple post to twitter script, it seems like a little overkill. In this post you’ll learn how to create a simple script that uses a quick and dirty version of OAuth for posting new tweets to Twitter. How to create a simple script Simplified, Twitter OAuth involves sending both ap...

   Twitter,OAuth,PHP,Auto tweet     2012-02-25 12:51:07