Discrete Bubble Model Users Guide¶
| Release: | 1.1 |
|---|---|
| Date: | Nov 08, 2017 |
Scripts¶
The class objects and method functions defined in the dbm
module provide a
flexible structure to handle the chemistry and thermodynamics of mixtures.
The examples detailed below show a few of the common tasks that may be
facilitated by the dbm
module. Further examples are presented in the
following scripts distributed in the ./bin
directory with the source
code.
Examples¶
While there are many different applications of the dbm
module objects and
methods, here we focus on a few of the most common tasks.
The basic philosophy of the dbm
module objects is to store all constant
chemical properties as object attributes (e.g., molecular weight, temperature
and pressure at the critical point, etc.) and to make the thermodynamic state
(e.g., temperature, pressure, salinity, etc.) as inputs to the object methods
(e.g., when calculating the density). Because this model is designed to work
with dissolving objects, the masses of each component in the mixture are also
taken as inputs to the methods. While mole could have been the fundamental
unit for composition, mass is used in TAMOC
.
Mixture Equations of State¶
As in the scripts above for air_eos
and co2_eos
, the dbm.FluidMixture
object provides an interface to the Peng-Robinson equation of state for any
mixture of chemicals.
As an example, consider a natural gas containing the following compounds with given mole fractions in the mixture:
>>> composition = ['methane', 'ethane', 'propane', 'n-butane']
>>> yk = np.array([0.86, 0.06, 0.04, 0.04])
If the binary interaction coefficients are going to be taken as default, then
we can initialize a dbm.FluidMixture
object as follows:
>>> import dbm
>>> gas = dbm.FluidMixture(composition)
This has now loaded all of the chemical properties of this mixture. As an example, the molecular weights of each compound are:
>>> gas.M
array([ 0.0160426, 0.0300694, 0.0440962, 0.058123 ])
In order to compute thermodynamic properties, we must further define the thermodynamic state and composition masses. The fundamental quantity describing the variables of the mixture are the masses. In this example, consider one mole of gas:
>>> m = gas.masses(yk)
>>> T = 273.15 + 10.0
>>> P = 101325.
>>> S = 34.5
The salinity is only used to calculate solubilities in water. Consider several common properties of interest:
>>> gas.mass_frac(yk)
array([ 0.70070791, 0.09163045, 0.08958287, 0.11807877])
>>> gas.mol_frac(m)
array([ 0.86, 0.06, 0.04, 0.04])
>>> gas.density(m, T, P)
array([[ 0.85082097],
[ 0.85082097]])
>>> gas.partial_pressures(m, P)
array([ 87139.5, 6079.5, 4053., 4053.])
>>> gas.fugacity(m, T, P)
array([[ 86918.57653329, 6027.56643121, 3997.97690862, 3977.65301771],
[ 86918.57653329, 6027.56643121, 3997.97690862, 3977.65301771]])
>>> gas.solubility(m, T, P, S)
array([[ 0.0205852 , 0.00434494, 0.00355051, 0.00366598],
[ 0.0205852 , 0.00434494, 0.00355051, 0.00366598]])
>>> gas.diffusivity(T)
array([ 1.82558730e-09, 1.68688060e-09, 1.35408904e-09,
8.76029676e-10])
For those entries above with more than one row in the output, the top row refers to the gas phase and the bottom row refers to the liquid phase. If both rows are identical (as in this example) there is only one phase present, and the user generally must look at the density to determine which phase (here, we have 0.85 kg/m^3, which is a gas).
If the same mixture is brought to deepwater conditions, there would be both gas and liquid present:
>>> P = 490e5
>>> gas.density(m, T, P)
array([[<PHONE_NUMBER>5],
[<PHONE_NUMBER>1]])
These methods do not take steps necessary to make the gas and liquid in equilibrium with each other. Instead, this function reports the density of gas or liquid if each had the mass composition specified by m.
To evaluate the equilibrium composition, one must use the
dbm.FluidMixture.equilibrium
method. As an example for this mixture:
>>> T = 273.15 + 4.1
>>> P = 49.5e5
>>> gas.equilibrium(m, T, P)
array([[ 0.01349742, 0.00168584, 0.00129938, 0.00092275],
[ 0.00029921, 0.00011832, 0.00046447, 0.00140217]])
Generally, the equilibrium calculation is only meaningful when there is a significant two-phase region of the thermodynamic space for this mixture.
Bubbles or Droplets¶
Bubbles and droplets in general require the same set of steps; here, we focus
on a bubble with similar composition to the mixture studied above. Both
bubbles and droplets are modeled by the dbm.FluidParticle
object. The main
differences between the dbm.FluidParticle
and dbm.FluidMixture
objects is
that the dbm.FluidParticle
can only have one phase (e.g., gas or liquid) and
also contains shape information so that concepts like rise velocity have
meaning.
If we consider the same mixture as above:
>>> composition = ['methane', 'ethane', 'propane', 'n-butane']
>>> yk = np.array([0.86, 0.06, 0.04, 0.04])
>>> import dbm
>>> bub = dbm.FluidParticle(composition, fp_type=0)
We can specify the thermodynamic state similarly to before (though, consider a hot reservoir fluid in deep water):
>>> T = 273.15 + 125.0
>>> P = 150.0e5
The mass vector is now conceptually the masses of each component in a
single bubble or droplet. Typically, we know the mole or mass fractions of
the components of the bubble or droplet and a characteristic fluid particle
size. Hence, the method dbm.FluidParticle.masses_by_diameter
is very
helpful for determining the actual masses of each component in the mixture:
>>> m = bub.masses_by_diameter(0.005, T, P, yk)
>>> print m
[ 4.54192150e-06 5.93939802e-07 5.80667574e-07 7.65375279e-07]
Once the masses m are known, it is a simple matter to determine the particle physical and transport attributes:
>>> Ta = 273.15 + 4.1
>>> Sa = 35.4
>>> bub.density(m, T, P)
99.036200340444182
>>> bub.particle_shape(m, T, P, Sa, Ta)
(2, # 2 : ellipsoid
0.0050000000000000018, # de
99.036200340444182, # rho_p
1034.959691281713, # rho_sw
0.0015673283914517876, # mu_sw
0.05298375) # sigma
>>> bub.slip_velocity(m, T, P, Sa, Ta)
0.22624243729143373
>>> bub.surface_area(m, T, P, Sa, Ta)
7.8539816339744881e-05
>>> bub.mass_transfer(m, T, P, Sa, Ta)
array([ 5.32070503e-05, 5.13189189e-05, 4.38949373e-05,
3.14623966e-05])
>>> bub.heat_transfer(m, T, P, Sa, Ta)
array([ 0.00113312])
Insoluble Fluid Particles¶
Sometimes either a particle is truly insoluble on the time-scale of the
simulations (e.g., sand) or the composition is too complicated for the
Peng-Robinson equation of state and it is safe to neglect solubility (e.g.,
for a dead oil over short time scales). In this case, an
dbm.InsolubleParticle
object is a simple means to capture the critical
properties of the particle yet provide an interface to the physics methods,
such as slip velocity.
Consider a sand particle. This particle is insoluble and incompressible.
The dbm
module can describe this particle as follows:
>>> import dbm
>>> sand = dbm.InsolubleParticle(isfluid=False, iscompressible=False,
rho_p=2500.)
Again, the mass must be established before the properties of the particle can be interrogated:
>>> T = 273.15 + 10.0
>>> P = 10.0e5
>>> Ta = 273.15 + 4.1
>>> Sa = 35.4
>>> m = sand.mass_by_diameter(0.005, T, P, Sa, Ta)
>>> print m
0.000163624617374
Then, all of the fluid properties relevant to an insoluble particle can be calculated:
>>> sand.density(T, P, Sa, Ta)
2500.0
>>> sand.particle_shape(m, T, P, Sa, Ta)
(4, # 4 : rigid sphere
0.005000000000000002, # de
2500.0, # rho_p
1028.5585666971483, # rho_sw
0.0015673283914517876, # mu_sw
0.07423) # sigma
>>> sand.slip_velocity(m, T, P, Sa, Ta)
0.4452547003124989
>>> sand.surface_area(m, T, P, Sa, Ta)
7.853981633974488e-05
>>> sand.heat_transfer(m, T, P, Sa, Ta)
array([ 0.00155563])


404 NOT FOUND
I have a bad news
for you
The page you are looking for might be removed or is temporarily unavailable
BACK TO HOMEPAGE


