Developing a Spring Framework MVC applicaton step-by-step
Part 2 – Developing and Configuring the Application
Thomas Risberg
July, 2003
This is Part 2 of a step-by-step account of how to develop a web application from scratch using the Spring Framework. In Part 1 (Steps 1 – 12) we configured the environment and set up a basic application that we will build upon.
This is what we have to start with.
An intoduction page index.jsp.
A DispatcherServlet with a corresponding springapp-servlet.xml configuration file.
A controller springappController.java.
A view hello.jsp.
We will now improve on these parts to build a more useful application.
Step 13 – Improve index.jsp
We will make use of JSP Standard Tag Library (JSTL) so I will start by copying the JSTL files we need to our WEB-INF/lib directory. Copy jstl.jar and standard.jar from the spring-framework-0.9/lib/jstl directory to the springapp/war/WEB-INF/lib directory. I am also creating a “header” file that will be incuded in every JSP page that I'm going to write. This will make development easier and I will be sure that I have the same definitions in all JSPs. I am going to put all JSPs in a directory named jsp under the WEB-INF directory. This will ensure that only the controller has access to the views - it is not possible to get to these pages by entering them directly as a URL in the browser. This strategy might not work in all application servers and if this is the case with the one you are using, just move the jsp directory up a level. You would then use springapp/war/jsp as the directory instread of springapp/war/WEB-INF/jsp in all the code examples that will follow.
|
springapp/war/WEB-INF/jsp/include.jsp |
<%@ page session="false"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %> |
Now we can change index.jsp to use this inlude and since we are using JSTL we can use the <c:redirect> tag for redirecting to our Controller. This ties the index.jsp into our application framework.
|
springapp/war/index.jsp |
<%@ include file="/WEB-INF/jsp/include.jsp" %> <%-- Redirected because we can't set the welcome page to a virtual URL. --%> <c:redirect url="/hello.htm"/> |
Step 14 – Improve the view and the controller
I am going to move the view hello.jsp to the WEB-INF/jsp directory. The same include that was added to index.jsp gets added to hello.jsp. I also add the current date and time as output that I will retrieve from the model, passed to the view, using the JSTL <c:out> tag.
|
springapp/war/WEB-INF/jsp/hello.jsp |
<%@ include file="/WEB-INF/jsp/include.jsp" %>  <title>Hello :: Spring Application</title>
Hello - Spring Application

Greetings, it is now <c:out value="${now}"/>
   |
For SpringappController.java there are a few changes we need to make. Change the view to WEB-INF/jsp/hello.jsp since we moved the file to this new location. Also add a string contining the current data and time as the model.
|
springapp/src/SpringappController.java |
import com.interface21.web.servlet.mvc.Controller; import com.interface21.web.servlet.ModelAndView; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class SpringappController implements Controller { /** Logger for this class and subclasses */ protected final Log logger = LogFactory.getLog(getClass()); public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String now = (new java.util.Date()).toString(); logger.info("returning hello view with " + now); return new ModelAndView("WEB-INF/jsp/hello.jsp", "now", now); } } |
Now we are ready to try this after we build and deploy this new code. We enter http://localhost:8080/springapp in a browser and that should pull upp index.jsp, which should redirect to hello.htm, which in turn gets us to the controller that sends the data and time to the view.
Step 15 – Decouple the view and the controller
Right now the controller specifies the full path of the view, which creates an unnessecary dependency between the controller and the view. Ideally we would like to map to the view using a logical name, allowing us to switch the view without having to change the controller. You can set this mapping in a properties file if you like using a ResourceBundleViewResolver and a SimpleUrlHandlerMapping class. If your mapping needs are simple it is easier to just set a prefix and a suffix on the InternalResourceViewResolver. The latter approach is the one that I will implement now, so I modify the springapp-servlet.xml and include this viewResolver entry. I have elected to use a JstlView which will enable us to use JSTL in combination with message resource bundles and it will also support internationalization.
|
springapp/war/WEB-INF/springapp-servlet.xml |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "https://raw.githubusercontent.com/peterchenhdu/interface21/master/interface21-framework/src/main/java/com/interface21/beans/factory/xml/spring-beans.dtd">  <beans> <bean id="springappController" class="SpringappController"/> <bean id="urlMapping" class="com.interface21.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/hello.htm">springappController</prop> </props> </property> </bean> <bean id="viewResolver" class="com.interface21.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass"><value>com.interface21.web.servlet.view.JstlView</value></property> <property name="prefix"><value>/WEB-INF/jsp/</value></property> <property name="suffix"><value>.jsp</value></property> </bean> </beans> |
So now I can remove the prefix and suffix from the view name in the contoller.
|
springapp/src/SpringappController.java |
import com.interface21.web.servlet.mvc.Controller; import com.interface21.web.servlet.ModelAndView; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class SpringappController implements Controller { /** Logger for this class and subclasses */ protected final Log logger = LogFactory.getLog(getClass()); public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String now = (new java.util.Date()).toString(); logger.info("returning hello view with " + now); return new ModelAndView("hello", "now", now); } } |
Compile and deploy and the application should still work.
Step 16 – Add some classes for business logic
So far our application is not very useful. I would like to add a little bit of business logic in form of a Product class and a class that will manage all the products. I name this management class ProductManager. In order to separate the web dependent logic from the business logic I will create two separate packages for the Java source – web and bus. If this was an application for a real company I would name the packages something like com.mycompany.web and com.mycompany.bus, but since this is just a demo application I will keep the package names real short. The Product class is implemented as a JavaBean – ith has the default constructor (automatically provided if we don't specify any constructors) and getters and setters for the two instance variables description and price. I also make it Serializable, not necessary for our application, but could come in handy later on if we have to pass this class between different application layers.
|
springapp/src/bus/Product.java |
package bus; import java.io.Serializable; public class Product implements Serializable { private String description; private Double price; public void setDescription(String s) { description = s; } public String getDescription() { return description; } public void setPrice(Double d) { price = d; } public Double getPrice() { return price; } } |
The ProductManager holds a List of Products, and again this this class is implemented as a JavaBean.
|
springapp/src/bus/ProductManager.java |
package bus; import java.io.Serializable; import java.util.List; public class ProductManager implements Serializable { private List products; public void setProducts(List p) { products = p; } public List getProducts() { return products; } } |
Next, I modify the SpringappController to hold a reference to this ProductManager class. As you can see, it is now in a separate package called web – remember to move the source to this new location. I also add code to have the controller pass some product information to the view. The getModelAndView now returns a Map with both the date and time and the product manager reference.
|
springapp/src/SpringappController.java |
package web; import com.interface21.web.servlet.mvc.Controller; import com.interface21.web.servlet.ModelAndView; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Map; import java.util.HashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import bus.Product; import bus.ProductManager; public class SpringappController implements Controller { /** Logger for this class and subclasses */ protected final Log logger = LogFactory.getLog(getClass()); private ProductManager prodMan; public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String now = (new java.util.Date()).toString(); logger.info("returning hello view with " + now); Map myModel = new HashMap(); myModel.put("now", now); myModel.put("products", getProductManager().getProducts()); return new ModelAndView("hello", "model", myModel); } public void setProductManager(ProductManager pm) { prodMan = pm; } public ProductManager getProductManager() { return prodMan; } } |
Step 17 – Modify the view to display business data and add support for message bundle
Using the JSTL <c:forEach> tag, I add a section that displays product information. I have also replaced the title, heading and greeting text with a JSTL <fmt:message> tag that pulls the text to display from a provided 'message' source – I will show this source in a later step.
|
springapp/war/WEB-INF/jsp/hello.jsp |
<%@ include file="/WEB-INF/jsp/include.jsp" %>  <title><fmt:message key="title"/></title>
<fmt:message key="heading"/>

<fmt:message key="greeting"/> <c:out value="${model.now}"/>

Products
 <c:forEach items="${model.products}" var="prod"> <c:out value="${prod.description}"/> $<c:out value="${prod.price}"/>

 </c:forEach>   |
Step 18 – Add some test data to automatically populate some business objects
I am not going to add any code to load the business objects from a database just yet. Instead, we can “wire up” a couple of instances using Spring's bean and application context support. I will simply put the data I need as a couple of bean entries in springapp-servlet.xml. I will also add the messageSource entry that will pull in the messages resource bundle ('messages.properties') that I will create in the next step.
|
springapp/war/WEB-INF/springapp-servlet.xml |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "https://raw.githubusercontent.com/peterchenhdu/interface21/master/interface21-framework/src/main/java/com/interface21/beans/factory/xml/spring-beans.dtd">  <beans> <bean id="springappController" class="web.SpringappController"> <property name="productManager"> <ref external="prodMan"/> </property> </bean> <bean id="prodMan" class="bus.ProductManager"> <property name="products"> <list> <ref external="product1"/> <ref external="product2"/> <ref external="product3"/> </list> </property> </bean> <bean id="product1" class="bus.Product"> <property name="description"><value>Lamp</value></property> <property name="price"><value>5.75</value></property> </bean> <bean id="product2" class="bus.Product"> <property name="description"><value>Table</value></property> <property name="price"><value>75.25</value></property> </bean> <bean id="product3" class="bus.Product"> <property name="description"><value>Chair</value></property> <property name="price"><value>22.79</value></property> </bean> <bean id="messageSource" class="com.interface21.context.support.ResourceBundleMessageSource"> <property name="basename"><value>messages</value></property> </bean> <bean id="urlMapping" class="com.interface21.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/hello.htm">springappController</prop> </props> </property> </bean> <bean id="viewResolver" class="com.interface21.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass"><value>com.interface21.web.servlet.view.JstlView</value></property> <property name="prefix"><value>/WEB-INF/jsp/</value></property> <property name="suffix"><value>.jsp</value></property> </bean> </beans> |
Step 19 – Add the message bundle and a 'clean' target to build.xml
I create a 'messages.properties' file in the war/WEB-INF/classes directory. This properties budle so far has three entries matching the keys specified in the <fmt:message> tags that we added to the hello.jsp.
|
springapp/war/WEB-INF/classes/messages.properties |
title=SpringApp heading=Hello :: SpringApp greeting=Greetings, it is now |
Since we moved some source files around, it makes sense to add a 'clean' and an 'undeploy' target to the build scripts. I add the following entries to the build.xml file.
<target name="clean" description="Clean output directories"> <delete> <fileset dir="${build.dir}"> <include name="**/*.class"/> </fileset> </delete> </target> <target name="undeploy" description="Un-Deploy application"> <delete> <fileset dir="${deploy.path}/${name}"> <include name="**/*.*"/> </fileset> </delete> </target> |
Now stop the Tomcat server, run the clean, undeploy and deploy targets. This should remove all old class files, re-build the application and deploy it. Start up Tomcat again and you should see the following:
Back Part 3 – Adding Unit Tests and a Form to the Application
Copyright © 2003, Thomas Risberg


