StackWorld 2016 Reflection

“Hmm. The email said that I should wear black blazer and black pants when I volunteer. It’s like I am going to an interview anyway.” I joked with my sister – but then, I was going to volunteer at the StackWorld Hiring Mixer, so it is pretty much like going to an interview. In fact, I ended up attending the Mixer as an hiree (is that a word?) myself during my break, totally under-prepared as I had thought I would be volunteering the whole time. There was only 4 companies, so it was easy and quick for me to just stop by during break and get an idea of what each companies are looking for.

That’s another unexpected thing – the size. I had been to DevWeek’s (same organization) Hiring Mixer earlier this year, which was very large yet extremely over-crowded. This time, the event was hosted at a small local pub, Cafe Royale. Four was pretty much the maximum number of booth tables that the place can hold.

Although with a place like this, the attendee have one major benefit – drinks. As the event went on, it morphed more into a networking event. I was assigned upstairs at the overlook, and I got to watched one of my friend attending the event worked his networking magic at the bar, chatting with different people at the table throughout the event. I wonder if that is the expected result – I did wondered with my sister why they pick a pub where hiree runs the risk of getting drunk, but if networking is the goal…

Second day is the fun day for me – talks, talks, talks! During the mixer, someone told me the talks from the first day were more of ops than dev in its contents, which I found to be quit true for second day, too. While I am interested in DevOps, I started as someone who was studying the development side, so that’s where my skill sets and knowledge primarily lies. Some of the talks were difficult for me to catch on as a result. But the talks did give me a good idea of what DevOps are about from the industry’s standpoint and which direction to look for in my studies. Some of the more memorable ones includes keynote from Josh Bernstein of EMC, Open Source Has Changed How You Run Infrastruture. His was quite funny and used some very good diagram and comparisons to talk about DevOps and the importance of Opensource.

Bernstein-Hierarchy of NeedsBernstein-Another DevOps Visualized

Dan Jones from VictorOps did DevOps 101, which also did a good description about what is involved in DevOps. At one point, he put up a quote by Ernest Mueller, author of Agile Admin, which I thought was pretty good:

DevOps is the practice of operations and development engineers participating together in the entire service lifecycle, from design through the development process to production support. DevOps means breaking down the traditional silos that have existed between Ops and Devs.

My favorite is Performant Security from Sabin Thomas of Codiscope . His talk about various tools that they used to develop Jack (cloud-based developer tool that checks github repo for security issues), and the process moving from Alpha stage to Beta stage and finally to Live is very insightful. It gave me a good idea of what to pay attention for when I am studying those tools – some of which includes Mongo and Docker, both of  which I am learning right now. I had to leave a bit early, while he is still talking about Google Cloud Platform, but I still found that I took a good amount of information from the talk.

I also did the booth challenge, where attendee gets a gift if they scan the QR code on 11 exhibition booth and 1 session. I decided to take it up a notch and talk to all 11 booth, asking all of them about what they do, and in some cases, if they are hiring recent grads. It was a very nervous, but also insightful experience. Some fun things I found:

  • Out of the 11 companies I talked to, at least 3 traveled from outside CA State! They are: Raygun from Seattle (crash-reporting software), VictorOps (real-time alert and monitor) from Boulder, and Codiscope (software security services) from Boston. While they have an office in San Carlos, QTS (data center service) is primarily based in Chicago.
  • I went to the Codiscope booth before their open talk, so I didn’t realize that their Jack service is completely Live now instead of Beta – I had talked to them during Devweek back when they are in Beta stage.
  • Citrix (application and data delivery on network and cloud) is very enthusiastic about getting people into their iPad raffle drawing and swags (an iPhone cloud-shaped stand and webcamera cover). In addition, they also set up 3 monitors to display their NetScaler service live. Very neat!

Citrix NetScaler

  • (cloud-based job processing system) printed out newpaper-like case studies of their customers, which includes Bleacher Report, Hotel Tonight, and Untappd. They also did a drawing for a drone. Didn’t win that either, but it looks pretty cool – it has a mount for GoPro!
  • AppDynamics (real-time application performance monitoring) had people there at the hiring mixer, who was also there in the exhibition hall. Someone is busy!
  • (crowd-source security professionals) wasn’t in the exhibition hall or had a QR code to scan, but their card display caught my attention as I walked by, and I ended up listening to the booth people discussing their services to another attendee:


Elm Workshop: Day Two