Configuration Management Specialist - Dahlgren, VA
Overview
SCCI is seeking a disciplined Configuration Management (CM) Specialist to participate on a team to support a Weapon System Program. The CM Specialist will be responsible for deriving metrics from various databases, creating, assisting with and maintaining business and configuration control processes, policies and Standard Operating Procedures (SOPs) based on program requirements. This position is located at our office in King George, VA and is available immediately.
Responsibilities:
The Configuration Management Specialist will:
-
Work as a liaison among engineers, CM specialists, and project managers to elicit, analyze, and implement requirements for system baseline management.
-
Assist with Software Version Description (SVD) creation.
-
Develop and revise process documents in support of configuration process management.
-
Facilitate communication flow within internal team and external customers.
-
Provide Status Reports / Metrics utilizing MSWord Excel, Visio, PowerPoint and other industry recognized programs.
-
Maintain file repositories and workflows via SharePoint or similar file/workflow-management tools.
-
Provide change control support using customer-developed tools.
-
Perform additional CM related functions as required (Planning, Configuration Identification, Status Accounting, Configuration Control and Audits).
Essential Skills and Experience:
-
Must be a U.S. CITIZEN and have a minimum of a SECRET SECURITY CLEARANCE.
-
Mid-Level (2-5 years of related experience).
-
Knowledge of CM principles, methods, and techniques.
-
Ability to quickly learn new tools and technical system configurations, and understand part versioning.
-
Highly proficient with MS Office tools, primarily MS Word, Excel and PowerPoint.
-
Ability to effectively communicate across all organizational levels to include co-workers, managers and government customers.
-
Ability to multi-task, work well independently and in a team environment.
-
Self-starter with strong technical skills and ability to learn new technologies quickly.
-
Ability to write clear, logically sequenced and grammatically correct documents.
Preferred Skills and Experience:
-
Familiarity with MS Access and/or Database Management.
-
Experience with coordinating Change Control Boards.
Keywords: Business Analyst, Configuration Management, Configuration, CM, Data Management, Weapon System, Software, System Configuration.
SCCI is committed to providing a comprehensive and competitive benefits package to meet the needs of employees and their families. EOE of Minorities, Females, Veterans, Disabilities.


Item Code:
Item Name:
Batch No:
Location:
Position:
Vendor Name:
Stock Quantity(KG):
Date:
Out Quantity(KG):
Sale Price
PO Code:
Customer Name:
Remark:
Submit
Close


The type mapping can be used to transfer a copy of an object to another sector.
You can use it in cases where you have principal/details. Or you need to open a panel/popup with more info in another sector
Here a simple sample:
As you can see in this sample, you can use the function [PostData](PostData) to send the mapping object back to his origin
You can use mapping to load a storageitem reference.
Here is a basic sample using mapping to edit an item inside an array in an object.
We can see the html for the DataMappingReferenceEdit.html below:
We can see that we are using the mapping with reference to load the data. And to save the save we are just using the PostData
The mapping will store the reference of his source to use the same reference to save the data.
You can subscribe a mapping to reload when its source is changed with the attribute d-dataMappingSubscribe. You can see a sample below:


Created by:
Komorokoko
Displaying 1 - 1 of 1 result.
Greetings from Kazachstan.
scalable
(Aug 27th, 2013, 2:31:00 PM)
4 Comments - Created by ilassassinli 5 minutes ago
Last post 5 seconds ago by
KamikazeCr0
281 Comments - Created by thejadefalcon 3 days ago
Last post 19 seconds ago by
Osiris11235
25 Comments - Created by TheSnake 1 day ago
Last post 22 seconds ago by
EvilMoo
8 Comments - Created by Wuschel 7 minutes ago
Last post 28 seconds ago by
Wuschel
Greetings from Kazachstan.


The 'Junar' API is a commercial platform to organize and publish data <http://www.junar.com>. It has been used in a number of national and local government Open Data initiatives in Latin America and the USA. This package is a wrapper to make it easier to access data made public through the 'Junar' API.
| Version: | 0.1.3 |
| Depends: | R (≥ 3.0.0) |
| Imports: | httr, jsonlite |
| Suggests: | knitr, rmarkdown, testthat (≥ 0.8.0) |
| Published: | 2017-12-11 |
| Author: | Frans van Dunné [aut, cre] |
| Maintainer: | Frans van Dunné <frans at ixpantia.com> |
| BugReports: | https://github.com/fvd/junr/issues |
| License: | MIT + file LICENCE |
| URL: | https://github.com/fvd/junr |
| NeedsCompilation: | no |
| Materials: | README |
| CRAN checks: | junr results |
| Reference manual: | junr.pdf |
| Vignettes: |
Acceder Datos Abiertos a Través del API de Junar Access Open Data Through the Junar API |
| Package source: | junr_0.1.3.tar.gz |
| Windows binaries: | r-devel: junr_0.1.3.zip, r-release: junr_0.1.3.zip, r-oldrel: junr_0.1.3.zip |
| OS X binaries: | r-release: junr_0.1.3.tgz, r-oldrel: junr_0.1.3.tgz |
| Old sources: | junr archive |
Please use the canonical form https://CRAN.R-project.org/package=junr to link to this page.


The following map shows various sites from the Pampa Colorada region and the Pucuncho basin. Each site fishtail projectile point will
link you to an artifact page which has a manipulatable 3D model of a projectile point from that site. "Artifact pages" in the navigation bar provides direct links to all archaeological sites repersented on the map below