Tired of all those bullet-hell button-mashers? Well then, Shape of Infinity is the game for you. It's turn-based mechanics add a layer of complexity while YOU, the player, dynamically dodge bullets in REAL time! Forever can't last long enough again, Shape of Infinity.
During the 2014 YCHacks event I hacked wide open some pebble watches. Initially convinced I could make the first great REM sleep cycle app, it turns out that has already been done. Early the next morning, I converted my work into a Jumping Jack Counter app. Ever forget how many jacks you have done? Never again.
Chosen out of over 1000 applicants, my independent work gave me a chance to make a large project like I had never accomplished before. My time was well spent, making connections with other students and gaining the respect of my instructors. I cut my teeth on MGWU, now I am ready to take a bite out of technololgy.


--- layout: post title: "Recovering from common Ruby on Rails errors and pitfalls" date: 2015-12-29T21:31:03-05:00 subtitle: Series: Recovering from ruby on rails errors categories: - series tags: - ruby - ruby on rails - errors ---
Ruby on Rails is great to give out detailed error messages. Additionally, there is a wealth of knownledge in the online community of other developers running into the exact same error and the reasons behind why they are occuring. Over the past couple months I have compiled 5 errors that I see most often.
Occassionally, when halting or using ctrl+c
to stop a rails server instance it will fail to unlock its process id. This will prevent you from starting a new server for the project as the server will think it is still running when it is in fact not.
Remove the server.pid file from the project.
rm /tmp/pids/server.pid
This error means that the port number you specified is still in use by another application or potentially an unclosed instance of your rails server. Typically the port Rails uses is 3000 so we need to make sure that there isn't another process already using it.
List out all the processes using the port your Rails server is using (default 3000). Switch tcp:3000 to just tcp if you want to list all processes.
lsof -wni tcp:3000
You should receive an output that looks like this:
{% highlight bash %} COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ruby 41704 jfrankel 12u IPv6 0xf3fe9a8ff1e035b9 0t0 TCP [::1]:hbci (LISTEN) ruby 41704 jfrankel 13u IPv4 0xf3fe9a8ff6649a29 0t0 TCP <IP_ADDRESS>:hbci (LISTEN) {% endhighlight %}Then all you need to do is kill the specific process based on its PID. You can supply multiple PID's to the kill method separated by a space each if there are additional processes that need to be stopped.
kill -9 41704
Rails console doesn't exit cleanly when you use ctrl+z
. This is due to the fact that ctrl+z
doesn't actually exit a command line program but instead pauses them. Because of this the commands in the terminal get all jumbled up.
exit
or using the preferred stop command of ctrl+c
will properly stop rails console, but this is only valid for the next time you run rails console. For now you will have to restart the current terminal session or just close the window and start a new terminal session up.
This is a farily straight forward error. Try re-reading the output error message and it starts to make sense. It is saying that there is an uninitalized constant, which could be a class or variable.
This most likely is a class and or variable name that has a typo in it or doesn't exist yet in this context.
This error is indicating that some JSON is not being parsed correctly. In the case of cookies it could mean that the cookie doesn't exist or is an valid that is not able to be parsed.
|| "{}"
{% highlight ruby %}
def preferences
@_preferences ||= MultiJson.load(cookies["preferences_#{get_preference_group}"] || "{}")
end
{% endhighlight %}
Do you have a different solution to a common error I've listed here? Got another error you keep running into? Leave me a comment below. I'm looking forward to hearing from you.


Home
(current)
Recruitment
Services
Pathfinder
SeAT
Recruitment
So you want to apply eh? Follow these steps to enter our recruitment process
These are our requirements
At least 30M SP
Active in the EU Timezone
Passion in destruction
A taste for tears
*Alts are welcome and encouraged*
Email address
We'll never share your email with anyone else.
EVE-Username
Submit


{% extends "base.html" %} {% load static from staticfiles %} {% block extrahead %} {% endblock %} {% load filters %} {% block title %}Worlds at War - Welcome{% endblock %} {% block content %}
Many thanks to the following, who have decided to support me and Worlds at War:
| {{ donator.worldid |worldlink:'username' }} | {% if forloop.counter|divisibleby:"4" %}


|
|
||
ProductsMagic Mechanical Service (MMS) install / repair HVAC systems, commonly known as air conditioners and furnaces. We are proud to be a dealer of American Standard heating, air conditioning and air purification products. As independent dealer, we have right to offer other brands of HVAC products that fit the best.
MMS designs indoor comfort systems with heating, air conditioning and air purification products that best fit your needs and wishes. The progress in engineering and manufacturing made available heating and air conditioning systems with wide range of features and technical characteristics. Let Magic Mechanical comfort consultant help you determine the right system for your home, choose from a variety of heating, air conditioning and air purification products and design a total comfort system that fits your home and your needs.
Call for a free in home consultation and estimate for a new HVAC system installation or replacement
Furnacefrom a basic modern furnace to the most advanced, high-efficiency, variable-speed, three-stage heating, communicating furnace, providing the best comfort and up to 96% energy efficiency.
Hybrid Heating(dual fuel) system that operates on electricity and gas fuel, allowing owner to choose between energy sources.
Air conditionerwith SEERs ranging from 13 to as high as 21, are available in single-stage and two-stage cooling. Two-stage cooling systems deliver quiet operation, better temperature control, and lower operating cost. The higher SEER (seasonal energy efficiency rating), the more energy efficient is air conditioner.
Ductless heater and air conditionerThey provide heating-cooling to the space where it is needed.
Air purification systemFrom basic furnace filter to the most advanced filtration systems, which clean the air in a whole house, removing up to 99.98% of unwanted particles and allergens.
Humidifier and de-humidifierTo optimize indoor humidity.
Indoor comfort controllerTo set level of indoor comfort.
Zone controlA system that keeps temperature in each zone-room independently.
For more details and to find what is best for you, call |
||


