| Apache Struts 2 Documentation > Home > FAQs > What is the ActionContext? |
A striking attribute of the framework is the brevity of its signatures. For example:
| S1 Action | ActionForward execute(ActionMapping, ActionForm, ServletRequest, ServletResponse) |
|---|---|
| S2 Action | String execute()
|
How can this be? How can a key method take no arguments and yet perform useful work within an application?
To keep signatures brief, and methods useful, the framework uses two techniques: Dependency Injection and Thread Local, both of which, in turn, rely on the ActionContext.
Many Interceptors are used to populate propertes on an Action. For example, the Servlet Config Interceptor can set Map properties representing the HTTP Request, Session, and Appplication objects.
Though, the signature for an Interceptor is nearly as brief as Action:
String intercept(ActionInvocation invocation)
Looking through [ActionInvocation], there are several interesting properties, but nothing that reveals the HTTP contexts. (Good thing! since it is a web-independant XWork class.)
So how does an Interceptor obtain the HTTP contexts to inject?
The [ThreadLocal] class is not a new kid on the block. It's been available to developers since Java 1.2. In effect, each thread has its own copy of the variables on a ThreadLocal class.
The framework uses ThreadLocal in connection with the ActionContext class to make servlet configuration and other runtime details available.
From anywhere within an Struts 2 application, you can obtain a reference to the [ActionContext] by calling
ActionContext context = ActionContext.getContext();
For example, if a helper class is called from an Action, and if it happens to need access to ServletContext (maybe it is writing a file and needs ServletContext to get a path to it), the helper can obtain the ActionContext directly. Nothing needs to be passed from the Action.
In frameworks like Struts 1, details like the runtime request and response are passed around like hot potatoes. In Struts 2, such details are bundled together in the ActionContext. In S1, Actions are bound to HTTP through the execute signature. In S2, Actions can be a plain old Java object, and each bound to HTTP only to the extent required.
Of course, the dark side of ThreadLocal is that it is easy to bind business logic classes to XWork. An otherwise pristine business class could grab request parameters directly from the ActionContext. The request parameters are exposed as a plain Map, so binding to HTTP is avoided, but the class still becomes bound to XWork. Of course, if you've decided to use XWork as your business logic framework, then binding to ActionContext might not be a problem.
The darker side is that classes that depend heavily on ThreadLocal can be diffcult to unit test. A cleaner design centralizes access to ThreadLocal variables, so that other classes are easier to test.
This material originally adopted from http://wiki.apache.org/struts/ActionContext?action=edit.


First name
Last name
Position
Office
Start date
Salary
First name
Last name
Position
Office
Start date
Salary


{% extends "base.html" %}
{% load staticfiles i18n crispy_forms_tags %}
{% block footer %}
{% endblock footer %}
{% block bodyclass %}default{% endblock bodyclass %}
{% block content %}
{% block nav %}
We are in the process of rebuilding the Decide to Fly community with a fresh new look and a ton of awesome features. Check back in a couple weeks or contact us below for more information. Thanks!


A keen and enthusiastic software engineer specialising in both front and back end development with strong experience of the full software lifecycle.
I am most proficient in the .NET Framework however I enjoy learning and experimenting in languages old and new.


| Users Online | 3 |
|---|---|
| Registed Users | 14 |
| Name | Description | |
|---|---|---|
| seconds ago | User Register | A new user has registered by the name of "Pim" |
| 1 hour ago | New Project | A new project by the name "Cgra-1" has been created |
| 3 days ago | Project Deleted | The project "LBAW-22" has just been deleted |


{% extends 'base.html' %} {% block content %}
Your next session is {{ request.user.next_session }}
You only have {{ request.user.get_remaining_weight }}kg to gain in order to meet your current goal!


Texture:
Standard Format
Regular Pattern
Rotation 'x':
Rotation 'y':
Rotation 'z':
Scale:
Position 'x':
Position 'y':
Position 'z':
Add Shape
Oops ... your browser doesn't support the HTML5 canvas element
Author: Andrii Bugaiov


Click on a category to rotate the chart. Hover on the circles to display department name.
D3.js code adapted from Chris Given's Triangular Scatterplot example.
Data sources from Insee.
Github


call psb_get_rank(rank, icontxt, id)
This subroutine returns the MPI rank of the PSBLAS process
- Type:
- Asynchronous.
- On Entry
-
- icontxt
- the communication context identifying the virtual
parallel machine.
Scope: global.
Type: required.
Intent: in.
Specified as: an integer variable.
- id
- Identifier of a process in the PSBLAS virtual parallel machine.
Scope: local.
Type: required.
Intent: in.
Specified as: an integer value.
- On Return
-
- rank
- The MPI rank associated with the PSBLAS process .
Scope: local.
Type: required.
Intent: out.