Day Two!

  • Richard start off with some Q&A, and we got some site recommendation when someone asked about learning tools. Although it was only a day (albeit an 8 hour day…), I got enough info that I can imagine applying it to one of my idea for a side project, but I definitely need some information to actually implement it.  I particularly like the article Building a Live-Validated Signup Form in Elm by noredink. Richard is also in the process of writing a book, Elm in Action, to be publishing by Manning. He also mentioned as a possibility, though he haven’t tried it himself. If I remember correctly, it is a paid subscription service, so I will probably try the noredink articles first.
  • Triple Quotes (“””): multiline string
  • Decoder Integer: Decoder check a JSON string and returns a “Result”, which should hold “Ok” if the decoding process is run smoothly (it can be decoded into a integer), “Err” if not.
  • decodeString is a shorthead for Json.Decode.decodeString after importing with the command import Json.decode exposing (..). Much better when you are doing a bunch of decodeString.
  • Int is a decoder. List is a function that takes in a decoder such as an Int, and returns another decoder.
  • Shelf (at [“name”] string) <— Find value at list key name, which should return a string to function named Shelf. The list key is in square bracket because it can hold nested keys.
  • Decoder
    • decode User
    • |> require “id” int <— Need to be id holding int
    • |> option “name” string “(falllback)” <— optional. If key not there, use the value in fallback.
    • |> hardcoded 1.0
  • Side Effect: unlike JS, Elm don’t have side effects.
    • Instead, it have Manage Effect.
  • GetString: takes in String, returns Task Error String <—The Error holds a Network HTTP error. UnexpectedPayLoad gets return if JSON decode fails. Task is like a to-do list – list by don’t do. Notes that this doesn’t invoke network traffic – GetString is a Task.
  • andThen and sequence: takes a Task and chain to others, building a full Task.
    • Some task cannot be chain together. Ex: random number generator.
  • Command messages (type Cmd) do not have error handling, unlike Tasks (type Task). Tasks is very general.
    • HandleSearchResponse(List SearchResult) and HandleSearchError Http.Error are both functions that returns Cmd.
  • Let … in expression: intermittent value (like variable) are defined with tasks (like value). No outside scoop outside see the value, until the code reach in, where the in scoop can call anything in the let scoop.
  • Maybe: in Elm, there is no undefined or null, it have a Maybe type container, and the type returns a “Nothing | Just a”. (Indecisive little guy, isn’t it?)
    • Attendee asked “Why Maybe exist?”. Answer was that it was to prevent error.
    • Just precedes a value to apply a wrapper.
  • Access JavaScript by sending to its port
  • Subscription is synchronize.
  • Elm packages
    • dependencies: used github repo.
    • elm is very strict on having the latest version. Reject if its old
    • testing project: project-fuzzball ????
  • Expect.equal compares 2 values for equals.
  • Left pipe ( <| ): calls a function. Eliminates parentheses. foo (bar baz) in JS is foo <| boo baz in Elm.
  • Unit ( () ): seriously is just a parentheses. Indicates that there is nothing happening. Tells function that it pass to that nothing is being done. Delays evaluations of test.
  • Fuzz Testing: do a test multiple times with randomly generated input.
  • Shrinking: when encounter error, the program tries to find something small and minimal to present to coder for debugger. Thank you Elm!
  • Set: a set of unique values. Get rids of duplicates.
    • Set.member will find out if the arg exist in the list
    • Set.insert – obviously, insert value.
  • Dict: dictionary of keys and values (Richard jokes “Careful how you pronunciation that.” Indeed, indeed…)
    • Key type and value type must be consistent throughout the dict.
    • .get returns Maybe types, meaning a Nothing or Just.
    • Maybe.withDefault { —Fallback Json } (Dict.get “key” DictName) <—This give a fallback value when the key is not found in the Dict list named DictName.
  • result -> can be shortened to {id} ->
  • { model | results = resultsById } ! [] is equal to { model | results = resultsById } ! command.none
  • Compose ( >> ): sibling to pipe (|>). Do one action to another item. The arrow can go either way.
  • React all about component. Elm uses component only when needed because it keeps simplicity, but takes more effort when encapsulation is needed.
  • Further Studies: Look up tail-recursion for fast performance optimization. Html.Lazy is another one good for performance optimization.

Elm Workshop: Day One