QGamepad Class
A gamepad device connected to a system More...
| Header: | #include <QGamepad> |
| qmake: | QT += gamepad |
| Inherits: | QObject |
Properties
|
|
- 1 property inherited from QObject
Public Functions
| QGamepad(int deviceId = 0, QObject *parent = nullptr) | |
| ~QGamepad() | |
| double | axisLeftX() const |
| double | axisLeftY() const |
| double | axisRightX() const |
| double | axisRightY() const |
| bool | buttonL1() const |
| double | buttonL2() const |
| bool | buttonL3() const |
| bool | buttonR1() const |
| double | buttonR2() const |
| bool | buttonR3() const |
| bool | buttonA() const |
| bool | buttonB() const |
| bool | buttonCenter() const |
| bool | buttonDown() const |
| bool | buttonGuide() const |
| bool | buttonLeft() const |
| bool | buttonRight() const |
| bool | buttonSelect() const |
| bool | buttonStart() const |
| bool | buttonUp() const |
| bool | buttonX() const |
| bool | buttonY() const |
| int | deviceId() const |
| bool | isConnected() const |
| QString | name() const |
- 32 public functions inherited from QObject
Public Slots
| void | setDeviceId(int number) |
- 1 public slot inherited from QObject
Signals
| void | axisLeftXChanged(double value) |
| void | axisLeftYChanged(double value) |
| void | axisRightXChanged(double value) |
| void | axisRightYChanged(double value) |
| void | buttonAChanged(bool value) |
| void | buttonBChanged(bool value) |
| void | buttonCenterChanged(bool value) |
| void | buttonDownChanged(bool value) |
| void | buttonGuideChanged(bool value) |
| void | buttonL1Changed(bool value) |
| void | buttonL2Changed(double value) |
| void | buttonL3Changed(bool value) |
| void | buttonLeftChanged(bool value) |
| void | buttonR1Changed(bool value) |
| void | buttonR2Changed(double value) |
| void | buttonR3Changed(bool value) |
| void | buttonRightChanged(bool value) |
| void | buttonSelectChanged(bool value) |
| void | buttonStartChanged(bool value) |
| void | buttonUpChanged(bool value) |
| void | buttonXChanged(bool value) |
| void | buttonYChanged(bool value) |
| void | connectedChanged(bool value) |
| void | deviceIdChanged(int value) |
| void | nameChanged(QString value) |
- 2 signals inherited from QObject
Additional Inherited Members
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject
Detailed Description
A gamepad device connected to a system
QGamepad is used to access the current state of gamepad hardware connected to a system.
Property Documentation
axisLeftX : const double
This read-only property holds the value of the left thumbstick's X axis. The axis values range from -1.0 to 1.0.
Access functions:
| double | axisLeftX() const |
Notifier signal:
| void | axisLeftXChanged(double value) |
axisLeftY : const double
This read-only property holds the value of the left thumbstick's Y axis. The axis values range from -1.0 to 1.0.
Access functions:
| double | axisLeftY() const |
Notifier signal:
| void | axisLeftYChanged(double value) |
axisRightX : const double
This read-only property holds the value of the right thumbstick's X axis. The axis values range from -1.0 to 1.0.
Access functions:
| double | axisRightX() const |
Notifier signal:
| void | axisRightXChanged(double value) |
axisRightY : const double
This read-only property holds the value of the right thumbstick's Y axis. The axis values range from -1.0 to 1.0.
Access functions:
| double | axisRightY() const |
Notifier signal:
| void | axisRightYChanged(double value) |
buttonL1 : const bool
This read-only property holds the state of the left shoulder button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonL1() const |
Notifier signal:
| void | buttonL1Changed(bool value) |
buttonL2 : const double
This read-only property holds the value of the left trigger button. This trigger value ranges from 0.0 when not pressed to 1.0 when pressed completely.
Access functions:
| double | buttonL2() const |
Notifier signal:
| void | buttonL2Changed(double value) |
buttonL3 : const bool
This read-only property holds the state of the left stick button. The value is true
when pressed, and false
when not pressed. This button is usually triggered by pressing the left joystick itself.
Access functions:
| bool | buttonL3() const |
Notifier signal:
| void | buttonL3Changed(bool value) |
buttonR1 : const bool
This read-only property holds the state of the right shoulder button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonR1() const |
Notifier signal:
| void | buttonR1Changed(bool value) |
buttonR2 : const double
This read-only property holds the value of the right trigger button. This trigger value ranges from 0.0 when not pressed to 1.0 when pressed completely.
Access functions:
| double | buttonR2() const |
Notifier signal:
| void | buttonR2Changed(double value) |
buttonR3 : const bool
This read-only property holds the state of the right stick button. The value is true
when pressed, and false
when not pressed. This button is usually triggered by pressing the right joystick itself.
Access functions:
| bool | buttonR3() const |
Notifier signal:
| void | buttonR3Changed(bool value) |
buttonA : const bool
This read-only property holds the state of the A button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonA() const |
Notifier signal:
| void | buttonAChanged(bool value) |
buttonB : const bool
This read-only property holds the state of the B button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonB() const |
Notifier signal:
| void | buttonBChanged(bool value) |
See also QGamepadManager::connectedGamepads().
buttonCenter : const bool
This read-only property holds the state of the center button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonCenter() const |
Notifier signal:
| void | buttonCenterChanged(bool value) |
buttonDown : const bool
This read-only property holds the state of the direction pad down button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonDown() const |
Notifier signal:
| void | buttonDownChanged(bool value) |
buttonGuide : const bool
This read-only property holds the state of the guide button. The value is true
when pressed, and false
when not pressed. This button is typically the one in the center of the gamepad with a logo. Some gamepads will not have a guide button.
Access functions:
| bool | buttonGuide() const |
Notifier signal:
| void | buttonGuideChanged(bool value) |
buttonLeft : const bool
This read-only property holds the state of the direction pad left button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonLeft() const |
Notifier signal:
| void | buttonLeftChanged(bool value) |
buttonRight : const bool
This read-only property holds the state of the direction pad right button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonRight() const |
Notifier signal:
| void | buttonRightChanged(bool value) |
buttonSelect : const bool
This read-only property holds the state of the Select button. The value is true
when pressed, and false
when not pressed. This button can sometimes be labeled as the Back button on some gamepads.
Access functions:
| bool | buttonSelect() const |
Notifier signal:
| void | buttonSelectChanged(bool value) |
buttonStart : const bool
This read-only property holds the state of the Start button. The value is true
when pressed, and false
when not pressed. This button can sometimes be labeled as the Forward button on some gamepads.
Access functions:
| bool | buttonStart() const |
Notifier signal:
| void | buttonStartChanged(bool value) |
buttonUp : const bool
This read-only property holds the state of the direction pad up button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonUp() const |
Notifier signal:
| void | buttonUpChanged(bool value) |
buttonX : const bool
This read-only property holds the state of the X button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonX() const |
Notifier signal:
| void | buttonXChanged(bool value) |
buttonY : const bool
This read-only property holds the state of the Y button. The value is true
when pressed, and false
when not pressed.
Access functions:
| bool | buttonY() const |
Notifier signal:
| void | buttonYChanged(bool value) |
connected : const bool
This read-only property holds the connectivity state of the gamepad device. If a gamepad is connected, this property will be true, otherwise false.
Access functions:
| bool | isConnected() const |
Notifier signal:
| void | connectedChanged(bool value) |
deviceId : int
This property holds the deviceId of the gamepad device. Multiple gamepad devices can be connected at any given time, so setting this property defines which gamepad to use.
Access functions:
| int | deviceId() const |
| void | setDeviceId(int number) |
Notifier signal:
| void | deviceIdChanged(int value) |
See also QGamepadManager::connectedGamepads().
name : const QString
This read-only property holds the reported name of the gamepad if one is available.
Access functions:
| QString | name() const |
Notifier signal:
| void | nameChanged(QString value) |


What's The Temp Outside?
Get Weather
You're looking for the weather in {{city}}, {{state}}
The temp outside is {{temp}}
{{err}}


Welcome to medSCHED, your medical reminder. Get started by clicking on adding a new medicine and then set your reminder.
Medicines
View All
Today
{{ today_card_html|safe }}Tomorrow
{{ tomorrow_card_html|safe }}Niggaday
{{ day_after_card_html|safe }}


FlightSurety
Flight
LX123
CX345
Time
Jan 1 2021
Feb 2 2021
Submit to Oracles
Amount (in ether)
Buy insurance
Get my balance in contract
Withdraw to my wallet
Fund first airline


So, I have this friend (who will remain nameless) who informed my boyfriend and I about these seed pods growing on someone's front lawn near my high school. The first thing that came to my mind was 'Woo! Free hallucinogenics!' He suggested that we smoke the plant, or brew some tea with it. We decided it would be much easier to just eat a few of the seeds and see what happened.
DAY 1:
Oct. 27, 2005
My boyfriend and I had experimented with the seeds the night before but we felt no effects. He didn't want to bother with any further experimentation but I, on the other hand, am a very curious person. I decided that maybe if I took a few cap-fulls of the stuff, I would have a better trip. Man, was I ever wrong.
4:30 PM
I take a cap-full of the Datura seeds at my boyfriend's house (even though he kept telling me not to). We were just on our way to my apartment and I decided to take another cap-full on the way to the bus stop.
5:15 PM
I'm laying on my bed watching TV with my boyfriend drinking Jonesís Soda when my head starts to feel funny. My body is all tingly and my head feels inflated. I'm also very, very thirsty from what I can remember.
5:20 PM
I am delirious and the hallucinations have started to kick in. I thought I was back in my boyfriend's basement and I turned to him, grabbing my guitar, and said 'Okay Chris, I gotta go home now.' and to my surprise, he says 'But Mel, you ARE home.' and I'm like, 'Chris, that's not funny, I gotta get to class.' I was now hallucinating that I was in front of my school and I was grabbing my guitar to go to class.
5:45 PM
My boyfriend informs my mom that I have ingested Datura because he's so concerned about my hallucinations, and my lack of ability to speak, or even form words. We go outside while my mom calls the Poison Control Centre and according to my boyfriend, I couldn't even hold my cigarette or stand up properly. My purse would continuously slip off my arm and my cigarette would keep falling out of my hand because my mind was no longer with me.
6:00 PM
Poison Control has reserved a space in the Emergency Room for me because I had ingested a poisonous substance which the hospital has heard little about. My mom makes me put my shoes back on, which wasn't easy. I kept putting two different shoes on because I was having trouble deciding 'which one was prettier than the other'.
6:20 PM
We are on our way to the hospital that is about 5 minutes from my apartment and I'm nodding-out in the front seat. When my mom parks the car, I'm passed out and worrying both her and my boyfriend as they frantically try to wake me up. We get into Emergency and Chris sits me down in a wheelchair, where I begin to pick the fluff off of the sweater that the black lady sitting next to me was wearing.  I can't remember anything except for what my mom or boyfriend told me, after this.
LATER THAT NIGHT
I'm in a room in Emergency and I'm being restrained because I won't stay still so that the staff can sedate me. My heart rate was soaring over the normal number. It was like my heart was running a marathon for 24 hours. After being sedated, my body is pumped with charcoal while my boyfriend stands next to me (but far enough away like the doctor said, incase I threw up).
DAY 2:
Oct. 28, 2005
I'm still sedated and remember nothing from the night before. I have been moved to the Pediatric Ward where I have my own room with a boarder of hockey players, a TV, and my favourite teddy bear. I leave my comatose state around dinner time, but I'm still experience STRONG hallucinations.
7:00 PM
'Daddy Day Care' is on the TV, but I don't remember watching it.  Neither of them knew whether I would come out of this without any permanent damage to myself. My boyfriend had mixed my peas into my mashed potatoes for me (like I always do) and promised that he would stay with me, no matter what happened.
7:10 PM
I finish eating and am now capable of holding conversations with my mom and boyfriend. I supposedly performed an exorcism on my mom because I thought she was possessed. Her face kept morphing and bugs were crawling out of her eye sockets. There were also bugs crawling all over the floor of the hospital room as well. My boyfriend's logo on his shirt turned into a bunch of feathers, I saw a little puppy running around the room, and I kept seeing pixies and stars everywhere. Stars kept covering my hands and I had to keep brushing them off.
8:00 PM
My boyfriend's mom and his sister came to visit me, along with my grandfather. I was slowly returning to normal, but not quite. Only an hour or two before, I had come to the conclusion that while I was sedated, I was surgically given a penis (It was really a catheter, but I didn't know that). Zina, my boyfriend's mom, asked me about the hockey players on the ceiling and I informed her that one of them was beating the crap out of the other, and that there was a boat sailing by her.
8:20 PM
Two security guards come into my room as I wheeled myself around on the wheelchair, gaining the nickname 'Wheels' from my boyfriend and grandfather. The security guards told us that I was being moved to a better room because a baby was being moved into the room I was in. I wanted Chris to push my wheelchair, but they wouldn't let him. They wheeled me to the basement of the hospital, right towards the Psychiatric Ward. I was totally confused. I didn't know why they were taking me there and I was so scared.
8:30 PM
The woman working the nightshift informs us that I'm staying there for a few days under observation, just to make sure that my hallucinations do stop and that I make it out okay. By then I was only having mild hallucinations and knew exactly what was going on. They wouldn't let my mom or boyfriend stay overnight and I started bawling because I was so afraid. They forced a sleeping pill on me and since they had a Smoking Room down there, my mom had to get a doctor's note saying that even though I was under 18, I was allowed to smoke in there.
9:00 PM
My mom comes back with my suitcase of pyjamas, toiletries, make-up, etc. and tucks me in to my bed.  The chair was doing some s--t out of Jumanji, and vines were coming out of it and stuff. Everytime I blinked, it would go away and start all over again.
DAY 3:
Oct. 29, 2005
I finally fell asleep around 10:00 that night and woke up well rested in the morning. I was still seeing barely visible insects crawling on the floor, but within an hour, all the hallucinations had finally stopped. I got up and took a shower and did my make-up to make myself feel better. I spent the morning watching TV until my family came to visit at 2:00 until 8:00 pm (Visiting hours).
DAY 4:
Oct. 30, 2005
After watching TV for a good 4 hours, I have one last visit with the psychiatrist who says I can leave as soon as my family arrived. I literally jumped for joy.   I flipped off the staff who had been hassling me for the entire duration of my admittance and made my way out. I got more and more excited the closer we got to the doors. I was like a kid making my way into a candy store. It was a beautiful day and it felt great to be alive.
The three of us got back to my apartment and my mom and boyfriend told me everything that I have just told you guys, because I can't remember anything after putting my shoes on until watching 'Daddy Day Care'. My mom also told me that the doctors said if I didn't go to the hospital, I would've went into cardiac arrest and died. That means I would've had my funeral on Halloween. I would've died on Thursday, October 27, 2005 and been buried on my favourite holiday; Halloween.
That is my story about how easy it can be to get carried away. Curiosity killed the cat, and it NEARLY killed me. Parts of my experience are humorous to look back on, but I almost died.
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.