Preparation time
less than 30 mins
Cooking time
10 to 30 mins
Serves
Serves 2
Preheat the oven to 180C/350F/Gas 4.
For the burgers, place the turkey, Brussels sprouts and egg into the bowl of a food processor and blend to combine.
Season well with salt and freshly ground black pepper.
Dust a little flour onto your hands and shape the mixture into four patties. Add more flour to your hands if necessary.
Heat the butter and oil in a frying pan over a medium heat.
Add the burgers to the pan and fry for one minute on each side.
Place the burgers onto a baking sheet, transfer to the oven and bake for about five minutes, or until cooked through.
For the relish, place all the relish ingredients into a small frying pan and cook gently for about eight minutes, until the cranberries have softened.
For the poached eggs, add the vinegar to a small frying pan filled with simmering salted water.
Crack the eggs, one at time, carefully into the pan - take care not to break the yolk.
Place a lid on the pan and cook for two minutes, or until cooked to your liking.
Remove the eggs with a slotted spoon and drain on kitchen paper.
Serve two burgers on each plate with a poached egg and a drizzle of the relish around each serving.


--- layout: default ---
Seaview is a luxury 38ft x 12ft, fully serviced, with three separate bedrooms. There is one double room with en suite toilet and two twin rooms with single beds. There is a family shower room and the option of a pull out double sofa bed in the lounge.
The modern kitchen has a fridge freezer, cooker and cupboards with convenient work tops. The lounge and dining areas have modern furniture and there is also a small flat screen TV.
Double glazing and Calor Gas central heating make this new mobile home a cosy option for cooler days. Cooker and hot water are run on Calor Gas and there is an electric heater in the lounge.
The caravan will have duvets as well as pillows and blankets; but as is customary with caravans, in the interest of hygiene, our customers are asked to bring their own linen and duvet covers.
| Date | Weekly price from | Date | Weekly price from |
|---|---|---|---|
| 8th April - 15th April | £305 | 29th July - 5th August | £568 |
| 15th April - 22rd April | £305 | 5th August - 12th August | £568 |
| 22nd April - 29th April | £305 | 12th August - 19th August | £568 |
| 29th April - 6th May | £315 | 19th August - 26th August | £568 |
| 6th May - 13rd May | £315 | 26th August - 2nd September | £550 |
| 13rd May - 20th May | £395 | 2nd September - 9th September | £335 |
| 20th May - 27th May | £395 | 9th September - 16th September | £335 |
| 27th May - 3rd June | £420 | 16th September - 23rd September | £335 |
| 3rd June - 10th June | £420 | 23rd September - 30th September | £335 |
| 10th June - 17st June | £410 | 30th September - 7th October | £335 |
| 17th June - 24th June | £430 | 7th October - 14th October | £335 |
| 24th June - 1st July | £430 | 14th October - 21st October | £335 |
| 1st July - 8th July | £449 | 21st October - 28th October | £355 |
| 8th July - 15th July | £495 | 28th October - 4th November | £355 |
| 15th July - 22nd July | £505 | 4th November - 11th November | £310 |
| 22nd July - 29th July | £568 | 11th November - Spring 2018 | £310 |


Expanded Project Event Information ..
The remote system (Basecamp) requires you to grant access before proceeding
Grant Access
Exit
Expanded Project Event Information ..
Project
Visit this project at Basecamp
Project Description
Placeholder for Project Description
Event Information
Title:
Placeholder for Event Title
Description:
Placeholder for Event Description
Date/Time:
Placeholder for Event Date/Time
Document to Upload:
Title:
Content:
Post Document to Basecamp
Close Window


VAEriants
A guide to Deep Graphical Models
More familiar with probabilistic models?
More familiar with deep learning?