Braving the Pride Weekend commuter traffic, I just attended day one of Elm Workshop, presented by Richard Feldman from NoRedInk, hosted by Women Who Code, and located at Pivotal Lab (yep, a lot of people went into this). Learning a functional programming language for the first time is a truly fascinating experience, especially if one does in 8 hours straight! Most of what I learned are from the in-workshop exercise, but here are some notes for day one. Note that this is from a very compacted 8 hours course, so I can only hope I didn’t misunderstand something:

  • Compared Babel to Elm: both translates languages
  • if-else is a statement in JavaScript, but expression in Elm. The last line in a function is a return value.
  • Uses then instead of {}.
  • Arguments are separated by space.
  • Only have double equal (==). No triple equal (===). Slash equal (/=) instead of bang equal (!=).
  • When calling functions, space are used instead of parentheses. Parentheses are used for grouping, not indicating function call.
    • instead of text( pluralize (“self”, “shelves”, 5)), do text (pluralize “self” “shelves” 5)
    • in the above sample, parentheses are used to ensure the result of function pluralize is passed as argument for function text, not all 4 item (function pluralize, string “self” and “shelves”, and integer 5).
  • Elm is not good with tab – change to space.
  • String are always double quotes.
  • Pro: good in debugging. When compile, error message occurs and points developer to where the problem is.
  • Single plus (+) in Elm is resolve for arithmetic. For concatenation, double plus (++) is used.
  • For HTML output, square brackets are used for each tag, in general. Text are precedent by text. Comma help separates. For HTML output, the functions – named as HTML tags such as div – takes 2 argument: list of attributes and list of children.
    • Comma is placed at the beginning of a statement instead of end. That’s a convention in Elm to make sure commas are not forgotten.
  • List: all elements in list for Elm must be the same type of value, unlike JS.
  • Type Indication: To declare the value of a variable, add : Type Type-of-type, such as apple: List String or shelves: Html a
    • Empty list type is undefined. Calling it in various name will work. If the first type is undefined, a can be places.
    • Type indication can also indicate the return type with an arrow, such as pluralHtml : number -> Html a (Format: function: type-it-takes -> type it returns).
  • Partial Application: When a function only give partial information regarding the argument for another function.
  • grabs the list, runs though the list and apply something.
  • Anonymous function are defined by slash ():
    • { return viewShelf(shelf); })
    • ( (shelf -> viewShelf shelf) shelves)
    • Ext-function(anoy-function-arg -> return-function/value), Ext-function-arg2
    • But we can also pass the function directly in cases where it is just a function being passed to another function.
    • viewShelf shelves
  • Interactive:
    • onClick{} instead of Eventhandler
    • Msg instead of Callback
  • True/False is capitalized in Elm because it is a uni-type in Elm, unlike JavaScript which is all lowercase.
  • Record and UniType
    • Records data are called use using dot (.):
    • UniType are called using case:
      • case arg of
        • uni-type-class1 uni-typevalue1-> { function or changes }
        • un-itype-class1 uni-typevalue1 -> { function or changes }
  • Debug.log: wrap it around what you want to log. Acts like console.log.
  • For imports, exposing(..) means bring everything in.
  • Pipeline Encoding: [ “list”, “items ] |> variableType.function1 /> variableType.function2  <= runs multiple function with a set of argument. ( Example: [“apple”, “orange”] /> List.reverse /> String.toUpper means String.toUpper(List.reverse [“apple”, “orange”]). )
  • Type Alias can take in arguments and return a record if the type alias has the variable defined by type only (the variable is not assigned values or expression)

Errata for Getting MEAN with Mongo, Express, Angular, and Node

Now that I have completed my CCSF courses, I have decided to learn the MEAN stack between my job hunts. I have found Getting MEAN with Mongo, Express, Angular, and Node by Simon Holmes to be quite excellent so far. However, it is from 2014, and it is not unusual for tech books to have errors.

This is my page for keeping track of errors in the book. Currently, I am in Chapter 4, so this post will be continually updated until I finish the book.

Note that sometimes I would remove existing code and retype the codes from the book, even if the code was build-in during the npm install. I do it because it makes it easier for me to learn how all the code work. That also mean I would spot mistake from the book that people who just use the default code from npm install may not come across, either because it was corrected in later npm versions or a mistype on the author’s part. I found mistake-discovery entertaining, but it may confused readers, so… ya, just a heads up on corrections that may not need corrected.

