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

SEARCH KEYWORD -- Array



  Handling Plugins In PHP

A common problem that developers face when building applications is how to allow the application to be "plug-able" at runtime.  Meaning, to allow non-core code to modify the way an application is processed at runtime.  There are a lot of different ways that this can be done, and lots of examples of it in real life.  Over a year ago, I wrote a StackOverflow Answer on this topic.  However, I think it deserves another look.  So let's look at some patterns and common im...

   PHP,Plugin,Handling     2012-03-11 13:18:39

  The tic-tac-toe game with Python

In this tutorial, we will show how to build a tic-tac-toe game with Python. We will use functions,arrays,if statements,while statements, for loops and error handling etc. First, we need to create two functions, the first function will display the borad of the game: def print_board(): for i in range(0,3): for j in range(0,3): print map[2-i][j], if j != 2: print "|", print "" Here we used two for loops to loop through the map, this map is...

   Python,Tic-Tac-Toe     2013-07-30 02:49:09

  Memory related exception analysis in Java

Java Virtual Machine Specification divides the memory of JVM into several areas : Heap, Stack, The Program Counter register and Method area etc. In HotSpot JVM, heap is composed of Young, Tenured and Perm. There are different OutOfMemory error can happen in different memory area. Next is an overview of some of these OOM errors. StackOverflowError The JVM will allow only a specified number of stacks created nested. An JVM option -Xss can be set to determine the maximum stack size. If the num...

   Java, Memory model, Memory exception, OOM     2015-01-19 06:54:27

  MaxHeapSize in JVM

MaxHeapSize is an option which is to set the JVM maximum heap size can be allocated. We can specify the MaxHeapSize as VM argument when we run the program by setting -XX:MaxHeapSize=, here can be 2M, 20M, 200M etc. We can also view the current MaxHeapSize set by setting different JVM options. To view the MaxHeapSize, we can use two JVM options : -XX:+PrintFlagsFinal and -XX:+PrintCommandLineFlags. Below is one example when running -XX:+PrintFlagsFinal: bool MaxFDLimit ...

   JVM,MaxHeapSize,Alignment     2014-06-17 07:01:50

  The internals of slice in GoLang

There are 3 components of slice:a) Pointer: Points to the start position of slice in the underlying array;b) length (type is int): the number of the valid elements of the slice;b) capacity (type is int): the total number of slots of the slice. Check the following code: package main import ( "fmt" "unsafe" ) func main() { var s1 []int fmt.Println(unsafe.Sizeof(s1)) } The result is 24 on my 64-bit system (The pointer and int both occupy 8 bytes). In the next example, I will use gdb to poke t...

   GOLANG,SLICE     2019-06-30 02:55:22

  First steps with Scala, say goodbye to bash scripts…

Those who know me are aware that I’ve been following play framework, and actively taking part of it’s community, for a couple of years. Playframework 2.0 is right around the corner, and it’s core is programmed in Scala, so it’s a wonderful opportunity to give this object-oriented / functional hybrid beast a try… Like many others, I will pick a very simple script to give my first steps… Finding an excuse to give Scala a try With a couple of friends we are ...

   Scala,Functional programming,Bash script,Replacement     2012-01-12 06:45:16

  Why Dynamic Programming Languages Are Slow

In a statically typed language, the compiler knows the data-type of a variable and how to represent that. In a dynamically-typed language, it has to keep flag describing the actual type of the value of the variable, and the program has to perform a data-dependent branch on that value each time it manipulates a variable.  It also has to look up all methods and operators on it. The knock-on effect of this on branching and data locality is lethal to general purpose runtime performance. T...

   Dynamic language,Slow,Analysis     2012-03-26 15:33:11

  Advice on improving your programming skills

Programming is cool. But behind the scenes it's also difficult for many people. Many people are defeated at the early stage of learning programming. When you are not so familiar with programming, you may find you don't know where to start and what to start with first and where to apply the knowledge. Once you go though the tough period of the learning phase, you will find a whole new world. Below are some advice which can help you improve your programming skills quickly. Write more code.  T...

   Programming,Advice     2014-02-21 08:59:04

  Simple PHP paging class

Frequently in our web applications, we may have many records in the database to display. In order to imrpove loading speed and efficiency, we may need to display some records at a time, so we need to paginate the records. For example, if we have 1 million book records and when users want to view the book list, it's inefficient to display all the records on the same page, we may need to have some pagination to allow displaying a portion of the records such as 20 records per page. This is a simple...

   PHP,Paging,Class     2012-09-10 20:23:33

  How key-based cache expiration works

There are only two hard things in Computer Science: cache invalidation and naming things — Phil Karlton Doing cache invalidation by hand is an incredibly frustrating and error-prone process. You’re very likely to forget a spot and let stale data get served. That’s enough to turn most people off russian-doll caching structures, like the one we’re using for Basecamp Next. Thankfully there’s a better way. A much better way. It’s called key-based cac...

   Cache,Expiration,Key-base cache,Work     2012-02-20 05:32:40