Who is Ryan Motl?
Frontend Developer/System Administrator/Mechanic/Repair
I am a creative IT Professional passionate about learning and technology based in Washington. I have 10+ years expeience in delievery and various other odd jobs. Currently, I am looking for work and would love to connect.
Worked with Comcast, ANCEA/Sakura-Con
Skills
HTML/CSS/Javascript/VBScript
Github
Linux/Mac/Windows
Computer Hardware/Networking
Automotive
Electronics Repair


Our focus is on providing services of the highest quality. Our professional team adheres to a set of standards during the knowledge transfer process to enhance the efficiency and productivity of our clients.
Satisfaction of our stakeholders is important to us. Hence, we view our customers as our partners rather than buyers of our services. Ensuring smooth adaptation of our processes and ease of using our applications is our ultimate motto.


Internal Actions - LaF Defaults
The LaF Defaults window provides a key-value pair lookup for UI Controls. It also allows interactive prototyping of UI Control color changes.
If the menu item Tools | Internal Actions is not available in IntelliJ IDEA, then the first step is to enable internal mode
Opening LaF Defaults
The LaF Defaults window is opened by selecting the menu item Tools | Internal Actions | UI | LaF Defaults.
The LaF Defaults window has two columns representing key-value pairs for UI Controls:
- The Name column contains the UI Control
key
for each IntelliJ Platform UI element available at runtime. - The Value column contains the UI Control color
value
for each IntelliJ Platform UI element.
Using the the LaF Panel
Finding UI Controls
The LaF Defaults window is used interactively by entering a UI element type - e.g. Panel
- in the Filter text box at the top.
LaF Defaults shows the list of UI Control names matching the filter.
Clicking on one of the names narrows the information to show only the key-value pair for that UI element:
Prototyping the Color of UI Controls
The color of UI Controls can be changed (in real time) by clicking in the Value column next to a Name (key
) of interest.
The Choose Color window is displayed.
Color changes can be specified as RGB, hexadecimal, or using the color picker.
Pressing the Choose button changes the UI Control color immediately.
UI Control colors can be reset using the Choose Color window, or by resetting the UI Theme.


Pritika Natraj
About
Pritika Natraj is a Computer Science student at the University of California, San Diego


There Will Be In Total 3 Rounds. Round 1: -Phase 1: Pen-Paper Test(Max. Time -30 Mins) Every Team Will Be Provided A Question Paper Consisting A Number Of Questions Related To Bollywood Movies. -Phase 2: Guess The Movie Song And Complete It Participants Will Be Given Lyrics of Hindi songs In English. So, They Have To Guess The Correct Name Of The Song And Sing A Few Lines Of It. For Every Correct Answer 5 Points Will Be Granted. For Every Wrong Answer 5 Points Will Be Deducted. If They Are Able To Recognize The Correct Movie Name Extra 5 Points Will Be Granted. Marks From Phase 1 And Phase 2 Will Be Added ; Top 10 Teams Will Qualify For Round 2; Round 2: Pictionary. -Depecting Movies/Songs Via Pictures. -Picking Chits From The Bowl. -Teams Can Challenge One Another. Top 4 Teams Will Qualify For Round 3. Round 3: Bolly Quiz At Center Foyer(Cf). -Various Questions Will Be Asked.
(1) Participants Can’t Use Google Or Any Resource To Answer The Questions. (2) Team Should Consist Of Maximum 3 Students. (3) There Will Be Total 3 Rounds And At The End, We Will Have A Winner And Runner-Up. (4) Participant Found Cheating,Arguing With Co-Ordinator/Volunteer Will Be First Warned , But If He/She Still Repeats The Same Mistake Then 5 Points Will Be Deducted And Under Extreme Conditions He/She Would Be Disqualified. (5) The Decision Taken By The Co-Ordinater Will Be Considered Final In Case Of Any Dispute.
6 members
08/03/2017
11:00 onwards
30/- per team
VIDIT GANDHI (IT<EMAIL_ADDRESS>9978099389


Wireframes
During week 1 of Phase 0, each of us were challenged to reverse engineer three of our favorite websites, and create wireframes to share with our cohort. Mine are below!
Trulia
The purpose of the Trulia site is to gather property listings from within a searchable area (city, neighborhood, etc.), and list them for prospective buyers/renters to choose from. The visual challenges for this site include: clearly displaying what the purpose of the site is, drawing the user's attention to an input box to gather necessary info, displaying the listings in an appealing, yet concise way. They accomplish this by locating the input field in the middle of large, relevant image at the top of the homepage. Once the search criteria is entered by the user, the property listing are then displayed neatly, containing only the most necessary information.
------------------------
Skillcrush
Skillcrush.com is a company site which is used to market/advertise the training they offer for aspiring web developers and designers. With all of the tech traffic they have through the site, the pressure to impress is that much higher! Skillcrush does a fantastic job of conquering its visual challenges, which include: how to present their products/services in a captivating way, and how to meet the user's high expectations for their site's design. Skillcrush uses stunning backgrounds for its various pages, and ties in additional images in a way that is calm and fluid. The color scheme for the various elements of the page draw attention to the more critical areas of the site without overwhelming the user.
----------------
RealClearPolitics
Of the three sites, RCP has a purpose much different than the other two. The goal of this site is to keep an up-to-date collection of the most popular editorials and news articles pertaining to recent current events. Where other sites may need to "shock and awe" the user with stunning visual elements, RCP is more concerned with displaying the content in a clear, and organized fashion. They do so by limiting the links for all articles to a single line, with consistent formatting for each link. Links are also separated by timeframes and other various subcategories. Considering the quantity of information contained on RCP, they've done a suitable job meeting their visual and content objectives.


"different parameters."
)
if verbose:
print(time.ctime(time.time()) + " Finished Nearest Neighbor Search")
return knn_indices, knn_dists, rp_forest
n_trees = 5 + int(round((X.shape[0]) ** 0.5 / 20.0))
n_iters = max(5, int(round(np.log2(X.shape[0]))))
if verbose:
print(ts() + "Building RP forest with " + str(n_trees) + " trees")
rp_forest = make_forest(X, n_neighbors, n_trees, rng_state, angular)
leaf_array = rptree_leaf_array(rp_forest)