So, here goes the errata:

  • Listing 3.5: the line p Welcome to #{title.} will create an error due to the period behind title. Move it to outside the curly braces instead ( p Welcome to #{title}. )
  • Listing 4.5: doctype html was changed to doctype 5. Don’t copy that. It’s still doctype html.
  • Listing 4.8: The paragraph above the listing stated that reader should create a file name named location-review-form.jade. The listing title stated “View for the Add Review page, app_server/views/location-review.form.js” The later is a type. It should still be location-review-form.jade and not js.
  • Listing 4.5.1: Sometimes, the term list.jade is used. It’s actually locations-list.jade.

Reflection of DeveloperWeek Hackathon 2016

I haven’t took the Muni for a while. I totally underestimated the time, missed a bus, and ended up way too late.

Not a good start.

By the time I was there, there is only about 10 minute before the main stage kickoff starts – wait, I mean I was late for breakfast.

What? Breakfast is a very important part of hackathon. Especially if you are a coffeeholic. Oh, coffee, my precious coffee.


The point is that everyone is there, chatting among themselves or the booth host, and I am still didn’t had my morning joe… wait, the booth is already set up this year!?

Well, at least I didn’t missed the food.

The main stage kickoff was late this year, and there were some momentary confusion about when and where it was to happen. It didn’t help that the attendees are split into 3 stories, with the lower story being the actual place for the main stage. I stalked checked up frequently on DeveloperWeek’s Facebook and Twitter account. Finally, someone came in to inform us that the kickoff is about to start. It was pretty much just each company introducing themselves and their Challenges, which was posted at, DeveloperWeek’s website for the hackathon event.

The companies involved this year that caught my attention because they were either on Opening stage or holds one of the booth includes Galvanize, Codeanywhere, Concierge, Flowroute, HP, CapitalOne,, IBM, Intuit, Magnet, NetApp, RedisLabs, SparkPost, CloudBees, Weebly, and Shippo.

It would be way too long to go over each company. I may go over them in a later post?

The decision to come to the Hackathon was last minute, so I didn’t really know what Challenges there were or had a team. I met up with a friend, but she was in a team that uses Ruby, which I know nothing about other than the fact my favorite and very awesome food subscription box uses it for their website (Yep, I checked their job page. What? An internship with a food company would be awesome! Except they use Ruby on Rails. And they don’t need interns. *Sighs* By the way, the company is Love With Food. Great snacks, fun preview video, and they donate a meal for each box purchased. Did I mentioned that they are awesome?).

So, first task. Read Challenges and existing Projects. The Challenge from Shippo caught my attention quickly. I thought of the multiple subscriptions of magazines and boxes I have, and how nice it would be to view them on one site. But then, no one seemed to have similar Challenge, so I decided to wonder around the booth, attend the workshops, and learned more about the available tools. After all, learning was my objective this time. While several were interesting, none of them materialized into a web app idea in my mind like Shippo did. In the end, I posted my own Project online onto However, I think I might had been too late, and no one is looking to team up anymore.

Lesson of the day, start and decide quick in a Hackathon.

One of the workshop, IBM’s Bluemix, did caught my interest. It seemed like I could use it to build web app, where I could input my code for Shippo. However, in the end, it was in vain. There were several errors that I came across, and it wasn’t friendly enough for me to create a login system in 24 hours. In the end, I became too obsessed with it and wasted time.

Another lesson learned. In hackathon, do not obsess over non-essential problem.

I did created a PHP class to extract the information given by Shippo’s API. I used WordPress and its numerous plugin for user registration. But by then, I realized I wouldn’t finish on time. I took too much time with IBM’s Bluemix, and there were also some issues with the WordPress plugins. I could do an all-nighter to make up for the time – except I had a volunteer project due and a dinner party for my dad the day when the Hackathon ends. I did not want to fall asleep for either of them for a project that I will either not finish or finished very roughly. Promised responsibilities comes first.

In the end, I turn of my laptop and went to bed. The idea is there now. Even if the hackathon had passed, I still got a project started that I plan to finished after my current EduGarden app, so not all is lost. Plus, this way, I get to make a much more complete project, which is much more satisfying for my perfectionist side. My current EduGarden app is being done with a focus on secure programming practices and an aim of learning PHP MVC. While EduGarden is made to work fine in both mobile screen and even without Javascript, my second app – now title SubscribeTrack – will probably focus completely on mobile usability with an aim to learn css3 media queries.