Operating Systems H
Introduction
OS:
- manages computer’s hardware
- provides basis for application programs
- intermediary between user and hardware
- an environment within which other programs can do useful work
Hardware:
- CPU
- memory
- IO devices
Application programs:
- define ways in which the above resources are used to solve users’ computing problems
User view:
- PC - maximise ease of use for a single user to monopolise resources
- mainframe - maximise resource utilisation for lots of users accessing through terminals
- workstations - share resources, but also have dedicated resources, connected through networks of workstations and servers
- mobile devices - similar to PC, with touch screen
System view:
- OS is resource allocator
- OS controls IO devices and user programs - control program
Moore’s Law - predicts that the number of transistors on an integrated circuit would double every 18 months
Common definition of an OS:
- the one program running at all times on the computer
- kernel
- there are also
- system programs - associated with OS but not necessarily part of kernel
- application programs - not associated with operation of the system
Today, mobile OS include middleware as well as the kernel:
- set of software frameworks that provide additional services to app devs
- can support databases, multimedia and graphics
Computer-System Operation
Modern general-purpose computer system:
- 1+ CPUs
- device controllers connected through common bus that provides access to shared memory
- in charge of a specific type of device
- execute in parallel, competing for memory cycles
- memory controller synchronises memory access
Bootstrap program:
- stored in ROM or electrically erasable ROM (EEROM)
- firmware
- initialises all aspects of system
- locates OS kernel and loads it into memory
Once kernel is loaded, it provides services to the system and users
Services provided outside of the kernel:
- system programs that are loaded into memory at boot time
- system processes/daemons
- run while kernel is running
- on UNIX, first process is “init”
- once initial phase complete, system is fully booted and waits for some event to occur
Event occurence:
- signalled by interrupt
- from hardware - send signal to CPU
- from software - executing system call
- CPU transfers execution to a fixed location
- containing starting address where the service routine for the interrupt is located
- executes
- on completion, CPU resumes interrupted computation
Interrupts:
- transfer control to appropriate interrupt service routine
- invoke generic routine to examine interrupt info.
- call interrupt-specific handler
- table of pointers to interrupt routines is used
- low memory (first hundred locations or so)
- interrupt vector - array of addresses
- indexed by unique device number
- invoke generic routine to examine interrupt info.
- must save address of interrupted instruction
- stored on system stack
Storage:
- programs run from rewritable main memory (D/RAM) but this is volatile
- EEROM/ROM - stores factory installations/bootstrap program
- magnetic disk - secondary storage
- magnetic tape
- cache
- solid state disk
- NVRAM - DRAM with battery backup power
- load - move byte/word from main to internal register
- store - move content of a register to main
Intruction-execution cycle:
- fetch instruction from memory
- store in the instruction register
- decode and execute intructions on operands
- result may be stored back in memory
CPU Scheduling
Multiprogramming:
- maximise CPU utilisation
- several processes kept in memory at one time
- when one process has to wait, OS takes all CPU from it and gives it to another process
- repeat
CPU/IO burst cycle:
- process execution
- CPU burst –> IO burst (repeat)
- exponential/hyperexponential frequency curve (lots of short CPU and not many long CPU bursts)
- IO-bound program has many short CPU bursts
- CPU-bound program might have a few long CPU bursts
- final CPU burst ends with system request to terminate execution
- CPU burst –> IO burst (repeat)
CPU scheduler:
- short-term
- select from list of processes that are ready to execute
- not necessarily FIFO
Preemptive scheduling - scheduling decisions may take place under the following 4 circumstances:
- process switching from running to waiting (IO or wait)
- process switching from running to ready (interrupt)
- process switching from waiting to ready (completion of IO)
- process terminating
- for 1 and 4, the scheduling scheme is nonpreemptive/cooperative (no choice in the matter)
- doesn’t require special hardware (timer) needed for preemptive scheduling
- preemptive results in race conditions when data is shared among processes
- while a process is updating data, it is preempted so that a second process can run
- 2nd tries to read data, which is in an inconsistent state
- preemption affects design of OS kernel
- during processing a system call, kernel may be busy with an activity on behalf of a process
- may involve changing kernel data (eg IO queues)
- what if process is preempted in the middle of these changes and the kernel needs to read/modify the same structure?
- wait for system call to complete
- wait for IO block to take place before switching context
- ensures simple kernel structure
- poor support of real-time computing
Dispatcher:
- gives CPU control to process selected by short-term scheduler
- switch context
- switch to user mode
- jump to proper location in user program
- invoked during every process switch
- dispatch latency - time taken to stop one process and start another
Scheduling criteria - when choosing a CPU-scheduling algorithm:
- CPU utilisation
- CPU should be as busy as possible
- ideally usage should be 40-90%
- throughput
- number of processes completed per time unit
- 1 per hour for long processes
- 10 per second for short processes
- turnaround time
- interval from time of submission of a process –> its completion
- sum of periods spent waiting to get into memory, waiting in ready queue, execution, and doing IO
- generally limited by speed of output device
- waiting time
- alg. doesn’t affect amount of time during which a process executes or does IO
- only affects waiting time
- sum of periods spent waiting
- response time
- time from submission of request –> production of first response
- time to start responding, not time it takes to output the response
Desirable to maximise CPU utilisation and throughput, and minimise the others.
In most cases, we optimise the average measure.
A system with reasonable and predictable response time may be considered more desirable than one that is faster on average, but highly variable.
Scheduling Algorithms
FIFO:
- simple to understand and implement
- average waiting time often quite long
- may vary substantially if CPU burst times vary greatly
- convoy effect where processes wait for one big process to get off the CPU
- nonpreemptive (only releases upon termination or IO)
- bad for time-sharing systems
Shortest-job-first:
- associates with each process the length of the process’ next CPU burst
- CPU assigned to process with the smallest next CPU burst
- FIFO to break ties
- gives minimum average waiting time for a given set of processes
- average waiting time less than FIFO
- but, you need to know the length of the next CPU burst
- for long-term scheduling, can use the process time limit that a user specifies
- users are motivated to submit an accurate time
- lower value = faster response
- too low a value = time-limit-exceed error + resubmission
- SJF cannot be used with short-term scheduling
- can predict the next CPU burst
- exponential average of the measured lengths of previous bursts
- for
Tn
= length ofnth
CPU burst, andYn+1
= predicted value - then for
0 <= A <= 1
,Yn+1 = ATn + (1-A)Yn
A
controls relative weight of recent and past history in the prediction
- this alg. can be preemptive/nonpreemptive
- the next CPU burst of a newly arrived process may be shorter than what is left of a currently existing process
- a preemptive will preempty the current process (shortest-remaining-time-first)
- a nonpreemptive will allow the current process to finish first
- the next CPU burst of a newly arrived process may be shorter than what is left of a currently existing process
Priority:
- CPU allocated to process with highest priority
- equal-priority are scheduled as FIFO
- here, assume low numbers represent high priority (but irl, different systems use different priority numbers)
- internally defined priorities
- use some measurable quantity to compute priority
- time, memory limits, num. of open files etc
- externally defined priorities
- set by OS criteria
- importance, type and amount of funds being paid for computer use etc
- preemptive - preempt CPU if priority of new process is higher than current
- nonpreemptive - put new process at head of ready queue
- indefinite blocking/starvation - a process that is ready to run but waiting for the CPU
- low priority processes may wait indefinitely
- either they will eventually be run when the system is lightly loaded
- or the system will crash and lose all unfinished low priority processes
- low priority processes may wait indefinitely
- solution - aging
- gradually increase priority of processes that wait for a long time
Round-robin:
- designed for time-sharing systems
- FIFO with added preemption
- time slice is defined
- ready queue treated as circular
- scheduler goes around the queue, allocating CPU to each process for specified time interval
- process may have CPU burst < 1 time quantum
- release CPU voluntarily
- process may have CPU burst > 1 time quantum
- timer interrupt
- context switch
- process moved to tail of queue
- average waiting time often long
- preemptive
- want the time quantum to be large with respect to the context-switch time
- if context switch is 10% of the time quantum, then 10% of CPU time is spent in context switching
- turnaround time depends on time quantum
- can be improved if most processes finish their burst in a single time quantum
- context switching increases average turnaround time
- if the time quantum is too large, RR scheduling degenerates to FIFO
- generally, 80% of CPU bursts should be smaller than the time quantum
Multilevel queue:
- foreground/background processes
- different response time requirements
- different scheduling needs
- foreground may have external priority over background
- partition ready queue into several queues
- processes permanently assigned to one queue based on some property
- each queue has its own scheduling alg.
- scheduling among the queues is commonly fixed-priority preemptive (foreground may have absolute priority over background)
- queues can also be time-sliced
- eg 80% of CPU to foreground to RR
- 20% of CPU to background to FCFS (first come first served - FIFO)
- low scheduling overhead
- inflexible (processes stay in one queue all the time)
Multilevel feedback queue:
- processes can move between queues
- separate processes according to the characteristics of their bursts
- process using too much time –> moved to lower-priority queue
- leaves IO-bound and interactive processes in higher priority
- there is also aging so a low priority queue can be moved to a higher one
- generally defined by the following parameters
- num. of queues
- scheduling alg. of each queue
- method to determine when to upgrade to higher-priority
- method to determine when to upgrade to lower-priority
- method to determine which queue a process will enter when it needs service
- can be configured to match a specific system
- most complex alg.
Thread Scheduling
OS schedules kernel-level threads (not processes)
User-level threads managed by a thread library
These threads must be mapped to a kernel-level thread (indirect and uses a lightweight process)