| Methods' Summary |
| attachFrame |
attaches a XFrame to a layout manager.
|
| reset |
resets the layout manager and remove all of its internal user interface
elements.
|
| getCurrentDockingArea |
provides the current docking area size of the layout manager.
|
| getDockingAreaAcceptor |
retrieves the current docking area acceptor that controls the border space of the frame's
container window.
|
| setDockingAreaAcceptor |
sets a docking area acceptor that controls the border space of the frame's container window.
|
| createElement |
creates a new user interface element.
|
| destroyElement |
destroys a user interface element.
|
| requestElement |
request to make a user interface element visible if it is not in hidden state.
|
| getElement |
retrieves a user interface element which has been created before.
|
| getElements |
retrieves all user interface elements which are currently instanciated.
|
| showElement |
shows a user interface element.
|
| hideElement |
hides a user interface element.
|
| dockWindow |
docks a window based user interface element to a specified docking area.
|
| dockAllWindows |
docks all windows which are member of the provided user interface element type.
|
| floatWindow |
forces a window based user interface element to float.
|
| lockWindow |
locks a window based user interface element if it's in a docked state.
|
| unlockWindow |
unlocks a window based user interface element if it's in a docked state.
|
| setElementSize |
sets a new size for a window based user interface element.
|
| setElementPos |
sets a new position for a window based user interface element.
|
| setElementPosSize |
sets a new position and size for a window based user interface element.
|
| isElementVisible |
retrieves the current visibility state of a window based user interface element.
|
| isElementFloating |
retrieves the current floating state of a window based user interface element.
|
| isElementDocked |
retrieves the current docking state of a window based user interface element.
|
| isElementLocked |
retrieves the current lock state of a window based user interface element.
|
| getElementSize |
retrieves the current size of a window based user interface element.
|
| getElementPos |
retrieves the current pixel position of a window based user interface element.
|
| lock |
prohibit all layout updates until unlock is called again.
|
| unlock |
permit layout updates again.
|
| doLayout |
forces a complete new layouting of all user interface elements.
|
| setVisible |
sets the layout manager to invisible state and hides all user interface elements.
|
| isVisible |
retrieves the visibility state of a layout manager.
|
| Methods' Details |
attachFrame
| void |
| attachFrame( |
[in] XFrame |
Frame ); |
- Description
- attaches a XFrame to a layout manager.
- Parameter Frame
- specifies the frame that should be attached to the layout manager
A layout manager needs a XFrame to be
able to work. Without a it no user interface elements can be created.
|
|
reset
- Description
- resets the layout manager and remove all of its internal user interface
elements.
This call should be handled with care as all user interface elements will
be destroyed and the layout manager is reseted to a state after a
attachFrame has been made. That means an attached frame
which has been set by attachFrame is not released.
The layout manager itself calls reset after a component has been attached
or reattached to a frame.
|
|
getCurrentDockingArea
- Description
- provides the current docking area size of the layout manager.
- Returns
- The ::com::sun::star::awt::Rectangle contains pixel values. The
members of ::com::sun::star::awt::Rectangle are filled as following:
- X = docking area on left side (in pixel)
- Y = docking area on top side (in pixel)
- Width = docking area on right side (in pixel)
- Height = docking area on bottom side (in pixel)
|
|
getDockingAreaAcceptor
- Description
- retrieves the current docking area acceptor that controls the border space of the frame's
container window.
- Returns
- current docking area acceptor which controls the border space of frame's container window.
A docking area acceptor retrieved by this method is owned by the layout manager. It is not
allowed to dispose this object, it will be destroyed on reference count!
|
|
setDockingAreaAcceptor
- Description
- sets a docking area acceptor that controls the border space of the frame's container window.
- Parameter xDockingAreaAcceptor
- a docking area acceptor which controls the border space of frame's container window.
A docking area acceptor decides if the layout manager can use requested border space for
docking windows. If the acceptor denies the requested space the layout manager automatically
set all docked windows into floating state and will not use this space for docking.
After setting a docking area acceptor the object is owned by the layout manager. It is not
allowed to dispose this object, it will be destroyed on reference count!
|
|
createElement
| void |
| createElement( |
[in] string |
ResourceURL ); |
- Description
- creates a new user interface element.
- Parameter ResourceURL
- specifies which user interface element should be created. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
|
|
destroyElement
| void |
| destroyElement( |
[in] string |
ResourceURL ); |
- Description
- destroys a user interface element.
- Parameter ResourceURL
- specifies which user interface element should be destroyed. A resourcce URL must meet
the following syntax: "private:resource/$type/$name". It is only allowed to use ascii
characters for type and name.
|
|
requestElement
| boolean |
| requestElement( |
[in] string |
ResourceURL ); |
- Description
- request to make a user interface element visible if it is not in hidden state.
- Parameter ResourceURL
- specifies which user interface element should be made visible. A resourcce URL must
meet the following syntax: "private:resource/$type/$name". It is only allowed to use
ascii characters for type and
name.
- Returns
- returns true if the user interface element could be made visible, otherwise
false will be returned.
If a user interface element should forced to the visible state
XLayoutManager::showElement should be used. This function can be
used for context dependent elements which should respect a the current visibility
state.
|
|
getElement
| ::com::sun::star::ui::XUIElement |
| getElement( |
[in] string |
ResourceURL ); |
- Description
- retrieves a user interface element which has been created before.
- Parameter ResourceURL
- specifies which user interface element should be retrieved. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
The layout manager instance is owner of the returned user interface element. That means that the life time of
the user interface element is controlled by the layout manager. It can be disposed at every time!
|
|
getElements
- Description
- retrieves all user interface elements which are currently instanciated.
- Returns
- a sequence of user interface elements providing ::com::sun::star::ui::XUIElement
interface.
The layout manager instance is owner of the returned user interface elements. That means that the life time of
the user interface elements is controlled by the layout manager. They can be disposed at every time!
|
|
showElement
| boolean |
| showElement( |
[in] string |
ResourceURL ); |
- Description
- shows a user interface element.
- Parameter ResourceURL
- specifies which user interface element should be shown. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- returns true if the user interface element has been shown, otherwise false will be returned.
|
|
hideElement
| boolean |
| hideElement( |
[in] string |
ResourceURL ); |
- Description
- hides a user interface element.
- Parameter ResourceURL
- specifies which user interface element should be hidden. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- returns true if the user interface element has been hidden, otherwise false will be returned.
|
|
dockWindow
| boolean |
| dockWindow( |
[in] string |
ResourceURL, |
| [in] ::com::sun::star::ui::DockingArea |
DockingArea, |
| [in] ::com::sun::star::awt::Point |
Pos ); |
- Description
- docks a window based user interface element to a specified docking area.
- Parameter ResourceURL
- specifies which user interface element should be docked. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Parameter DockingArea
- specifies on which docking area the window based user interface element should docked.
- Parameter Pos
- specifies the position inside the docking area.
- Returns
- returns true if the user interface element has been docked, otherwise false will be returned.
- See also
- ::com::sun::star::ui::DockingArea
|
|
dockAllWindows
| boolean |
| dockAllWindows( |
[in] short |
nElementType ); |
- Description
- docks all windows which are member of the provided user interface element type.
- Parameter nElementType
- specifies which user interface element type should be docked.
- Returns
- returns true if all user interface elements of the requested type could be
docked, otherwise false will be returned.
- See also
- ::com::sun::star::ui::UIElementType
|
|
floatWindow
| boolean |
| floatWindow( |
[in] string |
ResourceURL ); |
- Description
- forces a window based user interface element to float.
- Parameter ResourceURL
- specifies which user interface element should be float. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- returns true if the user interface element has been docked, otherwise false will be returned.
|
|
lockWindow
| boolean |
| lockWindow( |
[in] string |
ResourceURL ); |
- Description
- locks a window based user interface element if it's in a docked state.
- Parameter ResourceURL
- specifies which user interface element should be locked. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- returns true if the user interface element has been locked, otherwise false will be returned.
|
|
unlockWindow
| boolean |
| unlockWindow( |
[in] string |
ResourceURL ); |
- Description
- unlocks a window based user interface element if it's in a docked state.
- Parameter ResourceURL
- specifies which user interface element should be unlocked. A resourcce URL must
meet the following syntax: "private:resource/$type/$name". It is only allowed
to use ascii characters for type and name.
- Returns
- returns true if the user interface element has been unlocked, otherwise
false will be returned.
|
|
setElementSize
| void |
| setElementSize( |
[in] string |
ResourceURL, |
| [in] ::com::sun::star::awt::Size |
Size ); |
- Description
- sets a new size for a window based user interface element.
- Parameter ResourceURL
- specifies which user interface element should be resized. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Parameter Size
- specifies the new size in pixel.
It is up to the layout manager to decide if the user interface element can be resized. The new size can be retrieved
by calling getElementSize.
|
|
setElementPos
| void |
| setElementPos( |
[in] string |
ResourceURL, |
| [in] ::com::sun::star::awt::Point |
Pos ); |
- Description
- sets a new position for a window based user interface element.
- Parameter ResourceURL
- specifies which user interface element should be moved. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Parameter Pos
- specifies the new position in pixel.
It is up to the layout manager to decide if the user interface element can be moved. The new position can be retrieved
by calling getElementPos.
|
|
setElementPosSize
| void |
| setElementPosSize( |
[in] string |
ResourceURL, |
| [in] ::com::sun::star::awt::Point |
Pos, |
| [in] ::com::sun::star::awt::Size |
Size ); |
- Description
- sets a new position and size for a window based user interface element.
- Parameter ResourceURL
- specifies which user interface element should be moved and resized. A resourcce URL must meet the following
syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Parameter Pos
- specifies the new position in pixel.
- Parameter Size
- specifies the new position in pixel.
It is up to the layout manager to decide if the user interface element can be moved and resized. The new position and size can
be retrieved by calling getElementPos and getElementSize.
|
|
isElementVisible
| boolean |
| isElementVisible( |
[in] string |
ResourceURL ); |
- Description
- retrieves the current visibility state of a window based user interface element.
- Parameter ResourceURL
- specifies for which user interface element the visibility state should be retrieved. A resource URL must meet
the following syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- true if the user interface element is visible, otherwise false.
|
|
isElementFloating
| boolean |
| isElementFloating( |
[in] string |
ResourceURL ); |
- Description
- retrieves the current floating state of a window based user interface element.
- Parameter ResourceURL
- specifies for which user interface element the floating state should be retrieved. A resource URL must meet
the following syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- true if the user interface element is floating, otherwise false.
|
|
isElementDocked
| boolean |
| isElementDocked( |
[in] string |
ResourceURL ); |
- Description
- retrieves the current docking state of a window based user interface element.
- Parameter ResourceURL
- specifies for which user interface element the docking state should be retrieved. A resource URL must meet
the following syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- true if the user interface element is docked, otherwise false.
|
|
isElementLocked
| boolean |
| isElementLocked( |
[in] string |
ResourceURL ); |
- Description
- retrieves the current lock state of a window based user interface element.
- Parameter ResourceURL
- specifies for which user interface element the lock state should be retrieved. A resource URL must meet
the following syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- true if the user interface element is locked, otherwise false.
|
|
getElementSize
| ::com::sun::star::awt::Size |
| getElementSize( |
[in] string |
ResourceURL ); |
- Description
- retrieves the current size of a window based user interface element.
- Parameter ResourceURL
- specifies for which user interface element the current size should be retrieved. A resource URL must meet
the following syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- the size in pixel of the user interface element. A non-window based user interface element provides a zero size.
|
|
getElementPos
| ::com::sun::star::awt::Point |
| getElementPos( |
[in] string |
ResourceURL ); |
- Description
- retrieves the current pixel position of a window based user interface element.
- Parameter ResourceURL
- specifies for which user interface element the current position should be retrieved. A resource URL must meet
the following syntax: "private:resource/$type/$name". It is only allowed to use ascii characters for type and
name.
- Returns
- the size in pixel of the user interface element. A non-window based user interface element provides a zero size.
|
|
lock
- Description
- prohibit all layout updates until unlock is called again.
This call can be used to speed up the creation process of serveral user interface elements. Otherwise the layout manager
would calculate the layout for every creation.
|
|
unlock
- Description
- permit layout updates again.
This function should be called to permit layout updates. The layout manager starts to calculate the new layout after
this call.
|
|
doLayout
- Description
- forces a complete new layouting of all user interface elements.
|
|
setVisible
| void |
| setVisible( |
[in] boolean |
Visible ); |
- Description
- sets the layout manager to invisible state and hides all user interface elements.
A layout manager can be set to invisible state to force it to hide all of its
user interface elements. If another component wants to use the window for its
own user interface elements it can use this function. This function is normally
used to implement inplace editing.
- Parameter Visible
- provide false to make layout manager invisible otherwise this must be
set to true.
|
|
isVisible
- Description
- retrieves the visibility state of a layout manager.
A layout manager can be set to invisible state to force it to hide all of its
user interface elements. If another component wants to use the window for its
own user interface elements it can use this function. This function is normally
used to implement inplace editing.
|
|
Copyright © 2013, The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.


All Classes
DataSource
Foo
Foo2
FsmGrailsPlugin
FsmMultipleActions
FsmMultipleActionsTests
FsmSupport
FsmSupportDummy
FsmSupportException
FsmSupportIntegrationTests
FsmSupportUnitTests
Grammar
UrlMappings
_Install
_Uninstall
_Upgrade


The build hierarchy
Build graph
Depending on the contents of the Project.meta files, a build graph will be generated.
- An ExecutableConfig usally specifies files to compile, dependencies to other projects and linker stuff.
- A LibraryConfig usally specifies files to compile and archive.
- A CustomConfig usually defines a custom step.
Every config type can be equipped with pre and post steps like shell commands or makefiles.
All these steps will be combined to a build graph.
Example
The main project has dependencies to the projects A, B and C:
Steps are executed bottom-up. If one step fails, all steps above won't be executed.
If e.g.
- PreStepMain 2 fails
- at least one file of library B does not compile
then
- library B will not be created
- files of the main project will not be compiled
- main project will not be linked
- post step of main project will not be executed