The current project of SubscribeTrack is now on Github without the WordPress codes, temporary placed on hiatus until EduGarden is done.

Course Progress for C++ & WP

So far for C++, I have successfully churn through 1/3 of C++ Primer by Stanley B. Lippman in a month (It’s a really, really thick book. If it wasn’t softcover, you can probably knock someone out with it.). It is quite the intense reading – very detail but clear in its explanation. I can see why several Amazon reviews raved about it being an excellent book but emphasizes that it is not a beginner book (Seriously, do not read this if you have never touched OOP). Despite having skipped Intro to C++, I am doing fine in class as a result. I am so glad I am such a fast reading bookworm!

WordPress/Drupal have so much more assigned reading than any of my other programming classes! I literally read through 4 chapters of the textbook (Professional WordPress: Design and Development by Brad Williams, David Damstra, Hal Stern) in a week, plus 2 web pages in WordPress documentation about Core and Loop. I thought my brain was going to fried – who knows there is so much about WordPress? Core, content, admin, include, etc, etc.

Doing some extra self-challenge added some… challenge, to the class as well. I decided to run the whole LAMP stack natively when I got my new Macbook last year. I did had MAMP in my old Macbook, which was indeed a convenient program, but I was taking Linux when I got my new Mac and I was getting more and more interested in OS. Running my own LAMP, with all the troubleshooting and exploring sounded fun.

As a result, several error message came up with my second class assignment, and here is the notes about the problems I got to solved!

1) WordPress was asking for connection information when I try to update and upload the class’s assigned Underscore theme. At first, I just manually updated WP and upload the theme. Then I got asked again after trying to install plugin too, so I decided to look up for some better solution. After some research, I learned that I need to change WordPress’s filesystem method so it stops using FTP, so I added this in the wp-config.php:

/** Change filesystem method when localhost */
if ($_SERVER[‘REMOTE_ADDR’] == ‘’||’::1′) {
define(‘FS_METHOD’, ‘direct’);

Just define(‘FS_METHOD’, ‘direct’) also works, but I thought I would add an if statement to check if the file is in localhost, I don’t have to worry about removing the line if I need to move the page from development to production mode.

Note that ‘’ is the localhost ip for IPv4 system, while ‘::1’ is for IPv6. Including both allow the code to go into both system. For my Macbook, the code do not work if ‘::1’ is not included.

2) I got permission error, which was not fix by chmod 775 or 777. In that case, I thought it may be an chown issue instead of chmod. I looked up which user is localhost apache running as for in Mac OS, and the user turned out to be _www (MAMP users may have a different user). So I did chown -R _www wordpress. Now everything works.


Winter Break Activities, 2015-16