If you already know about graphs and want to go into the specific sections then click one of the sections below.
1. Graphs
2. Dijkastra's Shortest Algorithm
3. Big O of Graphs
Graphs are a data structure where there are many vertices connected with each other. Think about social media websites like Facebook or Linkedln where there is a network between friends, family, or coworkers.
Here is an example of a graph. In terms of Facebook, you can think like A is friends with B or an example in Linkedln is, E is 1 connection away from B.
So here are some types of graphs. One is a directed graph: a graph with arrows and has strict connection such as, A can go to B, but B can't got to A. Think about how in Instagram, you follow Hugh Jackman but he does not follow you back. Another type is an undirected graph: a graph where two vertices know each other back and forth. For instance, you follow your friend and your friend follows you back.
We will go over simple graphs: graphs with no self loop or has no multiple edges. Here are some examples of graphs that are not simple. While they are useful in certain situations, they are not necessary to know.
Cyclic graphs are graphs with a cycle and acyclic graphs are graphs without a cycle.
Graphs can also have weights. This is called a weighted graph. Each edge has a weight.
Here are two ways we can represent a graph: an adjacency matrix (like a 2D array) and an adjacency linked list (similar to a hash table).
As you can see we represented an undirected graph in an adjacency matrix. Basically, A to B (0 to 1) and B to A (1 to 0) will be filled in the adjacency matrix with T since A and B knows each other. On the image on the right, since A knows B but not the other way, only (0,1) will be filled with T. Also, when plotting, we will first start with 0 on the x-axis then 1 on the y-axis.
With weighted graphs, we will replace T with the weight to represent the relationship.
The adjacency linked list has each vertex holding all of their neighbors. - represents a neighbor relationship in a directed graph and -> remember a relationship in an undirected graph.
Graphs can be separated apart. They could have no connections at all. These are called islands.
Basically we can make an adjecny linked list. Each element is a vertex object where it holds the name of a vertex and its list of neighbors (neighbors are reprsented in neighbor objects). You can basically make an array of holding vertex objects and in each element it will hold the vertex name and its neighbors.
So how can we traverse through a graph, there are two popular types of traversals. We will first go through depth first search. We start at the new node and see if there is children then we call depth first search on them. Once done we go onto the next child and so on till we go through all of the vertices. We will start with an array initialized with all values as false. Each index the vertex matches with the boolean value in the array.
First, we will visit A and turn it to True to represent we have visited it.
Then we visit A's child, B, and turn it to True. Also we will now call depth first search on its children. We first call it on C since C alphabetically comes first.
C gets its boolean value turned to true. but it has no children on its own so we are done from here. Now off to D.
Then D gets it boolean value turned to true. Now lets call DFS on D's children.
For all of D's children we just needed to mark it true and no need to call more DFS since there are no other children.
In the case, there was an island we would have to restart. For instance, we would have to restart at H after being done executing the first island. Now try to implement DFS in Java.
Java implementation of DFS
Another type of traversal is, Breadth First Search. Using a queue, we add the first vertex and then add the children of that vertex to the queue. Then we will pop out a vertex of the queue and call BFS with that. We keep on doing it till the queue is empty.
We first add A.
Now we add A's child B and mark A's value true.
Then we pop out B and mark its boolean value to true. Also, we add B's children: C and D.
Then we pop out C and since C does not have and children, we just mark it true and pop out the next vertex.
Then we pop out D and add its children: E, F, and G. We mark D's value true.
We pop out E, F, and G and mark each of its value true. Since they all do not have children so the queue is empty and we are done. Now try to implement it in Java.
Java implementation of BFS.
 We can do that in a process called Topological Sort where we assign numbers in order of precedence (topological numbers). For instance, we could start at A and number at zero and then label B, 1 and C, 2, and so on. The arrows show the order. We can start at any vertex and assign the numbers and all of the vertices should be assigned with the same number.