Flex basis = auto e flex grow = 1
Flex basis = auto e flex grow = 2
Flex basis = 0 e flex grow = 1
Flex basis = 100px e flex grow = 2


@article{luo2018comparative, title={Comparative analysis of metabolism of trichloroethylene and tetrachloroethylene among mouse tissues and strains}, author={Luo, Yu-Syuan and Hsieh, Nan-Hung and Soldatow, Valerie Y and Chiu, Weihsueh A and Rusyn, Ivan}, journal={Toxicology}, volume={409}, pages={33--43}, year={2018}, doi={10.1016/j.tox.2018.07.012}, publisher={Elsevier} }


--- layout: post title: "Get and Put State" description: "A pair of standard helper functions for the State monad. An article for object-oriented programmers." date: 2022-07-04 9:15 UTC tags: [Software Design, Functional Programming] --- {% include JB/setup %}
{{ page.description }}
The State monad is completely defined by its two defining functions (SelectMany
and Return
). While you can get by without them, two additional helper functions (get and put) are so convenient that they're typically included. To be clear, they're not part of the State monad - rather, you can consider them part of what we may term a standard State API.
In short, get is a function that, as the name implies, gets the state while inside the State monad, and put replaces the state with a new value.
Later in this article, I'll show how to implement these two functions, as well as a usage example. Before we get to that, however, I want to show a motivating example. In other words, an example that doesn't use get and put.
The code shown in this article uses the C# State implementation from the State monad article.
Imagine that you have to implement a simple Aggregator.
"How do we combine the results of individual but related messages so that they can be processed as a whole?"
[...] "Use a stateful filter, an Aggregator, to collect and store individual messages until it receives a complete set of related messages. Then, the Aggregator publishes a single message distilled from the individual messages."
The example that I'll give here is simplified and mostly focuses on how to use the State monad to implement the desired behaviour. The book Enterprise Integration Patterns starts with a simple example where messages arrive with a correlation ID as an integer. The message payload is also a an integer, just to keep things simple. The Aggregator should only publish an aggregated message once it has received three correlated messages.
Using the State monad, you could implement an Aggregator like this:
public sealed class Aggregator : IState<IReadOnlyDictionary<int, IReadOnlyCollection<int>>, Maybe<Tuple<int, int, int>>> { private readonly int correlationId; private readonly int value; public Aggregator(int correlationId, int value) { this.correlationId = correlationId; this.value = value; } public Tuple<Maybe<Tuple<int, int, int>>, IReadOnlyDictionary<int, IReadOnlyCollection<int>>> Run( IReadOnlyDictionary<int, IReadOnlyCollection<int>> state) { if (state.TryGetValue(correlationId, out var coll)) { if (coll.Count == 2) { var retVal = Tuple.Create(coll.ElementAt(0), coll.ElementAt(1), value); var newState = state.Remove(correlationId); return Tuple.Create(retVal.ToMaybe(), newState); } else { var newColl = coll.Append(value); var newState = state.Replace(correlationId, newColl); return Tuple.Create(new Maybe<Tuple<int, int, int>>(), newState); } } else { var newColl = new[] { value }; var newState = state.Add(correlationId, newColl); return Tuple.Create(new Maybe<Tuple<int, int, int>>(), newState); } } }
The Aggregator
class implements the IState<S, T>
interface. The full generic type is something of a mouthful, though.
The state type (S
) is IReadOnlyDictionary<int, IReadOnlyCollection<int>>
- in other words, a dictionary of collections. Each entry in the dictionary is keyed by a correlation ID. Each value is a collection of messages that belong to that ID. Keep in mind that, in order to keep the example simple, each message is just a number (an int
).
The value to produce (T
) is Maybe<Tuple<int, int, int>>
. This code example uses this implementation of the Maybe monad. The value produced may or may not be empty, depending on whether the Aggregator has received all three required messages in order to produce an aggregated message. Again, for simplicity, the aggregated message is just a triple (a three-tuple).
The Run
method starts by querying the state
dictionary for an entry that corresponds to the correlationId
. This entry may or may not be present. If the message is the first in a series of three, there will be no entry, but if it's the second or third message, the entry will be present.
In that case, the Run
method checks the Count
of the collection. If the Count
is 2
, it means that two other messages with the same correlationId
was already received. This means that the Aggregator
is now handling the third and final message. Thus, it creates the retVal
tuple, removes the entry from the dictionary to create the newState
, and returns both.
If the state
contains an entry for the correlationId
, but the Count
isn't 2
, the Run
method updates the entry by appending the value
, updating the state to newState
, and returns that together with an empty Maybe value.
Finally, if there is no entry for the correlationId
, the Run
method creates a new collection containing only the value
, adds it to the state
dictionary, and returns the newState
together with an empty Maybe value.
A message handler could be a background service that receives messages from a durable queue, a REST endpoint, or based on some other technology.
After it receives a message, a message handler would create a new instance of the Aggregator
:
var a = new Aggregator(msg.CorrelationId, msg.Value);
Since Aggregator
implements the IState<S, T>
interface, the object a
represents a stateful computation. A message handler might keep the current state in memory, or rehydrate it from some persistent storage system. Keep in mind that the state must be of the type IReadOnlyDictionary<int, IReadOnlyCollection<int>>
. Wherever it comes from, assume that this state is a variable called s
(for state).
The message handler can now Run
the stateful computation by supplying s
:
var t = a.Run(s);
The result is a tuple where the first item is a Maybe value, and the second item is the new state.
The message handler can now publish the triple if the Maybe value is populated. In any case, it can update the 'current' state with the new state. That's a nice little impureim sandwich.
Notice how this design is different from a typical object-oriented solution. In object-oriented programming, you'd typically have an object than contains the state and then receives the run-time value as input to a method that might then mutate the state. Data with behaviour, as it's sometimes characterised.
The State-based computation turns such a design on its head. The computation closes over the run-time values, and the state is supplied as an argument to the Run
method. This is an example of the shift of perspective often required to think functionally, rather than object-oriented. That's why it takes time learning Functional Programming (FP); it's not about syntax. It's a different way to think.
An object like the above a
seems almost frivolous, since it's going to have a short lifetime. Calling code will create it only to call its Run
method and then let it go out of scope to be garbage-collected.
Of course, in a language more attuned to FP like Haskell, it's a different story:
let h = handle (corrId msg) (val msg)
Instead of creating an object using a constructor, you only pass the message values to a function called handle
. The return value h
is a State value that an overall message handler can then later run with a state s
:
let (m, ns) = runState h s
The return value is a tuple where m
is the Maybe value that may or may not contain the aggregated message; ns
is the new state.
Is this approach to state mutation better than the default kind of state mutation possible with most languages (including C#)? Why make things so complicated?
There's more than one answer. First, in a language like Haskell, state mutation is in general not possible. While you can do state mutation with the IO container in Haskell, this sets you completely free.  Constraints liberate.
While the IO monad allows uncontrolled state mutation (together with all sorts of other impure actions), the State monad constrains itself and callers to only one type of apparent mutation. The type of the state being 'mutated' is visible in the type system, and that's the only type of value you can 'mutate' (in Haskell, that is).
The State monad uses the type system to clearly communicate what the type of state is. Given a language like Haskell, or otherwise given sufficient programming discipline, you can tell from an object's type exactly what to expect.
This also goes a long way to explain why monads are such an important concept in Functional Programming. When discussing FP, a common question is: How do you perform side effects? The answer, as may be already implied by this article, is that you use monads. The State monad for local state mutation, and the IO monad for 'global' side effects.
Clearly you can write an implementation of IState<S, T>
like the above Aggregator
class. Must we always write a class that implements the interface in order to work within the State monad?
Monads are all about composition. Usually, you can compose even complex behaviour from smaller building blocks. Just consider the list monad, which in C# is epitomised by the IEnumerable<T>
interface. You can write quite complex logic using the building blocks of Where, Select, Aggregate, Zip, etcetera.
Likewise, we should expect that to be the case with the State monad, and it is so. The useful extra combinators are get and put.
The get function enables a composition to retrieve the current state. Given the IState<S, T>
interface, you can implement it like this:
public static IState<S, S> Get<S>() { return new GetState<S>(); } private class GetState<S> : IState<S, S> { public Tuple<S, S> Run(S state) { return Tuple.Create(state, state); } }
The Get
function represents a stateful computation that copies the state
over to the 'value' dimension, so to speak. Notice that the return type is IState<S, S>
. Copying the state over to the position of the T
generic type means that it becomes accessible to the expressions that run inside of Select
and SelectMany
.
You'll see an example once I rewrite the above Aggregator
to be entirely based on composition, but in order to do that, I also need the put function.
The put function enables you to write a new state value to the underlying state dimension. The implementation in the current code base looks like this:
public static IState<S, Unit> Put<S>(S s) { return new PutState<S>(s); } private class PutState<S> : IState<S, Unit> { private readonly S s; public PutState(S s) { this.s = s; } public Tuple<Unit, S> Run(S state) { return Tuple.Create(Unit.Default, s); } }
This implementation uses a Unit
value to represent void
. As usual, we have the problem in C-based languages that void
isn't a value, but fortunately, unit is isomorphic to void.
Notice that the Run
method ignores the current state
and instead replaces it with the new state s
.
The Get
and Put
functions are enough that we can now rewrite the functionality currently locked up in the Aggregator
class. Instead of having to define a new class
for that purpose, it's possible to compose our way to the same functionality by writing a function:
public static IState<IReadOnlyDictionary<int, IReadOnlyCollection<int>>, Maybe<Tuple<int, int, int>>> Aggregate(int correlationId, int value) { return from state in State.Get<IReadOnlyDictionary<int, IReadOnlyCollection<int>>>() let mcoll = state.TryGetValue(correlationId) let retVal = from coll in mcoll.Where(c => c.Count == 2) select Tuple.Create(coll.ElementAt(0), coll.ElementAt(1), value) let newState = retVal .Select(_ => state.Remove(correlationId)) .GetValueOrFallback( state.Replace( correlationId, mcoll .Select(coll => coll.Append(value)) .GetValueOrFallback(new[] { value }))) from _ in State.Put(newState) select retVal; }
Okay, I admit that there's a hint of code golf over this. It's certainly not idiomatic C#. To be clear, I'm not endorsing this style of C#; I'm only showing it to explain the abstraction offered by the State monad. Adopt such code at your own peril.
The first observation to be made about this code example is that it's written entirely in query syntax. There's a good reason for that. Query syntax is syntactic sugar on top of SelectMany
, so you could, conceivably, also write the above expression using method call syntax. However, in order to make early values available to later expressions, you'd have to pass a lot of tuples around. For example, the above expression makes repeated use of mcoll
, so had you been using method call syntax instead of query syntax, you would have had to pass that value on to subsequent computations as one item in a tuple. Not impossible, but awkward. With query syntax, all values remain in scope so that you can refer to them later.
The expression starts by using Get
to get the current state. The state
variable is now available in the rest of the expression.
The state
is a dictionary, so the next step is to query it for an entry that corresponds to the correlationId
. I've used an overload of TryGetValue
that returns a Maybe value, which also explains (I hope) the m
prefix of mcoll
.
Next, the expression filters mcoll
and creates a triple if the coll
has a Count
of two. Notice that the nested query syntax expression (from...select
) isn't running in the State monad, but rather in the Maybe monad. The result, retVal
, is another Maybe value.
That takes care of the 'return value', but we also need to calculate the new state. This happens in a somewhat roundabout way. The reason that it's not more straightforward is that C# query syntax doesn't allow branching (apart from the ternary ?..:
operator) and (this version of the language, at least) has weak pattern-matching abilities.
Instead, it uses retVal
and mcoll
as indicators of how to update the state. If retVal
is populated, it means that the Aggregate
computation will return a triple, in which case it must Remove
the entry from the state dictionary. On the other hand, if that's not the case, it must update the entry. Again, there are two options. If mcoll
was already populated, it should be updated by appending the value
. If not, a new entry containing only the value
should be added.
Finally, the expression uses Put
to save the new state, after which it returns retVal
.
While this is far from idiomatic C# code, the point is that you can compose your way to the desired behaviour. You don't have to write a new class. Not that this is necessarily an improvement in C#. I'm mostly stating this to highlight a difference in philosophy.
Of course, this is all much more elegant in Haskell, where the same functionality is as terse as this:
handle :: (Ord k, MonadState (Map k [a]) m) => k -> a -> m (Maybe (a, a, a)) handle correlationId value = do m <- get let (retVal, newState) = case Map.lookup correlationId m of Just [x, y] -> (Just (x, y, value), Map.delete correlationId m) Just _ -> (Nothing, Map.adjust (++ [value]) correlationId m) Nothing -> (Nothing, Map.insert correlationId [value] m) put newState return retVal
Notice that this implementation also makes use of get
and put
.
The Get
and Put
functions are basic functions based on the State monad abstraction. These two functions, again, can be used to define some secondary helper functions, whereof Modify
is one:
public static IState<S, Unit> Modify<S>(Func<S, S> modify) { return Get<S>().SelectMany(s => Put(modify(s))); }
It wasn't required for the above Aggregate
function, but here's a basic unit test that demonstrates how it works:
[Fact] public void ModifyExample() { var x = State.Modify((int i) => i + 1); var actual = x.Run(1); Assert.Equal(2, actual.Item2); }
It can be useful if you need to perform an 'atomic' state modification. For a realistic Haskell example, you may want to refer to my article An example of state-based testing in Haskell.
Another occasionally useful second-order helper function is Gets
:
public static IState<S, T> Gets<S, T>(Func<S, T> selector) { return Get<S>().Select(selector); }
This function can be useful as a combinator if you need just a projection of the current state, instead of the whole state.
Here's another basic unit test as an example:
[Fact] public void GetsExample() { IState<string, int> x = State.Gets((string s) => s.Length); Tuple<int, string> actual = x.Run("bar"); Assert.Equal(Tuple.Create(3, "bar"), actual); }
While the above Aggregator example didn't require Modify
or Gets
, I wanted to include them here for completeness sake.
Most of the code shown in this article has been C#, with the occasional Haskell code. You can also implement the State monad, as well as the helper methods, in F#, where it'd feel more natural to dispense with interfaces and instead work directly with functions. To make things a little clearer, you may want to define a type alias:
type State<'a, 's> = ('s -> 'a * 's)
You can now define a State
module that works directly with that kind of function:
module State = let run state (f : State<_, _>) = f state let lift x state = x, state let map f x state = let x', newState = run state x f x', newState let bind (f : 'a -> State<'b, 's>) (x : State<'a, 's>) state = let x', newState = run state x run newState (f x') let get state = state, state let put newState _ = (), newState let modify f = get |> map f |> bind put
This is code I originally wrote for a Code Review answer. You can go there to see all the details, as well as a motivating example.
I see that I never got around to add a gets
function... I'll leave that as an exercise.
In C#, I've based the example on an interface (IState<S, T>
), but it would also be possible to implement the State monad as extension methods on Func<S, Tuple<T, S>>
. Try it! It might be another good exercise.
The State monad usually comes with a few helper functions: get, put, modify, and gets. They can be useful as combinators you can use to compose a stateful combination from smaller building blocks, just like you can use LINQ to compose complex queries over data.


Some information to handle the cpp files in the telemetry.
Like you can see in the file <scs_config_handlers.cpp> the visual studio keyword
#pragma region RegionName
...
#pragma endregion Comment
is used. With the help of this lines, you can outline the region with a click on the `-`. In other IDE's or editors it may not give you that possibility, but it still should help to understand the region.


What is an Article?
These are the rich content text files providing relevant information for any particular topic. One can quickly get the answers to all the problems from these rich content articles.
In short, the articles are saved documents from which a customer or a user can fetch valuable information. You can make sure that your customer has a right insight by sharing a proper and standard knowledge base with them.
The support agents if they have a privilege can add and organize solution articles under the category and folders within the support portal so that your customers can quickly browse through them in their self-service portal.
Steps for creating a Article-
- Login to your UVdesk Support Panel.
- On the Dashboard, you will see "KNOWLEDGEBASE" menu and under it, you will find "Articles".
- Click on the "Articles" Icon and then you will be redirected to a new page.
- You will see a list of existing articles with its status, edit & delete buttons. You will also see Category and ID for each article.
- Click on "New Article" button to add a new Article.
- Enter Title, Content under the Article Tab.
- When the status of the article is Publish, then the article will be displayed on the front-end.
- Under the SEO, enter Slug, Meta Title, Meta Keywords & Meta Description.
- Under the Related Articles, you can enter the Article Title which you want to display on the front-end to the customer along with this current article.
- Under the Revisions feature, it stores a record of each saved or published article. You to see what changes you made in the article along with the time and date and you can also restore back the revision made on any specific date.
- The agent will also add Categories into the article by typing the first two alphabets of the Category name and then select it and add in the article.
- The agent will also view, preview and update their articles as taping on the front right side corner buttons.
- Click on "Save Changes" to save information and create a new Article.


This example will show how to create a more advanced version of middleware in Go.
A middleware in itself simply takes a http.HandlerFunc
as one of its parameters, wraps it and returns a new http.HandlerFunc
for the server to call.
Here we define a new type Middleware
which makes it eventually easier to chain multiple middlewares together. This idea is inspired by Mat Ryers’ talk about Building APIs.
You can find a more detailed explaination including the talk here.
This snippet explains in detail how a new middleware is created. In the full example below, we reduce this version by some boilerplate code.
func createNewMiddleware() Middleware {
// Create a new Middleware
middleware := func(next http.HandlerFunc) http.HandlerFunc {
// Define the http.HandlerFunc which is called by the server eventually
handler := func(w http.ResponseWriter, r *http.Request) {
// ... do middleware things
// Call the next middleware/handler in chain
next(w, r)
}
// Return newly created handler
return handler
}
// Return newly created middleware
return middleware
}
// advanced-middleware.go
package main
import (
"fmt"
"log"
"net/http"
"time"
)
type Middleware func(http.HandlerFunc) http.HandlerFunc
// Logging logs all requests with its path and the time it took to process
func Logging() Middleware {
// Create a new Middleware
return func(f http.HandlerFunc) http.HandlerFunc {
// Define the http.HandlerFunc
return func(w http.ResponseWriter, r *http.Request) {
// Do middleware things
start := time.Now()
defer func() { log.Println(r.URL.Path, time.Since(start)) }()
// Call the next middleware/handler in chain
f(w, r)
}
}
}
// Method ensures that only a url can me requested with a specific method, else returns a 400 Bad Request
func Method(m string) Middleware {
// Create a new Middleware
return func(f http.HandlerFunc) http.HandlerFunc {
// Define the http.HandlerFunc
return func(w http.ResponseWriter, r *http.Request) {
// Do middleware things
if r.Method != m {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
// Call the next middleware/handler in chain
f(w, r)
}
}
}
// Chain applies middlewares to a http.HandlerFunc
func Chain(f http.HandlerFunc, middlewares ...Middleware) http.HandlerFunc {
for _, m := range middlewares {
f = m(f)
}
return f
}
func Hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "hello world")
}
func main() {
http.HandleFunc("/", Chain(Hello, Method("GET"), Logging()))
http.ListenAndServe(":8080", nil)
}
$ go run advanced-middleware.go
2017/02/11 00:34:53 / 0s
$ curl -s http://localhost:8080/
hello world
$ curl -s -XPOST http://localhost:8080/
Bad Request


⇒ RIEF Orleans 2015: XVth Doctoral Meetings in International Trade and International Finance
The RIEF network organizes a yearly doctoral meeting which offers the opportunity for a limited number of PhD candidates or young PhDs to present their papers before an audience of senior researchers in the field. The 2015 edition will be hosted by the University of Orleans’ department of economics (LEO-CNRS) on June 25 and 26. PhDs candidates and young PhDs should submit their papers by March 9, 2015, decisions on papers will be taken on April 24, 2015.
Trade and long term unemployment
What is the effect of international trade on unemployment? We explore the link between openness to trade and unemployment using a multi-country, multi-sector gravity model with embedded heterogeneous sector-and-country specific labour market frictions. The model predicts that trade liberalisation may lead to an increase in unemployment if it results in labour reallocation into sectors with higher-than-average labour market frictions.
Immigration and Wages Inequality in France
Over 232 million people now reside in a country where they were not born. Immigrants thus account for 3.2% of the world's population. In the past two decades, the fraction of the population in developed countries that is foreign-born increased from 7% in 1990 to 10% in 2010. The rise in the demographic importance of international migration led to a parallel increase in the amount of time and effort that economists devote to studying the consequences of immigration. One of the main questions raised by economists is related to the labor impact of migration in receiving economies.
Does Country Size Matter for Trade Facilitation Assistance?
The Trade Facilitation Support Program is to help developing countries reform and modernize their border procedures. Such initiative is important as time delays at customs affect trade. Does country size affect trade facilitation? Is some of this cross-country variation in trade facilitation due to differences in country size?
Linguistic Proximity and Export Dynamics
Firms do not choose randomly their export market. Instead, empirical evidence suggest the existence of a geographic bias in the choice of export destination by firms. I argue that linguistic proximity (a proxy for the cultural proximity of the different export markets) can explain the dynamics of entry into new markets.
Sanctions and Exports Deflection
Thirty-one countries imposed severe exports sanctions on Iran in 2008. New research uncovers that two-thirds of the value of Iranian non-oil exports thought to be destroyed by non-oil exports sanctions have actually been deﬂected to destinations not imposing sanctions.


--- layout: post authors: ["Tracy Teal"] title: "Data Carpentry Genomics and Assessment Hackathon" date: 2015-01-28 time: "18:00:00" tags: ["Data Carpentry", "Assessment"] ---
If you're working or interested in genomics or assessment, we hope you'll consider applying for our upcoming Data Carpentry Genomics and Assessment hackathon. We're very excited about this event and the opportunity to develop lessons targeting genomics researchers and build assessment into the Data Carpentry curriculum. Travel support is available, so please apply to participate! It's a short application, and the deadline is this Friday, January 30th. If you have any questions about the event, please let us know.
Dates: March 23-25, 2015
Location: Cold Spring Harbor Labs, NY
Call for Participation
Application


Work Day Scheduler
A simple calendar app for scheduling your work day
09:00 AM
10:00 AM
11:00 AM
12:00PM
01:00PM
02:00PM
03:00PM
04:00PM
05:00PM


main page — COMP 526 Applied Algorithmics
Unit 2: Fundamental Data Structures
This is an archived version of this module from Spring 2020.
Click here for the current iteration.
This unit covers some fundamental data structures: stacks, queues, resizable arrays, binary heaps, and binary search trees.
Learning outcomes
- Understand the difference between abstract data type (ADT) and its implementation
- Know the ADTs stack, queue, priority queue and dictionary/symbol table
- Know array-based implementations of stack and queue
- Understand linked lists and the corresponding implementations of stack and queue
- Know binary heaps and their performance characteristics
- Understand binary search trees and their performance characteristics
Material
- tutorial problems
- notes from Q&A sessions
- Q&A Session 2020-02-04 on ADTs, Stacks, Resizable Arrays
- Q&A Session 2020-02-04 on Binary Heaps
- Q&A Session 2020-02-17 on Binary Search Trees (Search, Insert, Delete)
- Q&A Session 2020-02-18 on Binary Search Trees (Rank, Select, Analysis)
Lecture videos
This unit covers some prerequisites for the remainder of the module and is intended to bring all of you to the same level before moving on.
If you previously had an algorithms and data structures module in a computer science undergraduate program, this unit will mostly be recap for you, and you might be able to go over this unit at a faster pace.
To accommodate the varying levels of prior exposure with this material, this unit will be taught using videos. We will use the lecture videos from the online course Algorithms by Robert Sedgewick and Kevin Wayne with are available on CUvids.io.
How to watch the videos
Every video comes with a list of guidance questions resp. short tasks.
Try to answer all guiding questions while watching the videos! Take notes and bring these to class.
(I encourage you to handwrite these: The Pen Is Mightier Than the Keyboard (pdf).
Important: Speed up or slow down the videos (in the player) so that you are neither bored nor lost. CUvids.io also has a (searchable!) transcript of all videos, as well as subtitles.
1 – Stacks
Content: intro to ADTs, stacks and their implementations
Guiding questions:
- What is an abstract data type (according to Sedgewick)? What is a data structure?
- What operations does a stack support?
- What does FIFO and LIFO mean?
- What type of linked list is the presented implementation of a stack based on?
- How much space does the stack implementation use?
- What is the second implementation of stacks? Does it fully satisfy the specification of stack?
- What is loitering?
2 – Resizable Arrays
Content: doubling arrays, amortized costs
Guiding questions:
- First, a simplistic method is presented for obtaining arrays of variable sizes. How does it work? Why is it (usually) not useful?
- What are amortized costs? Describe the concept using
push
as an example. - When do we shrink the array again? Why do we do that?
- Do resizing-array stacks fulfill all API requirements?
- When should we use resizing arrays resp. linked lists to implement stacks according to Sedgewick?
3 – Queues
Content: queues and their implementations
Guiding questions:
- What operations does a queue support?
- How does the linked-list implementation of queues differ from that for stacks?
- How does the resizing-array implementation of queues differ from that for stacks?
4 – Java Generics
Content: Java generics for parametric types
Guiding questions:
- What options did programmers have in the original Java (before version 1.5)?
- What is the advantage of generics as introduced in Java 1.5?
- What caveats does Sedgewick mention in connection with Java generics?
5 – Iterators
Content: (Java’s) iterator concept, Bag ADT
Guiding questions:
- What operations does an iterator support?
- How can we implement an iterator for linked lists?
- How can we implement an iterator for arrays?
- For both cases, think about what happens when we add elements to the underlying stack while iterating over it. What happens to elements that are deleted?
[Optional] Stack and Queue Applications
Content: some interesting applications of stacks and queues; not vital for following COMP 526, but worthwhile knowing.
Guiding questions:
- What operations does Java’s
List
interface support? - Briefly describe the running-time complexity of these methods in
ArrayList
andLinkedList
. - What application for stacks does Sedgewick present?
- Which problem does Dijkstra’s two-stack algorithm solve? Which assumption does Sedgewick make for the input? (hint: parentheses!)
- How does Sedgewick justify the correctness of Dijkstra’s two-stack algorithm?
6 – Priority Queues
Content: The priority queue ADT, its applications and elementary implementations
Guiding questions:
- What operations do
MaxPQ
resp.MinPQ
offer? - Why does the
topM
test client use a MinPQ to find the M largest transactions – is that a mistake? - Which elementary implementations are presented? What are their running-time complexities?
7 – Binary Heaps
Content: binary-heap implementation (without change key)
Guiding questions:
- What is a binary tree (according to Sedgewick)? Be precise and give examples.
- What is a complete binary tree? How many (topologically, i.e., ignoring node labels) different complete binary trees with N nodes are there?
- What does it mean that a binary tree is heap-ordered? What does heap order imply for the key at the root?
- How does Sedgewick encode a complete binary tree in an array? How is that possible without explicitly storing where the child nodes of a node are stored?
- What does the swim operation do? Which preconditions must be fulfilled to run swim, and which postconditions does swim guarantee upon termination?
- What does sink do? What are pre- and postconditions?
- How does insert work for a binary-heap MaxPQ?
- How does delMax work for a binary-heap MaxPQ?
- What is the running-time complexity of these two operations?
- What does immutability mean? What could go wrong when keys of a PQ are not immutable?
8 – Symbol Table API
Content: symbol table ADT, requirements for keys, applications of symbol tables, and test clients.
Guiding questions:
- What operations does every symbol table (ST) support?
- What are similarities and differences between ST and mathematical functions?
- How should a typical implementation of Java’s
equals
method for a data type with several fields look like? What requirements have to be met? - Explain how the frequency counting test client uses STs.
9 – Elementary Symbol-Table Implementations
Content: functional, but inefficient ST implementations based on lists.
Guiding questions:
- What are the two implementations that are presented?
- How does
get
andput
work for these two implementations? - What is the running-time complexity of
get
andput
in these implementations?
10 – Ordered Operations
Content: Ordered ST ADT
Guiding questions:
- What are the (additional) operations in an ordered ST?
11 – Binary Search Trees
Content: (unbalanced) binary search trees (BSTs): definitions, search, insert, and analysis
Guiding questions:
- (again) What is a binary tree according to Sedgewick?
- What is a binary search tree (BST)? Draw a BST for the keys 10, 20, 30, 40, 50.
- How is a BST represented in Java? Draw a box-and-arrow diagram for your example BST.
- How does search in a BST work? Describe it on your example.
- How does insertion into a BST work? Again, give an example on your tree.
- How does the best-case tree w.r.t. search costs look like? (more precisely, the best case w.r.t. to searching each key once)
- What is the worst possible search cost? How does a tree look like where these occur?
- What statement does Sedgewick make about typical / average-case search costs in BSTs?
12 – Ordered Operations in BSTs
Content: augmented BST implementation of Ordered ST.
Guiding questions:
- How can we implement min and max in BSTs?
- How can we implement floor and ceiling?
- What do we have to do to maintain correct subtree sizes in all nodes?
- How does the rank operation work in BSTs?
Further reading and sources
The textbook corresponding to the lecture videos has some more details and many exercise problems. Summaries and code are available on the booksite.


Search location.
Search
Center Location
Search destination
Log in
Center Location
Zoom In
Zoom Out
Disable drag
Events - Visible
Jobs - Visible
Agencies - Visible
More settings
Log in to database
Report bug
About & Appendix
hardshell © 2019
We are hiring Web Developers! Click here for more.
See more
Hello world!
Advanced settings
Change map type:
Terrain
Terrain
Terrain
Terrain
Log in
To test:
Username: admin
Password: admin
Log in


--- layout: post title: How to critically evaluate the quality of a research article? date: 2011-08-01 00:01:30.000000000 +02:00 type: post published: true status: publish categories: - How-to - Literature research tags: - literature review - literature search - review process - scientific writing style - tips meta: _edit_last: '4' author: login: Zorana Zupan email<EMAIL_ADDRESS>display_name: Zorana Zupan first_name: Zorana last_name: Zupan ---
When considering a research idea, we are bound to rely on previous findings on the topic. Work done in the field constructs the foundation for our research and determines its course and value. Inaccurate findings may lead to imprecise applications and end in further fallacies in your own new scientific knowledge that you construct. In order to set a solid basis for research on any topic and to prevent multiplication of misinformation, it is crucial to to critically evaluate existing scientific evidence. It is important to know which information can be regarded as plausible.
So what's the criteria to determine whether a result can be trusted? As it is taught in the first classes in psychology, errors may emerge from any phase of the research process. Therefore, it all boils down to how the research has been conducted and the results presented.
Meltzoff (2007) emphasizes the key issues that can produce flawed results and interpretations and should therefore be carefully considered when reading articles. Here is a reminder on what to bear in mind when reading a research article:
Research question
The research must be clear in informing the reader of its aims. Terms should be clearly defined, even more so if they're new or used in specific non-spread ways. You as a reader should pay particular attention should to errors in logic, especially those regarding causation, relationship or association.
Sample
To provide trustworthy conclusions, a sample needs to be representative and adequate. Representativeness depends on the method of selection as well as the assignment. For example, random assignment has its advantages in front of systematic assignment in establishing group equivalence. The sample can be biased when researchers used volunteers or selective attrition. The adequate sample size can be determined by employing power analysis.
Control of confounding variables
Extraneous variation can influence research findings, therefore methods to control relevant confounding variables should be applied.
Research designs
The research design should be suitable to answer the research question. Readers should distinguish true experimental designs with random assignment from pre-experimental research designs.
Criteria and criteria measures
The criteria measures must demonstrate reliability and validity for both, the independent and dependent variable.
Data analysis
Appropriate statistical tests should be applied for the type of data obtained, and assumptions for their use met. Post hoc tests should be applied when multiple comparisons are performed. Tables and figures should be clearly labelled. Ideally, effect sizes shou
ld be included throughout giving a clear indication of the variables’ impact.
Discussion and conclusions
Does the study allow generalization? Also, limitations of the study should be mentioned. The discussion and conclusions should be consistent with the study’s results. It's a common mistake to emphasizing the results that are in accordance with the researcher’s expectations while not focusing on the ones that are not. Do the authors of the article you hold in hand do the same?
Ethics
Last but not least, ere the ethical standards met? For more information, refer to the APA’s Ethical Principles of Psychologists and Code of Conduct (2010).
References
American Psychological Association (2010, June 1). American Psychological Association Ethical Principles of Psychologists and Code of Conduct. Retrieved July 28, 2011 from http://www.apa.org/ethics/code/index.aspx
Meltzoff, J. (2007). Critical Thinking About Research. Washington, DC: American Psychological Association.
Edited by: Maris Vainre


---
layout: post
title: How to Install Shiny Server on OSX
date: '2014-02-20T15:38:00.001-08:00'
author: Mark Evans
tags:
- code
- Shiny
- R
- MacOS
modified_time: '2014-02-20T15:41:53.974-08:00'
blogger_id: tag:blogger.com,1999:blog-8042776731714569314.post-6547903943915645527
blogger_orig_url: http://codexpython.blogspot.com/2014/02/how-to-install-shiny-server-on-osx_20.html
---
I want to set up the shiny-server
to run on an iMac at work so that we can run multiple R-apps over the intranet. According to the docs for Shiny server, OSX is not supported yet (version 1.1.0) so we are going to build it from source and hope for the best!
Instructions for building from source are here. We follow them pretty closely but there are a few gotchas.
The full HowTo is on our GitHub Wiki, here