"Grandpa" by Shelbie Smithson - Flagstaff High School
"Halfpipe" by Jaden Williams - Flagstaff High School
"Cold Ice" by Bryce Fennel - Flagstaff High School
"Dandelion" by Hutton Hagerman - Flagstaff High School
"Bees are Dying at an Alarming Rate" by Chris Contreras - Flagstaff High School
"Reach" by Hannah Hanson - Flagstaff High School
"Portrait" by Isleny Ortega - Coconino High School
"Miss Angela" by Luke Paget - Flagstaff High School
"Ophelia's Afternoon Ride" by Lauren Pacheco - Northland Preparatory Academy
"A Bloom" by James Linskey - Flagstaff Arts and Leadership Academy
"The Sun is There" by Nathan Duran - Flagstaff High School
"Droplets" by Dawson Peters - Flagstaff High School
"The Moon" by Bailey Larson - Flagstaff High School
"Northern Arizona Stars" by Dell Carlsen - Flagstaff High School
"Olivia" by Elsa Jacobson - Flagstaff High School
"Rage" by Veronica Miller - Flagstaff High School
"Drowning in Pink" by Lexi Monke - Coconino High School
"Nature" by Izabel Cordova - Coconino High School
"Light" by Grace Morris - Coconino High School
"Perfect Imperfections" by Tiffany Kwan - Flagstaff High School
"Aleona" by Marina Aukon-Page - Basis
"Going Insane" by Aryn Begay - Flagstaff High School
"The Crane" by Ben Shanahan - Flagstaff High School
"As you Are" by Jovani Rodrigues - Flagstaff High School
"Big Bend Woman" by Zoe Sawyers - Flagstaff High School
"Element Flows" by Theresa Palacios - Flagstaff High School
"Adelaide" by Lydia Miller - Flagstaff High School


Reports method calls that can be replaced with operator invocations.
Example:
a.plus(b)
After the quick-fix is applied:
a + b


Setting up Rails Apps with Passenger and Apache in CentOS, Ruby, Rails, Apache
Difficulty: 2
Time: 30 minutes
This article guides you on how to deploy Rails Apps with Passenger and Apache in CentOS. You'll need at least one GB of RAM in a virtual server to run the Passenger commands that consume a lot of memory. This article assumes that the user has sudo privileges to access the virtual server.
This guide includes development library installation and ad hoc compilation on the machine, hence it is not recommended to use this tutorial in a production environment.
To setup your Arch Linux server, refer to the article: Initial Server Setup - CentOS. You need to ensure that the fully qualified domain name (FQDN) points to the server. After you have set up the Arch Linux server, you will need to install Ruby on Rails using RVM - CentOS. You may also refer to the article: Deploy Rails Apps with Passenger and NGINX - CentOS.
passenger.conf
file.
LoadModule passenger_module /home/newUser/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/buildout/apache2/mod_passenger.so PassengerRoot /home/newUser/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10 PassengerDefaultRuby /home/newUser/.rvm/wrappers/ruby-2.0.0-p247/ruby
Gemfile
using the following command:
<VirtualHost *:80> ServerName www.mydomain.com //your server name DocumentRoot /var/www/html/HelloWorld/public //your rail application path <Directory /var/www/html/HelloWorld/public > AllowOverride all Options -MultiViews </Directory> </VirtualHost>
In this article, we reviewed the steps involved in setting up your Rails app with Passenger and Apache, in order to make it more secure and reliable in Fedora distribution.


Homework 1
Top 10 most populated cities in the United States
New York City
Los Angeles
Chicago
Houston
Phoenix
Philadelphia
San Antonio
San Diego
Dallas
San Jose
Learn more details about these cities
here
.
Change user