So far, during this break I have:

  • Went to Japan with my family (Hooray!)
  • Started to volunteer for a non-profit that help local youth by teaching tech named Bayview Boom. Currently I am just discussing how to organize the page with the director, who is also a developer. Should be a good experience that we will let me both learn from a working developer and use my skills in front-end (the webpage is switching from Yola to for a good, local cause.
  • Reading through the HTML & CSS3 For The Real World by Alexis Goldstein, Louis Lazaris, Estelle Weyl.
  • Reading through the C++ Primer by by Stanley B. Lippman, Josee Lajoie, Barbara E. Moo. I am taking CCSF’s C++ Fundamentals coming semester, even though I have never taken the C++  intro class! I had, however, taken the Java intro class, whose professor emphasized that if we took the Java intro, we should take the C++ intro. I hope he is right, but I am going to make sure that I am well-prepare.
  • Reading articles and books on mobile responsive design.
  • Random reading about random programming subject.
  • Tried Eclipse to do C++. Can’t do Ctrl C and Ctrl D, which is part of the book exercises. Prefers and went back to command line.
  • Added to my PHP class project from last semester. During last semester, I already finish the basic functions for the login, inventory, and cart page. I want to finish the shop and about page during break.

Coming semester:

  • I am taking 3 classes: Programming Fundamentals: C++, WordPress & Drupal CMS Development, Linux Administration Projects.
  • Be more active with Meetup.
  • Continue volunteering at Rebuilding Together in data entry, phone screening, Cantonese interpretation, and Traditional Chinese translation.
  • Start volunteering at Bayview Boom with their website. Seems like it will focus on WordPress plugin and related codes. My WordPress class in CCSF starts just at the right semester!
  • In progress of inquiring about a possible web/media internship with a non-profit. No email reply yet.
  • For the PHP class project, finished the home and product page. If possible, include an event page.
  • Add my current work to my portfolio page. Everything is just on Github now, which only have the code, not the images.
  • Really want to learn C so I can program my Pebble Watch, but that may be too heavy of a work load this semester with the C++ class.
  • I would complete all the Linux courses in CCSF. Should I take the Redhat exam even though my aim is front-end? I have enjoyed the classes very much. I should look more into that…
  • Speaking of which, I should work on changing my Nexus tablet’s OS to Linux. Totally forgot about that!
  • And last but not least, look for a job or internship.

Building my PHP Session Handler

My homework recently consisted of building my session handler, which confused me greatly – what on earth is session handler? At first glance, I wondered why would one use session handler? How is different from, say, calling the method by $session->getData()? Took me a while, but I finally got a working code that I have now recorded on Github, and I got some basic idea on What, How, and Why.

Note that this is really a blog where I store my notes for future references and to type out information so my mind can wrap around things. There is a lot of “typing whatever comes to mind” and cherry-picking only things that interest me. If you somehow wandered here looking for organized info on Session Handler, I suggest the tutorial on Sitepoint, which is way more organized and correct.

What is Session Handler: Like its name, it handles session. When a session starts, such as via session_start(), data are stored in $_SESSION with a configuration file php.ini, or at least that is my impression of how it works. Using those information and configuration settings, the handler manages database storage. Its basic, possible use includes opening database, reading the database and outputting the data, writing to the database with the values gain from $_SESSION, destroying selected data from database, performing garbage collect in the database, and closing the database.

How to do a Session Handler:

Class Session {   // Or whatever you name it as.

// I am using the constructor in PHP 5 style. Do not misspell it as constructor. Certain someone spent a whole night wonder what is wrong with her constrictor because of it…

function __construct() {

// The build-in function below “sets the user-level session storage functions” (via, which pretty much means that it designates when the methods in this Class is invoked. Yes, the methods are invoked automatically basing on the condition! Most of the time anyway. Do not misplace the order of the arrays, or your function will be invoke in the wrong condition.

// Placing it inside the session class constructor is optional. However, placing it outside the class would mean you would type it out each time the class is invoked, plus “$this” will be change to the name of the object created by the Class, which is just annoyingly repetitive.


array($this, ‘open’),    // 2nd parameter’s name is personal preference, but pick something easy to understand. ‘Open’ is pretty standard.

array($this, ‘close’),

array($this, ‘read’),

array($this, ‘write’),

array($this, ‘destroy’),

array($this, ‘gc’)


session_start();   // though not required, it’s good idea to place session_start() her so you don’t to invoke every time you create an Object with this class.


function open() {

// Invoke condition: whenever session is starting, such as when session_start() is used.

// Typical content: call to database.


function close() {

// Invoke condition: after write() was called or when session_write_close() is called.

// Typical content: close database.


function read($sessionId) {   // all method’s parameter seems to be optional. Each method’s first parameter calls the value from $session_id(). You as the coder don’t have to do anything other than call the Class (or session_start() if it is not in the Class’s constructor. See, this is why its good to put session_start in the constructor) unless you want to change the default session id. You should not have to type read(1234) or something like that.

// Invoke condition: whenever session starts or when session_start is called() – but after open().

// Typical content: what you want to display from the database.


function write($sessionId, $data) {   // like read(), $sessionId will call the value from $session_start(), while $data will call the value from $_SESSION[‘data’]. Again, you don’t have to do anything other than calling the class unless you want to change the default value. I change the $data in my handler to take in the input value, but I did it by reassigning the value in $_SESSION[data] outside of the class ($_SESSION[‘data’] = $_POST[‘something’]) and not by $data = something.

// Invoke condition: whenever the PHP shuts down or when session_write_close() is called, but after the output stream is closed. close() is executed after this.

// Typical content: writing to database. Note that $_SESSION[‘data’] is automatically serialized. This means you have do some unserializing and serializing, plus you have to make sure to prevent SQL injection. In my own code, I:
(1) Copy the serialized session $_SESSION in a different variable, $original.
(2) Unserialized $_SESSION. Note that after PHP 5.3, using unserialize() on a SimpleXML_Load_String() will result in an error message, which is what will happen with $_SESSION. Use session_decode() instead.
(3) Store the unserialized content in a variable $output, then real_escape_string() it to prevent SQL injection.
(4) Restore $_SESSION with the variable containing the serialized session ($_SESSION = $original).
There are other methods, but this is the quickest one I can understand – I am working on a deadline after all.


function destroy($sessionId) {

// Invoke condition: whenever the session is destroy, either via session_destroy() or with session_regenerate_id() set to parameter TRUE.

// Typical content: what happens if a session is destroy. In my case, I set my codes to do a session_destroy if a submit button “Logout” is press (AKA, check if a $_POST[‘logout’] exist, if so, call session_destroy() ). When the destroy() is invoked as a result of that, it remove the entry in my database associated with the current session id.


function gc($lifetime) {   // $lifetime calls the value store in session.gc_maxlifetime.

// Invoke condition: called periodically by PHP, with the frequency based by session.gc_probability and session.gc_divisor.

// Typical content: what happens if a session is garbage collected. In my case, in my construct(), I set the session.gc_maxlifetime to 15 minutes. My database contains a column, ‘time’, that stores the time the entry was first written. When gc() is invoked, if any rows have a ‘time’ cell older than 15 minutes ago, the row is removed from the database. In another word, a user is automatically logged out after 15 minutes with its session id and data removed.


Why use Session Handler: It is probably because it (1) reduces the amount of coding when you store session repetitively and (2) sets a lot of automation.

When I first started building the code and my constructor wasn’t working, I placed session_start() outside of the class. I also attempted to invoke the methods manually:

$session = class Session();


$session ->open();

$session -> read();

$session -> close();

That is a lot of code to be typed each time you invoke a session class. With the session handler, all the methods are invoked automatically when conditions are met. Even the parameters, like $sessionId, $data, and $lifetime that I mentioned earlier, are automatically set. Coder can change them by change the values in $_SESSION[] or session.gc_maxlifetime, but it’s pretty automatic.

Summer 2015 So F ar

One of my goal this summer is work on my project, which ended up with me taking a long detour in both brushing up and learning new skills in JavaScript, JQuery, Ajax, PHP, MVC, and OOP. There was a lot of reading, online video/school, and coding. I have sadly ddiscovered that I have learned more about Ajax in a 2-days self-study using Treehouse video and books than I did a semester of class, but hey, some classes are better than other. It’s been good, although I ended up pushing back my C and Anduino learning.

IT network self-study has been going well. Since I am taking the same professor as I had in my Introduction to Networking for the next semester course in Network Security, I feel that I should brush up on my network knowledge. When I took my first network class over half year ago, I was new to CS and have no idea what is going on. I am half-way through re-reading my books and notes. Now that I have a lot more experience, it makes much more sense, and I feel more comfortable about jumping back to a networking class this Fall.

In term of Fedora, because of that fact that half of my self-study files are local, I lacked a reason to even turn on Virtualbox. But no more. Most of my learning files and even a good portion of my project files are now on Dropbox. I installed both Dropbox and Sublime Text on Fedora, so I can now do most of my coding and studies in Fedora!

Although, Fedora have problem waking up from its sleep in Virtualbox. It would either remain the black screen of death or refuse to let me type anything. In addition, I am consistently clicking on command-C instead of control-C. In Virtualbox, control-C actually exits the Virtualbox out of its full-screen mode instead of copying text. As someone who loves shortcut key and types pretty quick, it’s driving me a bit crazy. I pretty much do a command-key shortcut every 10 minutes when I started using Virtualbox, then when I do return to my Mac OS, I would do the opposite! (As in using control-key for shortcut every 10 minutes). For the first time in my life, I curse my ability to type so quickly…

Website planning 06/01/2015

Notes for website:

Need to create a portfolio image tile generator.

  1. Create a directory: largeTile
  2. Create a function that generate table with cell number based on number of image in largeTile.
  3. Generate the image with link. Variable $imgName.
  4. When hover in desktop/laptop, image becomes translucent with title stated.
  5. When tap in mobile, insert title above image within the table.

How to catalog?

  • Bookmarks image on top. Acts a navigator.
  • Clicked/Tap: Remove all cell holding images in according to bookmark selected.
    • Each cell has its own name.
    • Clicking the table means the whole page reloads.
  • Or, I can pre-catalog by directories beforehand. In normal view, the generator crawls through all sub-directories. In selected view, it crawls through only the sub-directories with name of bookmark.
  • Would need a flag. $bookmarked.