We could start at A and number at zero and label B, 1 and C, 2. But here is the problem? Since in topological sort we can start at any vertex and still assign the same number but what if we start at C? We can't number it zero because that does not have higher precedence. Plus, we will reach to a dead-end.
Now lets go back to the problem in the beginning. Lets try to do topological sort starting at vertex C. We could start at 4 on C and then backtrack and declare 3.
Then declare 2 on E. Backtrack to 1 and then 0.
This is how we would topological sort, if we start at A. It seem pretty easy if you get the previous example. Now try to implement DFS Topsort in Java on your own.
Java implementation of DFS Topsort.
We will first add all of the vertices that already has an index of zero (because of this we don't even need a driver for bfs).
We will first calculate all of the indegrees. Indegrees of a vertex are determined by how many vertices point to that vertex. We also will add them to the final sequence. Once a vertex's indegree is zero we will add them to the queue and the final sequence array. Since A and F indegrees are zero we will add them.
Now we popped A out and for the neighbors of that vertex we will decrease its indegree by 1. For instance, A's neighbors, B and D, will be decreased by 1. Since both of them are now zero, we will add it to the queue and the final sequence array. When we popped F, its neighbor (E) indegree has become 1 but it is not 0 so we can not add it.
C and E indegrees have become zero so we can add them to the queue and final array. Both C and E have no neighbors so we are done. Now try to implement BFS topsort in Java on your own.
Java implementation of BFS Topsort.
Dijkastra's shortest algorithm can be used to find the shortest path. It is responsible for many applications such as, Google Maps. It was founded by computer scientist Edsger W. Dijkstra in 1956.
Suppose we wanted to find the shortest path from A to C. Then we will first add A on done.
Then we list all of the lengths from A to its neighbor vertices. If it does not exist (the vertex is not a neigbor) put infinity or its last value. In this case, it is infinity as there has been no previous value as of now. We circled the shortest length which will be 5 meaning we are done with B and that is the shortest path from A to B.
Then we list all of the lengths from B to its neighbors excluding B since it is in done (I put a squigly line to show that we are done). Then we add 105 as we combined the length of path from B to C (100) plus the previous shortest path (5) and it will sum up to 105. D is still 10 as a direct path between B to D does not exist. D (10) is our shortest path.
Now we are at D. Since the path from D to C is 6 and the last shortest was 10 so, 6+10=16. 16 is less than 105, so 105 will be replaced with 16. The shortest path is 16.
Now find the shortest path from A to F.
Answer with explanation is below.
Implement Shortest Path between two vertices in Java using the class on the left.
Answer with explanation is below.
This is the space complexity of adjacency matrix and adjacency linked list.
Runtime of BFS and DFS traversals and Topsort BFS and DFS have the same runtime which is why overall not one is better than the other, but in certain problems one can be better than the other.
Runtime of Dijkastra's Method. It is determined by four functions: add to fringe, pick minimum, check old distance vs new distance, and update distance. So here are all the scenarios of what we used as a fringe and how it affects the four functions.


nodejs - best practices
misc links
sindresorhus/awesome-nodejs - github.com
ryanmcdermott/clean-code-javascript - github.com
i0natan/nodebestpractices - github.com
Node.js Best Practices : Matt Goldspink 20160829
- Start all projects with
npm init
- Setup
.npmrc
- Add scripts to your
package.json
- Use environment variables
- Use a style guide
- Embrace async
- Handle errors
- Ensure your app automatically restarts
- Cluster your app to improve performance and reliability
- Require all your dependencies up front
- Use a logging library to increase errors visibility
- Use Helmet if you’re writing a web app
- Monitor your applications
- Test your code
Node.js Best Practices - How to Become a Better Developer in 2017 : blog.risingstack.com
switching node version between projects
articles
nvm vs n! - .gitignore - 20170522
How I manage multiple Node.js versions - steelbrain.me - 20160719
The Best Way to Install Node.js - yoember.com - 20180929
tooling comparison
Taken from stackoverflow answer from nvm
maintainer
The most-used version managers for node are without a doubt http://nvm.sh, https://www.npmjs.com/package/nave, and https://www.npmjs.com/package/n.
nvm
is for modifying individual shell sessions to use the version you want.nave
is for launching subshells with the version you want loaded. n is for switching a single system-wide version of node.
nvm
uses a.nvmrc
file, which like.ruby-version
, contains the version-ish string X you’d normally couple withnvm use X
ornvm install X
.nvm use
ornvm install
by itself will locate the.nvmrc
file, as will simply sourcingnvm
upon opening a new shell.It appears
nave
supports a.naverc
file, but I’m not too familiar with its usage.
n
doesn’t appear to support any such config, but as it’s system-wide, it doesn’t really make as much sense to do so.
avn
supports.node-version
and attempts to provide automatic version switching by hooking intocd
, afternvm
decided that was too invasive a behavior to include.
nvm
NVM Automatic Switching : gist
n
Node.js version management: no subshells, no profile setup, no convoluted API, just simple.
usage
Super easy but system wide.
List installed version
n
Output :
0.8.14
ο 0.8.17
0.9.6
Change the active version by selecting the line and hit space bar.
Install desired node version with n <version>
ex n 10.2.1
.
issues
Possible issue with npm
, any npm
command will output this :
npm WARN lifecycle npm is using /home/<HOME_DIR>/n/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
Fixed by adding a .npmrc file in the project root dir containing :
scripts-prepend-node-path=true
node
package with npx
using a node package inside package.json
cf tweet
app structure
- DRY sur le config projet (eslint, code quality, etc …)
- automatisation des conventions
- 12 factors
- logging
- swagger
- unit / functionnal testing
- CI (circle & jenkins)
- deploy
- health checking
- métriques métiers
Advanced Node.js Project Structure Tutorial - 20180508
microservices
The Best Node.js & Microservices Articles we Ever Wrote - blog.risingstack.com - 20180516
Node.js - File System - www.tutorialspoint.com
- Synchronous vs Asynchronous
- Open a File
- Flags
- Get File Information
- Writing a File
- Reading a File
- Closing a File
- Truncate a File
- Delete a File
- Create a Directory
- Read a Directory
- Remove a Directory


The purpose of the Evacuation File is to help determine how the evacuation has impacted you and your family in order for Emergency Support Services (ESS) to coordinate or provide you with assistance to support you in your recovery.
Please answer all questions to the best of your knowledge. Required fields are marked with a red asterisk.
Please answer all questions to the best of your knowledge. Required fields are marked with a red asterisk.
Please read through and confirm that your details are all correct before submitting.
Once you have submitted this form you will only be able to edit your details with the assistance of an Emergency Support Services volunteer.


Based in Houston, but open to relocation within Texas, I develop websites for companies looking to successfully reach all visitors.
Single page, static website using HTML5, CSS3, JavaScript, Bootstrap,
An E-Commerce Site that uses HTML5/CSS3, JavaScript, Rails, AJAX, ActionCable, and caching.
Multi-page portfolio using HTML/CSS exclusively.
A personal website using HTML,CSS, and JavaScript.


Please Enter Your Information:
First Name:
Last Name:
Password:
Confirm Your Password:
Email Address:
Submit Your Information


A dark themed filled Line chart with a red tinge to it. The chart is using a gradient as the fill color and is also using the spline option. The background of the chart is dark by using the colorsBackground
option.
 Put this where you want the chart to show up:

This is the code that generates the chart - it should be placed AFTER the

tag:


Font Auto-resizer Options
* Leave blank to disable setting
Smallest Size:
px
Largest Size:
px
Settings cleared successfully.
Clear Settings


public abstract class AbstractPollingIoController<S extends AbstractIOSession,CH> extends AbstractIOController<S>
AbstractIOController
.disposalFuture, disposalLock
| 构造器和说明 |
|---|
AbstractPollingIoController(java.util.concurrent.Executor executor,
java.lang.Class<? extends IOProcessor<S>> processorType,
AbstractIOConfig config)
Constructor
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract java.util.Iterator<java.nio.channels.SelectableChannel> |
allChannels()
Iterator for all the client sockets polled for connection. |
protected abstract S |
buildSession(java.lang.String host,
java.lang.Integer port)
build a IOSession connected to specified host:port,
use the controller's configuration as the base config
|
protected abstract S |
buildSession(java.lang.String host,
java.lang.Integer port,
AbstractIOConfig config)
build a IOSession connected to specified host:port
with the specified configuration
|
void |
cancelConnect(IOFuture future)
Offer a cancel-connect request to Controller
|
protected abstract void |
closeChannel(CH channel)
Close a client socket.
|
protected abstract boolean |
connect(CH channel,
java.net.SocketAddress remoteAddress)
Connect a newly created client socket channel to a remote address.
|
boolean |
connect(IOFuture future)
Offer a Connect request to Controller,
|
S |
createSession(java.net.SocketAddress remoteAddress,
AbstractIOConfig config)
Create a new
IOSession |
S |
createSession(java.lang.String remoteHost,
int remotePort,
AbstractIOConfig config)
Create a new
IOSession |
protected abstract void |
destroy()
Destroy the controller, will be called by
AbstractIOController.dispose() |
protected void |
dispose0()
This method will release any resources.
|
protected abstract boolean |
finishConnect(CH channel)
Finish the connection of a client socket after it was reported to be ready by the
select(int) call. |
AbstractIOConfig |
getConfig() |
long |
getConnectCheckIntervalMs()
Get the select timeout interval for OP_CONNECT
used for
Selector.select(long timeout) |
protected java.util.concurrent.Executor |
getDefaultThreadPollExecutor()
This method will create and @return a default executor.
|
protected abstract IOFuture |
getFuture(CH channel)
get the IOFuture for a given client socket channel
|
boolean |
isSecure()
Note : we don't support SSL/TLS protocol by now
|
protected abstract boolean |
isSelectorEmpty() |
protected abstract CH |
newChannel()
Create a new client socket channel
|
protected abstract S |
newSession(IOProcessor<S> processor)
Create a new IOSession instance
|
protected abstract void |
registerConnecting(CH channel,
IOFuture future)
Register a new client socket for connection operation, add it to polling
|
protected abstract int |
select(int timeout)
Check for connected sockets, interrupt when at least one connection is
processed (connected or failed to connect).
|
protected abstract java.util.Iterator<java.nio.channels.SelectableChannel> |
selectedChannel()
Iterator for the set of sockets with connection processed. |
void |
setConnectCheckIntervalMs(long connectCheckIntervalMs)
Set the select timeout intervel for OP_CONNECT
used for
Selector.select(long timeout)
the value greater than 1000L will not take effect |
void |
setSecure(boolean secure)
Set this controller to be secure mode (SSL/TLS)
Note : we don't support SSL/TLS protocol by now
|
void |
setSelectable(boolean selectable)
Set selectable.
|
protected abstract void |
wakeup()
Interrupt the
select(int timeout) method. |
activate, deactivate, dispose, executeRunnable, getExecutor, getFilterChainBuilder, getHandler, isActive, isDisposing, setHandler
public AbstractPollingIoController(java.util.concurrent.Executor executor, java.lang.Class<? extends IOProcessor<S>> processorType, AbstractIOConfig config)
executor
- can provided by outside code.
Pass null
if you want this controller to create a Default one.processorType
- used to construct processor which will be responsible for handling
read/write I/O events.config
- the base configuration used for creation of IOSession
's configurationprotected java.util.concurrent.Executor getDefaultThreadPollExecutor()
getDefaultThreadPollExecutor
在类中 AbstractIOController<S extends AbstractIOSession>
protected void dispose0() throws java.lang.Exception
AbstractIOController.dispose()
.dispose0
在类中 AbstractIOController<S extends AbstractIOSession>
java.lang.Exception
- If the dispose failedpublic boolean isSecure()
public void setSecure(boolean secure)
secure
- true for secure mode. false as defaultpublic long getConnectCheckIntervalMs()
Selector.select(long timeout)
public void setConnectCheckIntervalMs(long connectCheckIntervalMs)
Selector.select(long timeout)
the value greater than 1000L will not take effectconnectCheckIntervalMs
- interval time in millisecondpublic void setSelectable(boolean selectable)
selectable
- Set to true when the controller has been initialized
Set to false when the controller will be destroyed.public AbstractIOConfig getConfig()
public S createSession(java.net.SocketAddress remoteAddress, AbstractIOConfig config)
IOSession
remoteAddress
- the SocketAddress
of remote endpoint this session will
connect to lately.config
- session's configuration which used only by this session.
Modification to this configuration will effect on the session immediately.public S createSession(java.lang.String remoteHost, int remotePort, AbstractIOConfig config)
IOSession
remoteHost
- the host domain of remote endpoint this session will
connect to lately.remotePort
- the port on which the remote endpoint listened for connections.config
- session's configuration which used only by this session.
Modification to this configuration will effect on the session immediately.public boolean connect(IOFuture future)
future
- the ConnectFuture
implementation bound to
the IOSession
which should be built a connection
to some remote endpoint.public void cancelConnect(IOFuture future)
future
- the ConnectFuture
implementation should be canceledprotected abstract S buildSession(java.lang.String host, java.lang.Integer port)
host
- the host domain of remote endpoint this session will
connect to lately.port
- the port on which the remote endpoint listened for connections.protected abstract S buildSession(java.lang.String host, java.lang.Integer port, AbstractIOConfig config)
host
- the host domain of remote endpoint this session will
connect to lately.port
- the port on which the remote endpoint listened for connections.config
- session's configuration which used only by this session.
Modification to this configuration will effect on the session immediately.protected abstract S newSession(IOProcessor<S> processor)
processor
- The processor the session will offer to after connection built.protected abstract CH newChannel() throws java.lang.Exception
java.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract void closeChannel(CH channel) throws java.lang.Exception
channel
- the client socketjava.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract boolean connect(CH channel, java.net.SocketAddress remoteAddress) throws java.lang.Exception
channel
- the client socket channelremoteAddress
- the remote address where to connectjava.lang.Exception
- If the connect failedprotected abstract boolean finishConnect(CH channel) throws java.lang.Exception
select(int)
call.channel
- the client socket channel to finish the connectionjava.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract void registerConnecting(CH channel, IOFuture future) throws java.lang.Exception
channel
- client socket channelfuture
- the ConnectFuture
as the attachmentjava.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract IOFuture getFuture(CH channel)
channel
- the socket client channelprotected abstract int select(int timeout) throws java.lang.Exception
selectedChannel()
to get all the client socket processed.timeout
- The timeout for the selectjava.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract boolean isSelectorEmpty()
protected abstract void wakeup()
select(int timeout)
method.
Used when the polled sessions queue changedprotected abstract java.util.Iterator<java.nio.channels.SelectableChannel> selectedChannel()
Iterator
for the set of sockets with connection processed.
during the last select(int timeout)
call.protected abstract java.util.Iterator<java.nio.channels.SelectableChannel> allChannels()
Iterator
for all the client sockets polled for connection.protected abstract void destroy() throws java.lang.Exception
AbstractIOController.dispose()
java.lang.Exception
- any exception thrown by the underlying systems calls