| DOSE: T+ 0:00 |
1 capsl |
oral |
2C-I |
| T+ 2:00 |
1 capsl |
oral |
2C-I |
| T+ 0:00 |
repeated |
smoked |
Cannabis |
My evening started rather simply just smoking some pot and hanging around my house with my roommate. There had been some rumors of a drug flying around our little mountain town which is very accustomed to psychedelics, but I had not gotten the chance to grab any of it. Shortly thereafter my friend, we'll call him G, gave me a call and said that he had gotten some of this mystery drug and wanted to know if we were interested in it. As someone that deeply enjoys psychoactive substances, I couldn't resist.
I drove over to his dorm room and grabbed 6 little blue and white gelcaps. during the conversation we had he told me he only took one of the pills and had an incredible time. I respected his opinion as we had taken tons and tons of acid together and I knew the kid knew what a good trip was. On my way out of his room, it occurred to me I had no idea what I was about to take, so I asked him and he told me it was 2c-i. I initially thought he had been mistaken, as I have heard about 2c-b, but never this. He told me it was another analoug and that I was sure to have a good time. But I took his word for it and went on my merry way home.
By the time I got home my third roommate had arrived and there was a little bit of a crowd hanging around the kitchen counter toking and getting ready to take some ecstasy. I walked in the kitchen and handed a pill to each of my roommates a told them they should take it. They asked me what it was and I told them that G said it was 2c-i. One of the kids around the kitchen counter told me he knew some people that had tried it and had a wild time.
Apparently nobody saw me do this because ten minutes later my roommates, S and J, asked me if we should do this. I told them I already had and they should hop on the fun train. They each took their pill around 8 o'clock and we all sat around and got high waiting for the trip to come in. About 9:30 I still felt barely any effects and I specifically remember thinking 'If this is the trip, then I'm gunna be pissed.' I wandered into the kitchen and me and S decided to crack open one of the pills and see what it looks like.
We busted a pill and poured its contents onto a black tray we routinely used for cocaine. We looked at what looked like many hcl salts and figured that it could be anything and maybe just some shit laced with the smallest amount of lsd. We went on the internet and looked up a picture, and it looked pretty much the same. S's mom works for a hospital so he emailed her asking what this stuff was. She called him only minutes later and told him to be careful, that drugs were dangerous, and as far as she could see it looked like it was a substance similar to really good lsd. We wandered back to the kitchen and I decided that since it wasn't kicking in I would take the pill we broke oen and parachute it. I piled the powder onto a small piece of toilet paper, folded it and it was down the hatch before anyone could tell me it may have not been a good idea. My roommates followed my que and did the same.
Less than ten minutes later I was tripping balls. It didn't seem like there was a long come up, it just felt instantaneous. I was sitting on a couch and the next thing I knew I was hugging the arm of the couch thinking that if I went anywhere or let go I would start tripping harder than I already was. Slowy but sure, even though I think I was coming up even more I began to feel more and more secure with my new state of inebriation. It was one of those situations like the first time you trip and everything seems so intense and different than you imagined it.
I was just looking around getting the most intense visuals. Everything had a greenish red halo around it and looked very cartoony. It was all sort of a combination of lsd and mushrooms and ecstasy, but nothing like combining those together. Its kind of hard to explain. At the same time I was so wide awake, much more so than an average trip, so it kind of had an amphetamine twinge to it. We spent the whole night in and around my house, seeing as it was about -15 degrees out.
We started the night by watching a movie. Happy Feet. I had never seen the movie and I had the toughest time telling if it was reality or cartoon. All the while I would get distracted from the movie and go do something else. I went into the spare bedroom in the house that had been temporarily converted into an office and looked up some information about this drug. I didn't get very far because there was nothing on the walls except paint and one little calender, so the room felt huge and pulsating and I really could't take it anymore. I decided I was going to go take a shower and try to warm up, but when I went into the bathroom I just looked at the faucet and couldn't really remember how to work it. I gave up and deicided to go get some food. At that point I still felt very cold so I put some clothes in the dryer and sat in the laundry room eating popcorn.
I came out of the bathroom and decided I was going to smoke a bowl the hopes it might relax me a bit. Wrong and excellent move at the same time. It intensified my trip so much, but at the same time almost too much. The first brief moment after smoking kind of flung me into a bad trip. I smoked a cigarette and as I was putting the cigarette out in an ashtray it began to morph and grow and start to consume my arm. The ashtray was eating me! I pulled my arm back and scurried across the room. My roommates laughed at me and then I started to see the humor in the situation, it was kind of funny.
By this time J had turned on Tokyo Drift and we all actually felt like we were asians driving cars really fast in Tokyo, it was crazy. J started flipping through the channels, and at the time we had Showtime and HBO and all those fancy channels. So while he skipped from movie to movie he landed on the Grudge. The scenery was dark and music was daunting. We all instantly began screaming.   Thats when I saw my gloves and decided I needed to go outside.
I dressed myself to the point that I could have survived an arctic expedition and walked out into the living room. S and J instantly got the idea and went to do the same. Because we were already cold because of the drug, it seemed absolutely brutal. We stood in the garage door and pressed the button to open it. It slowly lifted the door and light spilled into the driveway. For some reason this did not seem weird to us, smoking outside at 3 o'clock in the morning, talking extraordinarily loud. About halfway through the cigarettes, S looked over at the college, which you could see the roof of from our house and his jaw dropped. He just stared and pointed and then dropped his cigarette and ran inside. J and I exchanged quizzical looks and followed.
When we got back inside I found him poking his head out the back door towards the school. He told me he had seen the school lift off the ground and aliens crawl towrds our house. I told him it was jsut a hallucination and he said the he know, he just didn't want to stick around to find out that it might not be. Logical I guess.
From there the trip just seemed to take o the persona of childhood bliss. I had never felt so happy and carefree. It just seemed like all of my problems were so insignificant and that I was blowing everything way out of proportion. It was then that I was just laying on a couch thinking when S's cat, Blaze came up to me and i think he may have just yawned, but whatever was going on in my mind made it seem as thiough he was singing the lyrics to the music that we were listening to.
From there we just kind of talked, played with S's cats and smoked some more bud. We played some music and left cartoons on the t.v. on mute and the voices seemed to sync up with the movements of mickey mouse and so forth. We just hung out and started to feel ourselves come down and watched the sunrise.  We talked about how much fun we had and how interestingly enough that was one of our hardest trips, even though we had all done 10 or more hits of acid on multiple occasions. It was truly crazy.
I found out later that the person G had gotten the 2c-i from had not really known what he was doing. He had dosed the pills out with between 40 and 50 mgs of 2c-i per pill. Even though 35mg was plenty for maximum effects. But in any case I had a great time and while two pills was intense, I will definately take this drug more if it is around.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Lisp is an interesting language. Its emphasis on functional programming and properties such as homoiconicity make it quite different from other languages. Although it’s not suited for all developers, those who have experienced building large applications in other languages may appreciate the simplicity that Lisp provides.
When I ask other developers for their thoughts on Lisp, the most common response I receive is, “Why are there so many brackets?” As it turns out, Lisp’s brackets establish some consistency across the language that allows for some neat code-writing tricks. So neat, in fact, that they can make coding a Zen-like experience. Read these tips and you’ll soon be able to make onlookers wonder how you’re able to make code fly around the screen so quickly and elegantly–and with just a few keystrokes.
Lisp Refresher
For those of you who aren’t quite clear on Lisp syntax, here are a few basic things to know:
- Everything is a list
- The first element in every list is the “function call position”
That’s it! Easy, right? Let me show you a few examples written in Clojure (a dialect of Lisp) to make things more concrete. First, a standard “Hello World” example:
(println "Hello World")
In Clojure, you create lists by using rounded parentheses. The first element in this list is println,
so we are calling a function called println
with a single argument “Hello World”.
Next, we create a new function called inc
:
(defn inc
"Define a fn that increments a number by 1"
[x] (+ x 1))
The first element (the one in function-call position) calls a special function called defn
that allows us to create a new function. The other arguments are:
- The name of the function we want to define–in this case,
inc
- A string comment that we can use as a human-readable description of what our function does
[x]
is a vector of the arguments that our new function will receive
- The body of our function
In this final example, we create a try-catch statement:
(try
(/ 1 0)
(catch ArithmeticException e (println "Kaboom!"))
(finally (println "We’ve recovered!")))
We can start to see from this example how lists can be nested to provide richer programming capabilities. This nesting actually results in a tree structure (which in compilers is referred to as an ‘abstract syntax tree’) that provides the basis for some interesting coding workflows.
The Structure of Lisp
To illustrate what this abstract syntax tree looks like, let’s draw the try-catch example as a tree:
I’ve omitted the “finally” block to keep the illustration compact, but it should be clear now how we can visualize Lisp code as a tree. The workflow tips in this article revolve around making edits to this tree: navigating to parent nodes, moving a branch, removing levels, etc.
***I’ll provide these tips specifically for Vim, but there are equivalents in Emacs as well if you prefer that.***
Without further ado!
Tip #1: Give your brackets some color
‘Rainbow Parentheses’ is a plugin for text editors that will change the color of your brackets depending on their depth in a list. This enables you to visually recognize the start and close of a particular list. Once we can visualize this, it becomes much easier to jump between depth levels.
In the above gif, the cursor starts inside the println
then makes jumps upward to each parent node in the tree (println
-> catch
-> try
). These jumps can be performed with the ParEdit plugin while in normal mode by pressing "("
.
Tip #2: Keep your parens balanced
There’s nothing worse in Lisp than having unbalanced parentheses–especially if you have blocks of code that include several levels of nesting. Finding which block is missing a closing bracket can become a nightmare. Fortunately, ParEdit can prevent us from having this problem.
Say we have a try-catch-finally block and wish to delete the ‘finally’ clause. In Vim, we can easily remove this entire line when in normal mode by pressing ‘dd’. The problem is that if we do this, we will make our parentheses unbalanced by deleting the closing bracket of the try
block (in the above gif, the closing red bracket).
The ParEdit plugin solves this by forcing our brackets to always remain balanced. With paredit enabled we can perform ‘dd’ to delete the line and delete everything except for any brackets necessary to maintain balance.
Tip #3: Learn motions. Master the brackets!
Vim provides motions right out of the box, with no additional plugins needed. The handiest motions for dealing with parentheses are “select in” and “select all.” These can perform actions on an entire list in just a few keystrokes. For example, say in our try-catch block we want to return positive infinity instead of print a message. Place the cursor inside the println
list, issue a “select all,” and hit “c” for “change.” This will replace the entire println
list in just three keystrokes.
Note that “select in” will select everything inside the parentheses, while “select all” will select everything inside the parentheses (including the parentheses themselves). This command will work with round brackets, curly brackets, square brackets and even quotations, making it useful in other non-Lisp languages as well.
Here’s a cheat sheet for using these commands:
- viw - select in word
- vi( - select in round bracket
- vi{ - select in curly bracket
- vi[ - select in square bracket
- vi” - select in quote
- ciw - change in word
- ci( - change in round bracket
- ci{ - change in curly bracket
- ci[ - change in square bracket
- ci” - change in quote
- va( - select all round bracket
- va{ - select all curly bracket
- va[ - select all square bracket
- va” - select all quote
- ca( - change all round bracket
- ca{ - change all curly bracket
- ca[ - change all square bracket
- ca” - change all quote
Tip #4: Nest with ease!
Say we want to assign the result of our try-catch statement to a variable name. This can be done in four easy steps:
-
Place your cursor on either the opening or closing bracket of the try block (one of the red brackets)
-
Hit “v%” to select everything up to and including the matching bracket
-
Using the ParEdit plugin hit <Leader>w( to wrap the select text in another set of parentheses
-
Inside the new parentheses, write the code to make the assignment
-
(Optional) In the gif I have done an optional fifth step to re-indent the code by selecting the block and pressing the equal sign. “=” is a standard Vim command to re-indent.
Tip #5: Barf and Slurp!
Barfing and slurping are terms used in the ParEdit plugin. These operations depend on the location of your cursor. Barfing will eject (“barf”) either the first or last element of the list where your cursor is placed. Slurping is the opposite: A slurp will find the first element to either the left or right of the list where your cursor is and slurp that element into the list.
In our try-catch example, say we create a new function called my-function
. We then want to move the try-catch block inside this function so that we can call it later. Naively, we could select the try-catch block, then cut and paste it into the function body. Alternatively, in two keystrokes we can slurp the entire try-catch block into the function body! We can perform the opposite operation by then barfing the try-catch back out.
The concept might take a few minutes to sink in, but once you understand these operations you will be able to push code around like a pro.
Vim Plugins
Here are links for the vim plugins I used in the above demos:
(Lambda bird formation photo by Sigfrid Lundberg)


EBD - Easton Bible DIctionary
Nethaniah
NETHANIAH
"NETHANIAH "given of Jehovah. (1.) One of Asaph’s sons, appointed by David to minister in the temple (
1 Chronicles 25:2, 12
).
(2.) A Levite sent by Jehoshaphat to teach the law (
2 Chronicles 17:8
).
(3.)
Jeremiah 36:14
.
(4.)
2 Kings 25:23, 25
.
"NETHANIAH "given of Jehovah. (1.) One of Asaph’s sons, appointed by David to minister in the temple (1 Chronicles 25:2, 12).
(2.) A Levite sent by Jehoshaphat to teach the law (2 Chronicles 17:8).
(3.) Jeremiah 36:14.
(4.) 2 Kings 25:23, 25.


We know you have your taste and preference therefore we make sure you desicde on which ingredients to use and also you descide on which nutritional
herb to be used. This we believe make you feel like you did the smmothie yourselfe.
Nissie Smoothie understand how we strive to maintain our weight or add weight and also how we love to maintain a healthy life style,,
for this reason we have your need in mind to make sure every step we take goes a long way for you to achieve your aim of coming to us
We are giving you a customise and uniqe smoothie at an unbelievable prize you wouldnt get any where and we mean it.
With our state of the heart resturant your safety is assured and also with your delivery we make sure whiles we track the rider you are also able
to
We are into smoothie making,salads,sanwich,wraps and burgers
With our organic fruits and vegetable you are assured of a healthy and sumpcious smoothie ever which is made to meet your basic need of coming to us.
learn more...Preparing salads at home is a bit tidious but dont worry Nissis Smoothie has got you covered because we there for you.
learn more...Our delicious and healthy wraps just speaks for itselfe so better is little said about it
learn more...We know you love your burgers to the must therefore we keep suprising you with different types flavous just to make you happy
Learn more...We recently took part in a family day out games organise by Citi fm at aviation social center and we must confess it worth the partispation.Patronage was overwelming that we run out of stock but you know us we quickly restock to continue the party.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
A99 Adam Street
Texas, TX 555072
<EMAIL_ADDRESS>+41 5787 2323


Traveller (Reviewed on Nov. 7/98)
Starring Bill Paxton, Mark Wahlberg, Julianna Margulies
There's something about watching con men at work that never fails to fascinate me. Likely, it's because I know that I would never be able to pull off a con, no matter how small. I just don't have what it takes to look a man straight in the eyes and lie to him. Many of the characters in "Traveller" have the ability to do that, and much more.
The movie stars Bill Paxton as a con man at the top of his game, and Mark Wahlberg as his young protoge.  His "people" are gypsies, who rely on con men like Paxton to keep the money flowing in. The movie starts off predictably with Paxton showing Wahlberg the ropes, but then veers off into totally unexpected territory.
"Traveller" is an odd movie in that you never quite know what it's going to do next. For a while, you think it's a movie along the lines of "The Sting", with the older man showing the naive kid the ropes. But then it becomes something different, and I think that's what I liked most about the film. Too many films today have predictable outcomes, and a five year old can usually guess at how the movie's going to end. "Traveller" never quite settles into a niche, and I was happy to be watching a film that I couldn't quite put my finger on.
The performances are first rate, with Paxton redeeming himself for "Twister". At the outset of the film, we're not too sure if we like him. He's taking advantage of innocent people and generally acting like a bad-ass. But as the movie progresses, and as he falls in love with the Julianna Margules character, we start to see a different side to him emerge. And to me, this is the sign of a good actor. Someone who can make you think one thing, but later on, force you to re-evaluate what you originally thought. Wahlberg is good, too, as a natural-born grifter.
"Traveller" is the type of movie that, after you watch it, you will likely be suspecting everyone around you of ripping you off for the next week.  Well, what would have happened? Probably, we all would have been playing samba somewhere." -Billy Corgan
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


var dismissOnSelect: Boolean
Whether to dismiss the popup once an item gets selected. Defaults to true.
true


My name is Vere. It's like Beer, but with a "V". I grew up In South Africa to a Zimbabwean mum and kiwi Dad. I have worked as a writer and actor full-time for the last half decade and have really enjoyed it but would like to also start a career in software developement for a bit more stability and because the field looks extremely interesting. I love Horror films and all sorts of books (Charles Bukowski and Stephen King are a few of my favourites), and am a terrible surfer.


The Fashion influential community
with positive vibes
Fashion influencers and Brands meet each other to release their own potential.
We create synergies in the Fashion and Lifestyle sector
Le reviews online aumentano
le vendite del 210%
L’influencer marketing è considerato
più efficace dall’80% dalla popolazione rispetto al paid advertising
L’influencer marketing crescerà
del 50% quest'anno
The users of Square
A Gamified Approach allows our members to support our partners while having fun!
Our community is made by groups of models
who know each other and decide spontaneously which brands
to embrace fostering their social media awareness.
That’s why we select which brands to work with.
Our approach is against with the approach of making up
an influencer brand relation just built on money.
We instead operate in a gamified framework and invite
Brands to play with us
We organize real testing of the products and give out real
and sincere reviews from the customer that have an important
impact on e-commerce platforms
With our dense community we are the only ones that
can manage long run campaigns spread through
a vast amount of time.
Brands
Square is supporting models through their life abroad


Infers a topology of relationships between different datasets, such as multi-omics and phenotypic data recorded on the same samples. We based this methodology on the RV coefficient (Robert & Escoufier, 1976, <doi:10.2307/2347233>), a measure of matrix correlation, which we have extended for partial matrix correlations and binary data (Aben et al., 2018, <doi:10.1101/293993>).
| Version: | 1.0.2 |
| Imports: | Matrix, corpcor |
| Suggests: | knitr, rmarkdown, NMF, pcalg, Rgraphviz |
| Published: | 2018-06-13 |
| Author: | Nanne Aben |
| Maintainer: | Nanne Aben <nanne.aben at gmail.com> |
| License: | GPL-2 |
| NeedsCompilation: | no |
| Materials: | NEWS |
| CRAN checks: | iTOP results |
| Reference manual: | iTOP.pdf |
| Vignettes: |
A quick introduction to iTOP |
| Package source: | iTOP_1.0.2.tar.gz |
| Windows binaries: | r-devel: iTOP_1.0.2.zip, r-release: iTOP_1.0.2.zip, r-oldrel: iTOP_1.0.2.zip |
| OS X binaries: | r-release: iTOP_1.0.2.tgz, r-oldrel: iTOP_1.0.2.tgz |
| Old sources: | iTOP archive |
Please use the canonical form https://CRAN.R-project.org/package=iTOP to link to this page.


System Architect Picture "Subject Identifier State Change"
Parent Diagram:
State Change Activity
(UML Class)


{% extends "dashboard/_dashboard.html" %} {% load static %} {% block main %}
What you can do
Upload your service description file
Select security enrichments according to your SLA
Deploy your secured service with supported service orchestrators
Monitoring, alerting, trending (MAT), analytics of your secured services


Send
Speaking as:
User
To:
User / Group
New user register:
Register User
New group register:
Register Group
Messages:


{{eligibilityCtrl.currentState.questionText}}
"Ineligible felony" means any felony other than a failure to appear (§ 16-1327) [§ 23‑1327].
{{ misd.legal_description }}
{{text}}
{{eligibilityCtrl.currentState.helperText}}
{{record.answer}}


class Hello def say puts 'cheers' end end
puts "This should not get lumped into the above line Example"
A paragraph should go here.
echo "Hello"
And this is a paragraph


Loading...
Sign Out
Delete account
Fill up the details
Name
Email
Phone Number
Password
Confirm Password
Sign Up
Exsisting Customer?
Login


| PostgreSQL 9.0.10 Documentation | ||||
|---|---|---|---|---|
| Prev | Up | Chapter 5. Data Definition | Next |
When you create complex database structures involving many tables with foreign key constraints, views, triggers, functions, etc. you implicitly create a net of dependencies between the objects. For instance, a table with a foreign key constraint depends on the table it references.
To ensure the integrity of the entire database structure, PostgreSQL makes sure that you cannot drop objects that other objects still depend on. For example, attempting to drop the products table we had considered in Section 5.3.5, with the orders table depending on it, would result in an error message such as this:
DROP TABLE products; NOTICE: constraint orders_product_no_fkey on table orders depends on table products ERROR: cannot drop table products because other objects depend on it HINT: Use DROP ... CASCADE to drop the dependent objects too.
The error message contains a useful hint: if you do not want to bother deleting all the dependent objects individually, you can run:
DROP TABLE products CASCADE;
and all the dependent objects will be removed. In this case, it doesn't remove the orders table, it only removes the foreign key constraint. (If you want to check what DROP ... CASCADE will do, run DROP without CASCADE and read the NOTICE messages.)
All drop commands in PostgreSQL support specifying CASCADE. Of course, the nature of the possible dependencies varies with the type of the object. You can also write RESTRICT instead of CASCADE to get the default behavior, which is to prevent the dropping of objects that other objects depend on.
Note: According to the SQL standard, specifying either RESTRICT or CASCADE is required. No database system actually enforces that rule, but whether the default behavior is RESTRICT or CASCADE varies across systems.
Note: Foreign key constraint dependencies and serial column dependencies from PostgreSQL versions prior to 7.3 are not maintained or created during the upgrade process. All other dependency types will be properly created during an upgrade from a pre-7.3 database.


Welcome to
MyMedicine App
Join millions of people how are using this App to help them to set a reminder for Medication
Copyright © 2021 MyMedicine. All Rights Reserved.
Join millions of people how are using this App to help them to set a reminder for Medication
Copyright © 2021 MyMedicine. All Rights Reserved.


{% from "macros/nav_macros.html" import nav_link with context %} {% from "macros/nav_macros.html" import dropdown_nav with context %} {% from "macros/nav_macros.html" import nav_logo with context %} {% from "macros/nav_macros.html" import dropdown_item with context %}
{% block head %}


--- layout: default --- {% comment %} This is a partial restyling. Still to-do: - DocsIta integration - Forum integration - New timeline {% endcomment %} {% include setlang.html %}
{{page.description}}


--- layout: default --- {{ content }} My Areas of Expertise: {% for skill in site.skills %} {{ skill.title }} {{ skill.description }} {{ skill.output }} {% endfor %}


I would go after the companies that have the most sales volume because it shows that they are will have consumers and lots of them. With a larger population then you have a greater chance of people needing your services.


Simple Recipe
content_copy
Ingredients
Instructions
Sorry about that!
We were unable to find any recipes on this page.
Close


Reports any array fields or variables whose contents are read but not written,
or written but not read. Such mismatched reads and writes are pointless, and probably indicate
dead, incomplete or erroneous code.
Sample of the code that will be reported:
final int[] bar = new int[3];
bar[2] = 3;


We're sorry but dnd-druid-worksheet doesn't work properly without JavaScript enabled. Please enable it to continue.


Time-Series-Transform
1.1.2
Time Series Transformer
Introduction
Time_Series_Transformer
Stock_Transformer
time_series_transform API documentation
Gallery
Basic Useage
Time Series Transformer
Introduction
Time_Series_Transformer
Stock_Transformer
Time Series Data Plot
Stock Analysis
Machine Learning
Deep Learning
Stock Extraction
Time-Series-Transform
»
Gallery
View page source
Gallery
¶
Basic Useage
¶
Contents:
Time Series Transformer
Introduction
Time_Series_Transformer
Pre-made functions
Custom Functions
Data with Category
pandas
numpy
Stock_Transformer
create technical indicator
Time Series Data Plot
Introduction
Time_Series_Plot
Stock Plot
Stock Analysis
¶
Contents:
Machine Learning
Data Prep
Deep Learning
Stock Extraction
Stock Transformer


The problem Reddit is trying to solve is how to present to you, in the best way possible, the "hottest" submissions. Basically, there is a limited amount of space on the screen, and a since it is the "hottest" designation, where time is a factor, Reddit is trying to present as much relevant submissions, ranked in a fashion that would be interesting to you. I think it does a fair job of doing so, especially with the images.
This page is pretty simple- basically trying to get the user to search ASAP without any distractions. Once they get a basic search going and see what kind of results there are, thats when they can start throwing their results / advertising at you.
Amazon's main page is trying to basically do three things; show it's main categories of shopping (left); show you any great deals relevant possibly to the date (father's day); and to also offer some recommendations based on your browsing history. The middle is a combination of everything, as well as a search bar.


Whispering Pines School student arrested after pushing teacher
by Cristina AlexanderMIRAMAR, FLA. (WSVN) - A 19-year-old high school student in Miramar has been arrested for allegedly pushing his teacher.
The incident occurred at Whispering Pines School located at 3609 South Douglas Road, Tuesday.
According to police, Eric Herr was having difficulties in the classroom and became disruptive.
As the teacher attempted to calm Herr down, police said, Herr threw a chair and walked out of the classroom.
Detectives said after the victim called the other staff members for help, Herr returned to the classroom and forcefully pushed him twice, causing him to hit the wall.
Additional staff intervened and restrained Herr,
Herr was arrested and charged with battery on a public/private education employee.
He’s being held on a $7,500 bond.


[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[W]
[X]
[Y]
[Z]
Table class (HTMLgen)
tables on web pages adding
laying out forms
tags
2nd
Tcl language
Tcl/Tk on Windows
Python and
TCP (Transmission Control Protocol)
socket module
TCP objects
TCP/IP
socket module
Telnet
telnetlib module
templates
testing assert statement in v1.5
GuiMaker class
mixin methods
sequence permutations
set classes
set functions
text editing
editors, program
files distinguishing from binary
uploading
processing
parser generators
rule strings
summing columns
utilities
zz
[See also regular expressions][See also regular expressions] ScrolledText class
widgets
this instance pointer (C++)
thread module
global objects, synchronizing access to
thread exits, waiting for
threading module
threads
2nd
email transfers and
exiting, waiting for
global interpreter lock and
global objects, synchronizing access to
GUIs and
support for
threading servers
time-slicing
[See multiplexing servers] time.sleep() client requests
servers, multiplexing
time.strftime()
time/date formatting
timer module
2nd
Tk library
Tkinter animation techniques
canvas widgets
checkbuttons
adding to HTML forms
configuring
dialogs
Entry widget
Message widget
variables and
windows, top-level
Grail and
graphics
grids
listboxes
menus
2nd
GuiMaker class
object viewers
persistent
radiobuttons
adding to HTML forms
configuring
dialogs
Entry widget
Message widget
variables and
windows, top-level
scrollbars
sliders
variables and
text
editing
toolbars
GuiMaker class
Tkinter module
__tkinter module
Tkinter module
documentation for
email client
browser as
deleting mail
forwarding mail
implementing
loading mail
replying to mail
saving mail
sending mail
threading
viewing mail
FTP client frontend
PMW
Windows
toolbars
GuiMaker class
Toplevel object
translating conversion codes
Tcl/Tk to Python/Tkinter
Transmission Control Protocol
[See TCP] Trigger__Event()
try/finally statements mailboxes, unlocking
shelves, mutual exclusion for
|


Click Here To Continue
access_time
Easy Return
border_color
Highlighting & Notes Ok
https
100% Secure


Thank you for visiting my web-page. Here is a list of my project information. Please feel free to reach out on my Contacts page.


Comments
-
Greg Hurrell
(In reply to comment #0)
Feature request: When you are playing a track ichat will show what you specify in the synergy advanced preferences. But when you are paused or stopped instead of displaying "Paused: Track - Artist" it simply shows you as "Available" or "Paused" without showing the track name.
Are you sure about that? I just double-checked here and it definitely shows the track name when paused or stopped.
Having the player status is great... something I love about Synergy Advanced, but the word "Playing" itself seems redundant and takes up text room in your status if the track name is already showing.
You can turn the display of the player status on and off in the Instant Messaging preferences.
Just something extra I'd love to see in the future! Thanks for Synergy, I'm a proud owner of both classic and advanced!
Glad to hear that you like them!
Can you confirm that the preferences are working for you? Given that the preferences already seem to permit what you've asking for, I've reworded your summary a bit to broaden the request. Have made it "Separate control over iChat status when playing, paused, stopped etc", which is about as far as I think I can go in terms of making this customizable for the user.
-
Greg Hurrell
Ok, this is now implemented in the development version but still needs to be tested prior to release. Adding the "test" keyword.
Add a comment
Comments are now closed for this issue.


Falling Leaves
问题描述 :
Figure 1
Figure 1 shows a graphical representation of a binary tree of letters. People familiar with binary trees can skip over the definitions of a binary tree of letters, leaves of a binary tree, and a binary search tree of letters, and go right to The problem.
A binary tree of letters may be one of two things:
- It may be empty.
- It may have a root node. A node has a letter as data and refers to a left and a right subtree. The left and right subtrees are also binary trees of letters.
In the graphical representation of a binary tree of letters:
- Empty trees are omitted completely.
- Each node is indicated by
- Its letter data,
- A line segment down to the left to the left subtree, if the left subtree is nonempty,
- A line segment down to the right to the right subtree, if the right subtree is nonempty.
- Its letter data,
A leaf in a binary tree is a node whose subtrees are both empty. In the example in Figure 1, this would be the five nodes with data B, D, H, P, and Y.
The preorder traversal of a tree of letters satisfies the defining properties:
- If the tree is empty, then the preorder traversal is empty.
- If the tree is not empty, then the preorder traversal consists of the following, in order
- The data from the root node,
- The preorder traversal of the root’s left subtree,
- The preorder traversal of the root’s right subtree.
- The data from the root node,
The preorder traversal of the tree in Figure 1 is KGCBDHQMPY.
A tree like the one in Figure 1 is also a binary search tree of letters. A binary search tree of letters is a binary tree of letters in which each node satisfies:
The root’s data comes later in the alphabet than all the data in the nodes in the left subtree.
The root’s data comes earlier in the alphabet than all the data in the nodes in the right subtree.
The problem:
Consider the following sequence of operations on a binary search tree of letters
Remove the leaves and list the data removed
Repeat this procedure until the tree is empty
Starting from the tree below on the left, we produce the sequence of trees shown, and then the empty tree
by removing the leaves with data
BDHPY
CM
GQ
K
Your problem is to start with such a sequence of lines of leaves from a binary search tree of letters and output the preorder traversal of the tree.
输入:
The lines contain the leaves removed from a binary search tree in the stages described above. The letters on a line will be listed in increasing alphabetical order. Data sets are separated by a line containing only an asterisk (‘*’).
The last data set is followed by a line containing only a dollar sign (‘$’). There are no blanks or empty lines in the input.
输出:
样例输入:
BDHPY CM GQ K * AC B $
样例输出:
KGCBDHQMPY BAC
解题代码:
//* @author: SmilingWang import java.util.*; public class Main { public static void main(String[] args){ Scanner in =new Scanner(System.in); BinarySearchTree< Character> bt = new BinarySearchTree< Character>(); boolean stop = false; while(true){ String input = in.next(); LinkedList< String> list = new LinkedList< String>(); while(input.charAt(0) != '*'){ if(input.charAt(0) == '$'){ stop = true; break; } list.addFirst(input); input = in.next(); } for(int i = 0; i < list.size(); i++){ input = list.get(i); for(int j = 0; j < input.length(); j++){ bt.insert((Character)input.charAt(j)); } } bt.printTree(); if(stop){ return; } System.out.println(); bt = new BinarySearchTree< Character>(); } } } class BinaryNode< T extends Comparable< ? super T>> { BinaryNode< T> left; BinaryNode< T> right; T element; public BinaryNode(T theElement){ this(theElement, null, null); } public BinaryNode(T theElement, BinaryNodelt, BinaryNode rt){ element = theElement; left = lt; right = rt; } public T getElement(){ return this.element; } public BinaryNode< T> getLeft(){ return this.left; } public BinaryNode< T> getRight(){ return this.right; } public String toString(){ return element + ""; } } class BinarySearchTree< T extends Comparable< ? super T>>{ private BinaryNode< T> root; public BinarySearchTree(){ root = null; } public BinarySearchTree(BinaryNode< T> t){ root = t; } public void makeEmpty(){ root = null; } public boolean isEmpty(){ return root == null; } public T find(T x){ return elementAt(find(x, root)); } public void insert(T x){ root = insert(x, root); } public void printTree(){ printTree(root); } private T elementAt(BinaryNode< T> t){ return t.element; } private BinaryNode< T> find(T x, BinaryNode< T> t){ if(t == null){ return null; } if(x.compareTo(t.element) < 0){ return find(x, t.left); } else if(x.compareTo(t.element) == 0){ return t; } else{ return find(x, t.right); } } private BinaryNode< T> insert(T x, BinaryNode< T> t){ if(t == null){ t = new BinaryNode< T>(x, null, null); } else if(x.compareTo(t.element) < 0){ t.left = insert(x, t.left); } else if(x.compareTo(t.element) > 0){ t.right = insert(x, t.right); } else; return t; } private void printTree(BinaryNode< T> t){ if(t != null){ System.out.print(t.element); printTree(t.left); printTree(t.right); } } }
分析的很专业！
终于明白了递归和dp的关系，多谢分享！
for(int i=1; i<=m; i++){
for(int j=1; j<=n; j++){
dp = dp [j-1] + 1;
if(s1.charAt(i-1) == s3.charAt(i+j-1))
dp = dp[i-1] + 1;
if(s2.charAt(j-1) == s3.charAt(i+j-1))
dp = Math.max(dp [j - 1] + 1, dp );
}
}
这里的代码似乎有点问题？ dp(i)(j) = dp(i)(j-1) + 1;这个例子System.out.println(ils.isInterleave("aa","dbbca", "aadbbcb"));返回的应该是false
刚开始学习，为啥会报错了，你试过了吗
不考虑最后将结果排序的话，快排的时间复杂度是O(N) ，而堆排的是O(N*logK)
1234百位上出现的次数应该是200吧。
图像处理那题解题报告在哪儿呢？
第二个方法挺不错。NewHead代表新的头节点，通过递归找到最后一个节点之后，就把这个节点赋给NewHead，然后一直返回返回，中途这个值是没有变化的，一边返回一边把相应的指针方向颠倒，最后结束时返回新的头节点到主函数。
…. 配图居然是没方向的。。
第一段代码中：
next = next ;
明显不对吧，应该是 next =j;才对
这是往年的笔试题，非在线，主要考察基础，Java会在面试时问到
对，还是这种实现比较好理解。虽然效率有点低


Cyber Physical System Vulnerability Calculator
Select values for all categories to generate a score
--
Attack Vector
Network
Adjacent Network
Local
Physical
Attack Complexity
Low
High
Privilege Required
None
Low
High
User Interaction
None
Required
Scope
Unchanged
Changed
Base
0.00
1.75
2.75


Please notify me if...
-
I speak 2 fast
-
I should repeat anything
-
I should explain something better
-
You have any questions
I will be talking mostly in Ruby on Rails framework context but the same applies to any other
In the end, all of it is just Ruby
What's wrong with Rails the way it is?
The way Rails is being taught
- You need Rails to program in Ruby
- The Rails way is the best way
- Fat models
- Slim controllers
- Models to rule it all
- It's supposed to be object oriented programming - so let's make models validate themselfs
- States, everywhere states
- It can happen even if you don't know about it (callbacks)
You need Rails to program in Ruby
# Gemfile
source 'https://rubygems.org'
gem 'rails', '5.0.1'
%w(
rails
active_model/railtie
active_job/railtie
active_record/railtie
action_controller/railtie
action_mailer/railtie
action_view/railtie
sprockets/railtie
).each { |lib| require lib }
# Yeah now I can program...
@some_object.try :test
The Rails way is the best way
- It's blazing fast at the beginning
- Easy to add new features
- Just test prototypes and it's production ready
The Rails way is NOT the best way
- Business loves not only features
- But also predictability
- Monolith by design
- A lot of magic
- Model level associations and relations
- Non-trivial business logic in models, controlers, views and (horrible!) callbacks
Fat models
Fat models
- "Great" for everything
- Validations
- Presentation
- Relations
- Persistance
- Scopes
- Translations
- Callbacks
- Triggers
SRP as fu*k
Fat controllers
Fat controllers
- "Great" for everything
- Validations
- Presentation
- Relations
- Persistance
- Scopes
- Translations
- Callbacks
- Triggers
- Data filtering
- Authentication
- Permissions and policies
SRP as fu*k
Models don't care about context (unless explicitly given)
- Hard to build multi non-related model form
- Magic behind AR triggers weird things
- "Let's build in a way that will remove everything with a user" automatically
States, everywhere states
if @model.valid?
else
if @model.errors[:xyz].present?
else
end
end
if @model.status == 'available'
else
end
Callbacks
What we can do about it?
- Stop using Rails and use something else (LOL)
What we can do about it?
- Introduce some other layers (policies, services, presenters, validators, uploaders, jobs, etc)
- and... bind most of them in the controller context
What we can REALLY do about it?
- Data, Context, and Interaction (DCI)
- CQRS
- Event sourcing
- DDD practices
- Railway-oriented programming
Where do we start from? Trailblazer
What is Trailblazer?
Trailblazer gives you a high-level architecture for web applications. It extends the basic MVC pattern with new abstractions. Rock-solid conventions that go far beyond database table naming or route paths let you focus on your application code, minimize bugs and improve the maintainability.
What do I know about Trailblazer?
- I've used every major (and sometimes minor) version of Trailblazer
- Even read Apotonicks book about it (heavily outdated novadays :D)
- Developed and maintained multiple apps with Trailblazer
- Had to patch things up from time to time to cover non-std cases
What do I know about Trailblazer?
class OrganizationsController < BaseController
def index
respond_with Organizations::Index.call(params)
end
def new
respond_with Organizations::New.call(params)
end
def create
respond_with Organizations::Create.call(params)
end
end
What Trailblazer is not
- Tool that will converts shitty programmers into Ruby magicians
- The new and only proper way to do Ruby apps
- Tool for junior developers (at least until they understand some concepts)
- Tool that has 100% accurate always up2date documentation
- Silver bullet to automatically refactor your apps
How does it work?
- Operation - A service object implementation with functional flow control.
- Contract - Form objects to validate incoming data
- Policy - To authorize code execution per user
- Representers - For serializing and parsing API documents.
How does it work?
How does it work?
Railway-oriented programming
The flow pipetree is a mix of the Either monad and Railway-oriented programming
Example - operation
class Create < ApplicationOperation
contract Contracts::Create
step Containers::Model::Build(Repository)
step Containers::Contract::Build()
step Containers::Contract::Validate(key: :repository)
step Containers::Contract::Persist()
failure Containers::Error::Raise()
end
Example - AM based contract
class Create < ApplicationContract
property :id
property :slug
property :setup_state
validates :id,
presence: true,
length: { is: 36 }
validates :slug,
presence: true
validates_uniqueness_of :id,
case_sensitive: false
validates_uniqueness_of :slug,
case_sensitive: false
end
What do I need to use it?
- A bit of patience
- A bit of DDD and CQRA understanding
- Understanding that code duplication can be good
- 100% code coverage
Downsides
- Composition over inheritance
- Often more code (but no coupling)
- Some WIP gems under the hood
- No invocation standardization
- Requires a good understanding of Ruby to do non-standard stuff
- Can be replaced (with a custom wrapper) with set of Dry-gems
Downsides
- I still prefer Dry-transactions DSL for endpoint handling
- Low code quality of Tralblazer itself
- No upgrade docs between major versions
- Trailblazer internal documentation understandable (if any) only by Apotonick


Make early booking for a place to sleep. The rooms are charged according to the season demands.
We also give discounts for early bookings
The resort has tents for hire for those who want to camp.
Please contact the manager and make further inquiries.


|
entity - entity handle
row - matrix row index column - matrix column index |
|
Returns the value of an element from within an entity's transformation matrix.
The transformation matrix is what is used by Blitz internally to position, scale and rotate entities. GetMatElement is intended for use by advanced users only. |
|
; GetMatElement Example
; --------------------- Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-5 light=CreateLight() RotateEntity light,90,0,0 ; Create sphere sphere=CreateSphere() ; Position, scale, rotate entity - try messing with these values to change GetMatElement value PositionEntity sphere,0,0,0 ScaleEntity sphere,1,2,3 RotateEntity sphere,0,0,0 While Not KeyDown(1) RenderWorld Text 0,0,GetMatElement#(sphere,1,1) Flip Wend End |


array_flip (PHP 4, PHP 5, PHP 7) array_flip — 交换数组中的键和值 说明 array array_flip ( array $trans ) array_flip() 返回一个反转后的 array，例如 trans 中的键名变成了值，而 trans 中的 值成了键名。 注意 trans 中的值需要能够作为合法的键名，例如需要是 integer 或者 string。如果值 的类型不对将发出一个警告，并且有问题的键／值对将不会反转。 如果同一个值出现了多次，则最后一个键名将作为它的值，所有其它的都丢失了。 参数 trans 要交换键/值对的数组。 返回值 成功时返回交换后的数组，如果失败返回 NULL。 范例 Example #1 array_flip() 例子 Example #2 array_flip() 例子：冲突 1, "b" => 1, "c" => 2); $trans = array_flip($trans); print_r($trans); ?> 现在 $trans 是： Array ( [1] => b [2] => c ) 参见 • array_values() - 返回数组中所有的值 • array_keys() - 返回数组中部分的或所有的键名 • array_reverse() - 返回一个单元顺序相反的数组 User Contributed Notes 14 notes =============================================================================== I find this function vey useful when you have a big array and you want to know if a given value is in the array. in_array in fact becomes quite slow in such a case, but you can flip the big array and then use isset to obtain the same result in a much faster way. =============================================================================== This function is useful when parsing a CSV file with a heading column, but the columns might vary in order or presence: I find this better than referencing the numerical array index. =============================================================================== I needed a way to flip a multidimensional array and came up with this function to accomplish the task. I hope it helps someone else. $Value) { // If there is an original key that need to be preserved as data in the new array then do that if requested ($OrigKeyName=true) if ($OrigKeyName) $Value[$OrigKeyName]=$Key; // Require a string value in the data part of the array that is keyed to $DesiredKey if (!is_string($Value[$DesiredKey])) return false; // If $DesiredKey2 was specified then assume a multidimensional array is desired and build it if (is_string($DesiredKey2)) { // Require a string value in the data part of the array that is keyed to $DesiredKey2 if (!is_string($Value[$DesiredKey2])) return false; // Build NEW multidimensional array $ArrayOut[$Value[$DesiredKey]][$Value[$DesiredKey2]]=$Value; } // Build NEW single dimention array else $ArrayOut[$Value[$DesiredKey]][]=$Value; } return $ArrayOut; }//end multi_array_flip ?> =============================================================================== Similarly, if you want the last value without affecting the pointer, you can do: =============================================================================== Finding the longest string in an array? Differences are obvious: returns an array of [i]all[/i] of the longest strings, instead of just picking one arbitrarily. Doesn't do the stripslashing or magic stuff because that's another job for for another function. =============================================================================== array_flip() does not retain the data type of values, when converting them into keys. :( '1', 'two' => '2', 'three' => '3'); var_dump($arr); $arr2 = array_flip($arr); var_dump($arr2); ?> This code outputs this: array(3) { ["one"]=> string(1) "1" ["two"]=> string(1) "2" ["three"]=> string(1) "3" } array(3) { [1]=> string(3) "one" [2]=> string(3) "two" [3]=> string(5) "three" } It is valid expectation that string values "1", "2" and "3" would become string keys "1", "2" and "3". =============================================================================== When you do array_flip, it takes the last key accurence for each value, but be aware that keys order in flipped array will be in the order, values were first seen in original array. For example, array: [1] => 1 [2] => 2 [3] => 3 [4] => 3 [5] => 2 [6] => 1 [7] => 1 [8] => 3 [9] => 3 After flipping will become: (first seen value -> first key) [1] => 7 [2] => 5 [3] => 9 And not anything like this: (last seen value -> last key) [2] => 5 [1] => 7 [3] => 9 In my application I needed to find five most recently commented entries. I had a sorted comment-id => entry-id array, and what popped in my mind is just do array_flip($array), and I thought I now would have last five entries in the array as most recently commented entry => comment pairs. In fact it wasn't (see above, as it is the order of values used). To achieve what I need I came up with the following (in case someone will need to do something like that): First, we need a way to flip an array, taking the first encountered key for each of values in array. You can do it with: $array = array_flip(array_unique($array)); Well, and to achieve that "last comments" effect, just do: $array = array_reverse($array, true); $array = array_flip(array_unique($array)); $array = array_reverse($array, true); In the example from the very beginning array will become: [2] => 5 [1] => 7 [3] => 9 Just what I (and maybe you?) need. =^_^= =============================================================================== In case anyone is wondering how array_flip() treats empty arrays: results in: Array ( ) I wanted to know if it would return false and/or even chuck out an error if there were no key-value pairs to flip, despite being non-intuitive if that were the case. But (of course) everything works as expected. Just a head's up for the paranoid. =============================================================================== note :: array_flip is a changer for key and value and a auto unique like array_unique : =============================================================================== From an algorithmic efficiency standpoint, building an entire array of lengths to then sort to only retrieve the longest value is unnecessary work. The following should be O(n) instead of O(n log n). It could also be: $longestLen) { $longest = $value; $longestLen = $len; } } $longest = str_replace("\r\n", "\n", $longest); if (get_magic_quotes_gpc()) { return stripslashes($longest); } return $longest; } ?> =============================================================================== this function can be used to remove null elements form an array: [1] => 1 [2] => 2 [3] => [4] => 3 [5] => ) */ print_r(array_flip(array_flip($ar))); /* result: Array ( [1] => 1 [2] => 2 [4] => 3 ) */ ?> =============================================================================== I know a lot of people want a function to remove a key by value from an array. I saw solutions that iterate(!) though the whole array comparing value by value and then unsetting that value's key. PHP has a built-in function for pretty much everything (heard it will even cook you breakfast), so if you think "wouldn't it be cool if PHP had a function to do that...", odds are it already has. Check out this example. It takes a value, gets all keys for that value if it has duplicates, unsets them all, and returns a reindexed array. $arr contains: Array ( [0] => Array ( [0] => 11 [1] => 13 ) ?> ) =============================================================================== $values){ foreach ($values as $value){ $output[$value][] = $key; } } return $output; } =============================================================================== "submit", "textarea" => "Some long spiel of text\r\na textarea, probably", "another-input" => "make me longer", "and" => "another" , "etc" => "etc."); echo '
Longest value: ', get_longest_value($array),'body>'; function get_longest_value($array) { foreach ($array as $key => $value) { $lengths[$key] = strlen($value); } asort($lengths); $lengths = array_flip($lengths); $longest = str_replace("\r\n", "\n", $array[array_pop($lengths)]); if (get_magic_quotes_gpc()) { return stripslashes($longest); } return $longest; } ?>