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

 ALL


  Create temp file in Bash using mktemp and trap

When working on Linux Bash, sometimes there is need to create temporary file. A common way of creating temp file on Linux is creating some file in /tmp directory. However there is security risk when creating temp file in /tmp directory. This post will show how to securely create temp file in Linux Bash.When creating file in /tmp directory, there are some security risks. This directory can be accessed by any user on the system, any user can write data into this directory as well. The files created in this directory can also be read by other users. pike@DESKTOP-G352RBR:/tmp$ touch /tmp/info...

33,616 2       TEMP FILE MKTEMP TRAP LINUX


  A trap in PDOStatement::bindParam

First, let's check out below codes:<?php$dbh = new PDO('mysql:host=localhost;dbname=test', "test"); $query = <<prepare($query); $bind_params = array(':username' => "laruence", ':password' => "weibo");foreach( $bind_params as $key => $value ){ $statement->bindParam($key, $value);}$statement->execute();What is the SQL executed finally? Is there any problem with above codes?Many people may think the query executed is :INSERT INTO `user` (`username`, `password`) VALUES ("laruence", "weibo");But the query actually gets executed is :INSERT INTO `user` (`username`, `passwor...

9,161 1       PHP TRAP BINDPARAM


  A Python assignment trap

Python has no assignment, it only has reference. Assume, we have following code snippet:>>> values = [0, 1, 2]>>> values[1] = values>>> values[0, [...], 2]Why the result is not [0, [0, 1, 2], 2], instead it goes into an infinite loop? To understand this, we need to understand some basics about Python.Python has no variables, it only has labels. When we run:values = [0, 1, 2]Python will first create a list object [0,1,2], then it labels it as values. If we later run:values = [3, 4, 5]Python will then create a new list object [3,4,5] and it will tear off the values lab...

9,403 0       PYTHON TRAP ASSIGNMENT SHALLOW COPY


  The trap of the performance sweet spot

This post is about JavaScript performance but I would like to start it by telling a story that might seem unrelated to JS. Please bear with me if you don’t like C.A story of a C programmer writing JavaScriptMr. C. is a C programmer as you can probably guess from his name. Today he was asked by his boss to write a very simple function: given an array of numbered 2d points calculate vector sum of all even numbered points... He opens his favorite text editor and quickly types something like (I’ll be intentionally skipping some #include boilerplate):typedef s...

2,003 0       JAVASCRIPT MEMORY C LOW LEVEL SWEET SPOT TRAP