This package is an example of how you can use SQLite Database FTS functionality in an R package. It provides data access to some (not so well curated?) data from the World Factbook data distributed in the SQLite database format which is initially downloaded from a remote location.
A local SQLite db is then created based this distribution of data and extended to support Full Text Search functionality. This data is then exposed to R through a couple of functions returning tibbles.
The support for FTS - Full Text Search - is provided by using the RSQLite
package which embeds the fast and SQL-ansi-compliant sqlite database engine portably and thereby embeds the FTS5 seach capabilities built into this database engine.
The idea is to show how to provide access to data in a potentially larger database - the database in the example is not huge but could be a lot bigger - and show how to enable use of in-built full text search capabilities in SQLite. The approach is to download potentially big remote data and installing it locally using the rappdirs
R package, rather than bundling it directly into the package.
This can be useful if you are considering to release a package to CRAN that provides access to larger datasets in R and you also want to follow the general recommendation from the CRAN checks that “package data should be smaller than a megabyte”. With this approach you can avoid having to argue separately with the CRAN gods for making an exception to the 1 MB rule (see details in Hadley Wickhams R Packages book, the sections on data packages and CRAN rules).
There are a few minor practical drawbacks - mostly that your package will initially not work off-line until at least one initial successfull call to download the data has been made using factbook_download()
which would require a connection to the Internet.
The upside is being able to tap into things like Full Text Search for datasets and with this approach the package can stay small and pass the CRAN checks without requiring exceptions, while the dataset size is only limited to 2TB (an SQLite limitation).
After installing, you need to first download the data and can then proceed to work it it:
library(factbook)
library(dplyr)
# get the data, only required to run once initially
factbook_download()
# use the data
df <- factbook_tibble()
This is a few of the rows and columns in the data:
| id | code | name | area | area_land |
|---|---|---|---|---|
| 1 | af | Afghanistan | 652230 | 652230 |
| 2 | al | Albania | 28748 | 27398 |
| 3 | ag | Algeria | 2381741 | 2381741 |
| 4 | an | Andorra | 468 | 468 |
| 5 | ao | Angola | 1246700 | 1246700 |
To make a search in the database using the Full Text Search capabilities:
# display info for any country matching the search term "vatican",
# expecting to see data related to the Vatican City
factbook_search_country("vatican")
#> # A tibble: 1 x 13
#> name id code area area_land area_water population population_grow…
#> <chr> <int> <chr> <int> <int> <int> <integr64> <dbl>
#> 1 Holy… 190 vt 0 0 0 842 0
#> # … with 5 more variables: birth_rate <dbl>, death_rate <dbl>,
#> # migration_rate <dbl>, created_at <chr>, updated_at <chr>
# display info for countries that have "new" in their name:
factbook_search_country("new")
#> # A tibble: 3 x 13
#> name id code area area_land area_water population population_grow…
#> <chr> <int> <chr> <int> <int> <int> <integr64> <dbl>
#> 1 New … 126 nz<PHONE_NUMBER>10 NA 4438393 0.82
#> 2 Papu… 135 pp<PHONE_NUMBER>60 9980 6672429 1.78
#> 3 New … 211 nc 18575 18275 300 271615 1.38
#> # … with 5 more variables: birth_rate <dbl>, death_rate <dbl>,
#> # migration_rate <dbl>, created_at <chr>, updated_at <chr>
The database could have any number of tables and you only need to expose the relevant parts through the functions you provide in the package.


The Less module enables developers to access our public Less variables & mixins in their application.
Our Less module is not intended as a general-purpose library of utility mixins and variables such as LessHat.
{% highlight json %} { "dependencies": { "lasso": "^3", "lasso-less": "^3", "@ebay/skin": "^{{ page.version | slice: 0, 2 }}" } } {% endhighlight %}NOTE: This module requires the additional lasso-less plugin dependency in your app package.json.
For a full list of DS4 colour variables, please visit the archive.
{% endif %} {% if page.ds == 6 %}


{% extends "base.html" %} {% block styles%} {{ super() }} {% endblock%} {% block content %}
Personal blog site for sharing opinions.Interact with pixelog and get the latest blog posts
{{quote}}
"{{quote_author}}"


CLIENT PAUSE
is a connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds).
The command performs the following actions:
- It stops processing all the pending commands from normal and pub/sub clients. However interactions with slaves will continue normally.
- However it returns OK to the caller ASAP, so the
CLIENT PAUSE
command execution is not paused by itself. - When the specified amount of time has elapsed, all the clients are unblocked: this will trigger the processing of all the commands accumulated in the query buffer of every client during the pause.
This command is useful as it makes able to switch clients from a Redis instance to another one in a controlled way. For example during an instance upgrade the system administrator could do the following:
- Pause the clients using
CLIENT PAUSE
- Wait a few seconds to make sure the slaves processed the latest replication stream from the master.
- Turn one of the slaves into a master.
- Reconfigure clients to connect with the new master.
It is possible to send CLIENT PAUSE
in a MULTI/EXEC block together with the INFO replication
command in order to get the current master offset at the time the clients are blocked. This way it is possible to wait for a specific offset in the slave side in order to make sure all the replication stream was processed.
Return value
Simple string reply: The command returns OK or an error if the timeout is invalid.


Please provide the following information:
| Location | Number |
|---|---|
| U.S. and Canada |<PHONE_NUMBER> |
| Mexico | +01-800-874-8748 |
| Germany | +49-89-2109-3010 |
| Czech Republic | +420-22888-1645 |
| Spain | +34-51-888-9435 |
| Italy | +39-02-9475-3861 |
| France | +33-18-488-3003 |
| Poland | +48-12-881-1029 |
| UK | +44-17-5342-2417 |
| Severity | Impact |
|---|---|
| 1 | Entire FC unable to work |
| 2 | Single department down |
| 3 | Group productivity impacted |
| 4 | Individual productivity impacted |
| 5 | No impact to productivity |


DiskHandle FileGetDiskHandle( /* sets thread's error value */ FileHandle fh);
This routine returns the handle of the disk containing an open file. If unsuccessful, it sets the thread's error value (accessible via
ThreadGetError()
).
Include: file.h
word FileGetHandleExtAttributes( FileHandle fh, /* open file's handle */ FileExtendedAttribute attr, /* attribute to get */ void * buffer, /* attribute is written here */ word bufSize); /* length of buffer in bytes */
This routine gets one or more extended attributes of an open file. (To get the attributes of a file without opening it, call
FileGetPathExtAttributes()
.) If a single attribute is requested, the attribute will be written in the buffer passed. If several attributes are requested,
attr
should be set to FEA_MULTIPLE, and
buffer
should point to an array of
FileExtAttrDesc
structures. In this case,
bufSize
should be the number of structures in the buffer, not the length of the buffer.
If
FileGetHandleExtAttributes()
is successful, it returns zero. Otherwise, it returns one of the following error codes:
Tips and Tricks: Note that the only way to recover a custom attribute is by passing FEA_MULTIPLE, and using a
FileExtAttrDesc
to describe the attribute.
See Also: FileGetPathExtAttributes()
.
Include: file.h
word FileGetPathExtAttributes( const char * path, /* path relative to current * working directory */
FileExtendedAttribute attr, /* attribute to get */ void * buffer, /* attribute is written here */ word bufSize); /* length of buffer in bytes */
This routine gets one or more extended attributes of a GEOS file. If a single attribute is requested, the attribute will be written in the buffer passed. If several attributes are requested,
attr
should be set to FEA_MULTIPLE, and
buffer
should point to an array of
FileExtAttrDesc
structures. In this case,
bufSize
should be the number of structures in the buffer, not the length of the buffer.
If
FileGetPathExtAttributes()
is successful, it returns zero. Otherwise, it returns one of the following error codes:
Tips and Tricks: Note that the only way to recover a custom attribute is by passing FEA_MULTIPLE, and using a
FileExtAttrDesc
to describe the attribute.
See Also: FileGetHandleExtAttributes()
.
Include: file.h
word FileLockRecord( /* returns error */ FileHandle fh, dword filePos, /* lock starting at this position... */ dword regLength); /* lock this many bytes */
This routine puts a lock on a part of a byte file. It first checks to make sure that there are no locks that overlap the region specified; if there are, it will fail and return ERROR_ALREADY_LOCKED. If there are no locks, it will place a lock on the region specified and return zero.
Warnings: Locking a region only prevents threads from locking part of the same region; it does not prevent them from reading from or writing to the region. If applications use this mechanism, they have to make sure to call
FileLockRecord
before trying to access a part of a file.
See Also: FileUnlockRecord()
,
HandleP()
.
word FileMove( /* Returns error */ const char * source, /* source path and file name */ const char * dest, /* destination path and file name */ DiskHandle sourceDisk, /* These handles may be Standard */ DiskHandle destDisk); /* Path constants, or null to indi- * cate current working directory */
This routine moves a file from one location to another. The source and destination are specified with path strings. Each string specifies a path relative to the location specified by the corresponding disk handle. If the handle is a disk handle, the path is relative to that disk's root. If the disk handle is a standard path constant, the path string is relative to that standard path. If the disk handle is null, the path is relative to the current working directory.
If
FileMove()
is successful, it returns zero. Otherwise, it returns one of the following error codes and sets the thread's error value.
See Also: FileCopy()
.
Include: file.h


{% extends 'base.html' %} {% import 'macros.html' as macro %} {%block styles%} {{ super() }} {%endblock%} {%block content%}
Technology drives data, data catalyzes knowledge, and knowledge enables empowerment. In tomorrow’s world,.
ReadThe roll-out of 5G creates markets that we only imagine - like self-driving bots, along with a mobility-as-a-service economy - and others we can’t imagine
ReadOvernight, we’ve experienced a sharp increase in delivery services with a need for “day-of” goods from providers like Amazon and Instacart - but it has been limited. .
ReadPaper and pencil tracking, luck, significant global travel and opaque supply chains are part of today’s status quo, resulting in large amounts of wasted energy, materials and time. Accelerated in part by the long-term shutdown of international and regional travel by COVID-19, companies that design and build products
ReadIn 2025, carbon footprints will be viewed as socially unacceptable, much like drink driving is today. The COVID-19 pandemic will have focused the public’s attention .
ReadOne major application of this new kind of computer will be the simulation of complex chemical reactions, a powerful tool that opens up new avenues in drug development..
ReadGet your financial tips and keys to grow your business or to increase your financial status and grow your money
ReadThis trend will be enabled by AI-powered and systems biology-based technology that exponentially grows our knowledge of the role of specific dietary phytonutrients in specific human health and functional outcomes.
Read


See: Description
| Interface | Description |
|---|---|
| ServiceWrapper |
| Class | Description |
|---|---|
| AnnotatedMethodFilter |
TypeFilter to find classes based on annotations on
Method s. |
| AnnotatedMethodScanner | |
| AsyncCircuitBreaker | |
| CircuitBreakerBean |
This is basically a
CircuitBreaker that adds JMX
annotations to some of the methods so that the core library
doesn't have to depend on spring-context. |
| CircuitBreakerBeanFactory |
Factory to create new
CircuitBreakerBean instances and keep track of
them. |
| FlowRegulatorBean | |
| PerformanceMonitorBean |
The
PerformanceMonitorBean is a straightforward wrapper
around a PerformanceMonitor that allows for leveraging
automated exposure of the information via Spring's JMX annotations. |
| PerformanceMonitorBeanFactory |
Factory to create new
PerformanceMonitorBean instances and keep track
of the created instances. |
| PerformanceMonitorFilter |
This class is a standard Servlet filter that can be configured in web.xml to wrap all
request handling in a
PerformanceMonitor . |
| RequestCounter | |
| RequestCounterBean | |
| ServiceWrapperInterceptor |
A Spring interceptor that allows wrapping a method invocation with
a
ServiceWrapper (for example, a CircuitBreaker or
PerformanceMonitor ). |
| StatusController |
This is a convenient
Controller that can be used to implement a
"heartbeat" URL in a web application. |
If you are using the Spring framework, this package provides more convenient access to the core Jrugged functionality.
Spring interceptors are provided that allow you to easily wrap specified methods in one of the jrugged "core" ServiceWrappers. Currently CircuitBreakers and PerformanceMonitors are supported.
Copyright © 2019. All Rights Reserved.


template<class CAMERA>
class gtsam::RegularImplicitSchurFactor< CAMERA >
RegularImplicitSchurFactor.
A specialization of a GaussianFactor to structure-less SFM, which is very fast in a conjugate gradient (CG) solver. Specifically, as measured in timeSchurFactors.cpp, it stays very fast for an increasing number of cameras. The magic is in multiplyHessianAdd, which does the Hessian-vector multiply at the core of CG, and implements y += F'alpha(I - E*P*E')*F*x where
- F is the 2mx6m Jacobian of the m 2D measurements wrpt m 6DOF poses
- E is the 2mx3 Jacabian of the m 2D measurements wrpt a 3D point
- P is the covariance on the point The equation above implicitly executes the Schur complement by removing the information E*P*E' from the Hessian. It is also very fast as we do not use the full 6m*6m F matrix, but rather only it's m 6x6 diagonal blocks.
|
|
| RegularImplicitSchurFactor () |
| | Constructor.
|
| |
| | RegularImplicitSchurFactor (const KeyVector &keys, const FBlocks &Fs, const Matrix &E, const Matrix &P, const Vector &b) |
| | Construct from blocks of F, E, inv(E'*E), and RHS vector b. More...
|
| |
|
| ~RegularImplicitSchurFactor () override |
| | Destructor.
|
| |
|
const FBlocks & | Fs () const |
| |
|
const Matrix & | E () const |
| |
|
const Vector & | b () const |
| |
|
const Matrix & | getPointCovariance () const |
| |
| void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override |
| | print More...
|
| |
| bool | equals (const GaussianFactor &lf, double tol) const override |
| | equals More...
|
| |
| DenseIndex | getDim (const_iterator variable) const override |
| | Degrees of freedom of camera. More...
|
| |
| void | updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info) const override |
| | Update an information matrix by adding the information corresponding to this factor (used internally during elimination). More...
|
| |
| Matrix | augmentedJacobian () const override |
| | Return a dense \( [ \;A\;b\; ] \in \mathbb{R}^{m \times n+1} \) Jacobian matrix, augmented with b with the noise models baked into A and b. More...
|
| |
| std::pair< Matrix, Vector > | jacobian () const override |
| | Return the dense Jacobian \( A \) and right-hand-side \( b \), with the noise models baked into A and b. More...
|
| |
| Matrix | augmentedInformation () const override |
| | Compute full augmented information matrix More...
|
| |
| Matrix | information () const override |
| | Compute full information matrix More...
|
| |
| void | hessianDiagonalAdd (VectorValues &d) const override |
| | Add the diagonal of the Hessian for this factor to existing VectorValues. More...
|
| |
| void | hessianDiagonal (double *d) const override |
| | add the contribution of this factor to the diagonal of the hessian d(output) = d(input) + deltaHessianFactor More...
|
| |
| std::map< Key, Matrix > | hessianBlockDiagonal () const override |
| | Return the block diagonal of the Hessian for this factor. More...
|
| |
| GaussianFactor::shared_ptr | clone () const override |
| | Clone a factor (make a deep copy) More...
|
| |
| bool | empty () const override |
| | Test whether the factor is empty. More...
|
| |
| GaussianFactor::shared_ptr | negate () const override |
| | Construct the corresponding anti-factor to negate information stored stored in this factor. More...
|
| |
|
void | projectError2 (const Error2s &e1, Error2s &e2) const |
| | Calculate corrected error Q*(e-ZDim*b) = (I - E*P*E')*(e-ZDim*b)
|
| |
| double | error (const VectorValues &x) const override |
| | Print for testable. More...
|
| |
|
double | errorJF (const VectorValues &x) const |
| |
|
void | projectError (const Error2s &e1, Error2s &e2) const |
| | Calculate corrected error Q*e = (I - E*P*E')*e.
|
| |
| void | multiplyHessianAdd (double alpha, const double *x, double *y) const |
| | double* Hessian-vector multiply, i.e. More...
|
| |
|
void | multiplyHessianAdd (double alpha, const double *x, double *y, std::vector< size_t > keys) const |
| |
| void | multiplyHessianAdd (double alpha, const VectorValues &x, VectorValues &y) const override |
| | Hessian-vector multiply, i.e. More...
|
| |
|
void | multiplyHessianDummy (double alpha, const VectorValues &x, VectorValues &y) const |
| | Dummy version to measure overhead of key access.
|
| |
| VectorValues | gradientAtZero () const override |
| | Calculate gradient, which is -F'Q*b, see paper. More...
|
| |
| void | gradientAtZero (double *d) const override |
| | Calculate gradient, which is -F'Q*b, see paper - RAW MEMORY ACCESS. More...
|
| |
| Vector | gradient (Key key, const VectorValues &x) const override |
| | Gradient wrt a key at any values. More...
|
| |
|
VectorValues | hessianDiagonal () const |
| | Using the base method.
|
| |
| virtual void | hessianDiagonal (double *d) const=0 |
| | Using the base method. More...
|
| |
|
| GaussianFactor () |
| | Default constructor creates empty factor.
|
| |
| template<typename CONTAINER > |
| | GaussianFactor (const CONTAINER &keys) |
| | Construct from container of keys. More...
|
| |
|
virtual | ~GaussianFactor () |
| | Destructor.
|
| |
| void | print (const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override=0 |
| | print More...
|
| |
| virtual bool | equals (const GaussianFactor &lf, double tol=1e-9) const =0 |
| | Equals for testable. More...
|
| |
| virtual double | error (const VectorValues &c) const =0 |
| | Print for testable. More...
|
| |
| virtual DenseIndex | getDim (const_iterator variable) const =0 |
| | 0.5*(A*x-b)'D(A*x-b) More...
|
| |
| virtual Matrix | augmentedJacobian () const =0 |
| | Return a dense \( [ \;A\;b\; ] \in \mathbb{R}^{m \times n+1} \) Jacobian matrix, augmented with b with the noise models baked into A and b. More...
|
| |
| virtual std::pair< Matrix, Vector > | jacobian () const =0 |
| | Return the dense Jacobian \( A \) and right-hand-side \( b \), with the noise models baked into A and b. More...
|
| |
| virtual Matrix | augmentedInformation () const =0 |
| | Return the augmented information matrix represented by this GaussianFactor. More...
|
| |
| virtual Matrix | information () const =0 |
| | Return the non-augmented information matrix represented by this GaussianFactor. More...
|
| |
|
VectorValues | hessianDiagonal () const |
| | Return the diagonal of the Hessian for this factor.
|
| |
| virtual void | hessianDiagonalAdd (VectorValues &d) const =0 |
| | Add the current diagonal to a VectorValues instance. More...
|
| |
| virtual void | hessianDiagonal (double *d) const =0 |
| | Raw memory access version of hessianDiagonal. More...
|
| |
| virtual std::map< Key, Matrix > | hessianBlockDiagonal () const =0 |
| | Return the block diagonal of the Hessian for this factor. More...
|
| |
| virtual GaussianFactor::shared_ptr | clone () const =0 |
| | Clone a factor (make a deep copy) More...
|
| |
| virtual bool | empty () const =0 |
| | Test whether the factor is empty. More...
|
| |
| virtual GaussianFactor::shared_ptr | negate () const =0 |
| | Construct the corresponding anti-factor to negate information stored stored in this factor. More...
|
| |
| virtual void | updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info) const =0 |
| | Update an information matrix by adding the information corresponding to this factor (used internally during elimination). More...
|
| |
| virtual void | multiplyHessianAdd (double alpha, const VectorValues &x, VectorValues &y) const =0 |
| | y += alpha * A'*A*x More...
|
| |
| virtual VectorValues | gradientAtZero () const =0 |
| | A'*b for Jacobian, eta for Hessian. More...
|
| |
| virtual void | gradientAtZero (double *d) const =0 |
| | Raw memory access version of gradientAtZero. More...
|
| |
| virtual Vector | gradient (Key key, const VectorValues &x) const =0 |
| | Gradient wrt a key at any values. More...
|
| |
|
virtual | ~Factor ()=default |
| | Default destructor.
|
| |
| KeyVector & | keys () |
| |
|
iterator | begin () |
| | Iterator at beginning of involved variable keys.
|
| |
|
iterator | end () |
| | Iterator at end of involved variable keys.
|
| |
| virtual void | printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const |
| | print only keys More...
|
| |
|
Key | front () const |
| | First key.
|
| |
|
Key | back () const |
| | Last key.
|
| |
|
const_iterator | find (Key key) const |
| | find
|
| |
|
const KeyVector & | keys () const |
| | Access the factor's involved variable keys.
|
| |
|
const_iterator | begin () const |
| | Iterator at beginning of involved variable keys.
|
| |
|
const_iterator | end () const |
| | Iterator at end of involved variable keys.
|
| |
| size_t | size () const |
| |


Functions to estimate start and duration of moult from moult data, based on models developed in Underhill and Zucchini (1988, 1990).
| Version: | 2.1.0 |
| Imports: | Formula, Matrix |
| Published: | 2018-01-12 |
| Author: | Birgit Erni. Based on models developed by Underhill and Zucchini (1988, 1990). |
| Maintainer: | Birgit Erni <birgit.erni at uct.ac.za> |
| License: | GPL-2 |
| NeedsCompilation: | no |
| Citation: | moult citation info |
| Materials: | NEWS |
| CRAN checks: | moult results |
| Reference manual: | moult.pdf |
| Package source: | moult_2.1.0.tar.gz |
| Windows binaries: | r-devel: moult_2.1.0.zip, r-release: moult_2.1.0.zip, r-oldrel: moult_2.1.0.zip |
| OS X binaries: | r-release: moult_2.1.0.tgz, r-oldrel: moult_2.1.0.tgz |
| Old sources: | moult archive |
Please use the canonical form https://CRAN.R-project.org/package=moult to link to this page.


{{ template "header.html" . }}
Here you can adjust the CPU / memory quotas of your project. All adjustments are logged.


Sweet Free Stuff
///////////////////////////////////////////
Free Prince Alan Tea Sample
Posted: 05 Jan 2016 10:15 AM PST
http://feedproxy.google.com/&edburner&utm_medium=email
Free Prince Alan Tea Sample
The post Free Prince Alan Tea Sample appeared first on SweetFreeStuff.com.
///////////////////////////////////////////
Free Tena Sample Kit
Posted: 05 Jan 2016 04:00 AM PST
http://feedproxy.google.com/&edburner&utm_medium=email
Free Tena Sample Packs Click on Get a Free Trial Kit
The post Free Tena Sample Kit appeared first on SweetFreeStuff.com.
Commentsty by chris
///////////////////////////////////////////
Free Garnier Fructis Brazilian Smooth Haircare Sample
Posted: 05 Jan 2016 03:03 AM PST
http://feedproxy.google.com/&edburner&utm_medium=email
Free Shampoo, Conditioner, Treatment sample. Free Garnier Fructis Brazilian
Smooth Haircare Sample
The post Free Garnier Fructis Brazilian Smooth Haircare Sample appeared
first on SweetFreeStuff.com.
CommentsLooking forward to trying out these hair products! by ShellyThis
shampoo and conditioner smells good. by JulieIf one browser doesn’t work,
try another. Mess with your … by Scarywe have the same name!! LOL by
sheila (smith) christmasI can’t wait to try this. by Terry ReadPlus 14
more…
///////////////////////////////////////////
Free U by Kotex Samples
Posted: 05 Jan 2016 02:00 AM PST
http://feedproxy.google.com/&edburner&utm_medium=email
Free U by Kotex Samples
The post Free U by Kotex Samples appeared first on SweetFreeStuff.com.
CommentsLove the product and they give you so much in the sample box! by
JuliaWould love to try these out before I buy! so excited by Kylee512This
is a real good thing on free stuff before buying it. by Valerie KiesterYou
have to fill out the form just commenting wont get u a thing by SaraI
always get these samples anytime I can. I love free stuff. I … by
BeautyMomKnowsPlus 20 more…
///////////////////////////////////////////
FREE EquateTM Options Pad and Liner Sample Kit
Posted: 04 Jan 2016 09:05 PM PST
http://feedproxy.google.com/&edburner&utm_medium=email
Click on Get a Free Sample. FREE EquateTM Options Pad and Liner Sample Kit
The post FREE EquateTM Options Pad and Liner Sample Kit appeared first on
SweetFreeStuff.com.
///////////////////////////////////////////
Free 3-Piece Invata Sample Pack at Aveda
Posted: 04 Jan 2016 09:02 PM PST
http://feedproxy.google.com/&edburner&utm_medium=email
Bring this certificate to a participating location to receive a FREE Invati
sample pack including Exfoliating Shampoo, Thickening Conditioner and Scalp
Revitalizer.
The post Free 3-Piece Invata Sample Pack at Aveda appeared first on
SweetFreeStuff.com.
CommentsHi. I would LOVE to try your product, please! Always looking … by
Michele Shahar
///////////////////////////////////////////
Free Subscription to Family Fun Magazine
Posted: 04 Jan 2016 02:07 PM PST
http://feedproxy.google.com/&edburner&utm_medium=email
The post Free Subscription to Family Fun Magazine appeared first on
SweetFreeStuff.com.
CommentsBoy do i need more ideas, lol. Would just love to have this. by
minkieWould like to try! by Sandra Nettles


This is a demo project showing how to set up a database connection in an xxm project, using SQLite3.dll.
Download SQLite3.dll from www.sqlite.org.
Download SQLite.pas and SQLiteData.pas from github.com/stijnsanders/TSQLite.
Important: Some website-platforms use multiple processes to host a website.
Since this demonstration project uses a single TStringList object to store session data under the sorted SessionID's,
the processes won't be able to access eachother's session data in this case, which results in unexpected behavior.
For advanced projects it is strongly advised to use a central session object store (e.g.: a database, COM or COM+ server),
or to disable multiple processes (IIS: limit to 1 worker processes, Apache: single-process mode "-X")
SetSession(Context);
call on LoadPage, linking each request to a new or existing session.Table1
, displaying an edit and delete link for each item. It also displays an add link.
When looping over the query result, Context.Connected
is checked, allowing the visitor to abort building the page when the list gets too long.Table1
.Table1
.


{% extends "global/Page.html" %} {% load staticfiles otree %} {% block title %} Personality {% endblock %} {% block content %}
Here are a number of personality traits that may or may not apply to you. Please indicate the extent to which you agree or disagree with that statement. You should rate the extent to which the pair of traits applies to you, even if one characteristic applies more strongly than the other.
{% for field in form %} {% formfield field %} {% endfor %}


MSG_GEN_FILE_SELECTOR_GET_FILTER_ROUTINE, GenFileSelectorFilterRoutine
If the built-in search limitations do not provide the functionality you require, you can set up a callback routine that the File Selector will call for each file or subdirectory in a directory scan. This routine will serve as the final filter for each file; if a file passes all other filters, it will be subjected to your routine. This procedure adds overhead to any scan, of course, so you should try to use the built-in File Selector functions whenever possible.
To set the File Selector to use the callback functionality, you must set FSFC_FILTER_FILE in the
GFSI_fileCriteria
field. If your callback routine is written in C, you must also set FSFC_FILTER_IS_C; the routine must also follow the Pascal calling convention.
In order to take advantage of the callback functionality, you must first subclass
GenFileSelectorClass
to handle the message
MSG_GEN_FILE_SELECTOR_GET_FILTER_ROUTINE
, which the File Selector will send to itself before beginning the directory scan. Your handler should return the address of the callback routine along with a pointer to an array of attributes that will be passed to it.
The callback routine can assume that if it is being called, the file has passed all other filters--the callback is therefore the last word on acceptance or rejection of the file. In essence, the callback is asked whether the file should be rejected: It should return the constant TRUE if the file is to be rejected but FALSE if it is not to be rejected.
As mentioned above, you can designate an array of extended file attributes that will be passed to the callback routine. This array contains a number of
FileExtAttrDesc
structures, each of which defines a certain attribute and some extra data for the attribute. This structure is shown below:
typedef struct { FileExtendedAttribute FEAD_attr; /* file attribute to * get or set */ void * FEAD_value; /* pointer to a buffer * or new value */
word FEAD_size; /* size of buffer or * new value */ char * FEAD_name; /* if custom attribute, * pointer to name */ } FileExtAttrDesc;
In the above context,
FEAD_value
is meaningless and
FEAD_size
is the number of bytes required to hold the value of the attribute. Note that this array is not passed to the callback routine; instead, it specifies the structure and composition of the values that will be.
An example of filtering files using a callback routine is shown in Filtering Files Via a Callback Routine
. The
FileExtAttrDesc
structure is defined and detailed in the File System chapter.
Code Display 14-10 Filtering Files Via a Callback Routine
/******************************************************************************* * This is a sample handler for MSG_GEN_FILE_SELECTOR_GET_FILTER_ROUTINE. * You should be able to use this code in your subclass. Note that the routine * name "FilterFileSelectorRoutine" is application-specific; it can be whatever * you want. It must be declared as static Boolean, however. See below. * PARAMETERS: * void (GenFileSelectorGetFilterRoutineResults *filter) *******************************************************************************/
@method FilterFileSelectorClass, MSG_GEN_FILE_SELECTOR_GET_FILTER_ROUTINE {
/* We need to return a virtual pointer to the filter routine so the * file selector can lock and unlock the routine's code resource as * appropriate. Unfortunately, the compiler optimizes the simple * implementation (just assigning filter->filterRoutine the address of * the routine) by storing CS for the segment, which is unhelpful. So * we need a static variable holding the routine's address instead. */
static GenFileSelectorFilterRoutine *const filterRoutine = &FilterFileSelectorRoutine;
/* Specify the address of the routine to call. It need not be locked into * memory, as the GenFileSelector will do that for us. */
filter->filterRoutine = filterRoutine;
/* Specify the additional attributes we need to look at in our filter * routine. As with the filterRoutine, these need not be in fixed or * locked memory. */
filter->filterAttrs = &filterFileSelectorFilterAttrs; }
/******************************************************************************* * This is a sample File Selector callback routine. It may be called whatever * you want and must be declared static Boolean. * This routine is called once per file or directory that passes all other File * Selector filters. This routine is limited to examining the attributes of the * file. It may not do anything that could cause the File Selector's instance chunk * to move in memory. * Return: TRUE to reject the file, FALSE to accept the file. *******************************************************************************/
static Boolean FilterFileSelectorRoutine(optr oself, FileEnumCallbackData *fecd, word frame)
/* The code of the routine is not included here; to see it, look at the FSFilter * sample application. */
/* Following is the array of attributes examined by our filter routine. * This array contains an arbitrary number of elements, the last of which * has FEA_END_OF_LIST as its FEAD_attr field. FEAD_value is unused in this * context. FEAD_size is set to the total number of bytes needed for each * attribute. * Each structure's fields are FEAD_attr, FEAD_value, FEAD_size, * and FEAD_name */
const FileExtAttrDesc filterFileSelectorFilterAttrs[] = { { FEA_NAME, 0, sizeof(FileLongName), NULL }, { FEA_FILE_ATTR, 0, sizeof(FileAttrs), NULL }, { FEA_FILE_TYPE, 0, sizeof(GeosFileType), NULL }, { FEA_END_OF_LIST, 0, 0, NULL } };
void MSG_GEN_FILE_SELECTOR_GET_FILTER_ROUTINE( GenFileSelectorGetFilterRoutineResults *filter);
This message returns the address of the callback routine used by the File Selector as well as the array of
FileExtAttrDesc
structures specifying the callback's parameters.
For the callback function to be used, you must set FSFC_FILE_FILTER in the File Selector's
GFSI_fileCriteria
instance data field. If your callback routine is in C, you must also set FSFC_FILTER_IS_C. In addition, the callback routine must follow the Pascal calling convention.
Source: Sent by the File Selector object to itself before calling
FileEnum()
. Also may be used by other objects to retrieve the callback information for the File Selector.
Destination: Any GenFileSelector object.
Parameters:
filter
A pointer to an empty return value structure. This structure is detailed below.
Return: The structure pointed to by
filter
must be filled by this method.
Structures:
The single parameter is a pointer to an empty structure of type
GenFileSelectorGetFilterRoutineResults
. This structure has two parts:
filterRoutine
is a pointer to your callback routine, and
filterAttrs
is a pointer to an array of
FileExtAttrDesc
structures. You must fill in this structure in your handler so the File Selector knows how to call your callback routine. The structure is shown below:
typedef struct { GenFileSelectorFilterRoutine *filterRoutine; const FileExtAttrDesc *filterAttrs; } GenFileSelectorGetFilterRoutineResults;
Interception: If a callback routine is to be used, you must subclass and handle this message to return the proper structures.
Tips: If your callback has no requirements other than the file name, you can pass NULL in the
filterAttrs
field of
filter
.
Warnings: The handler for this message must return a virtual segment for the callback routine in
filter
's
filterRoutine
field. This can cause problems with most compilers; to avoid these problems, set a static variable in your method as shown in Filtering Files Via a Callback Routine
, below (taken from the FSFilter sample application).
See Also:
FileEnum()
Boolean GenFileSelectorFilterRoutine( optr oself, FileEnumCallbackData *fecd, word frame);
This routine is defined by your application and is called for each file in a directory scan. It may be of any name of your choice as shown in Filtering Files Via a Callback Routine
. It serves as the final filter; when called, it can assume the subject file has passed all other filters applied. This routine is set up and executed in the same manner as the callback routine for
FileEnum()
; see the File System chapterfor complete details.
Parameters:
oself
The optr of the File Selector object
fecd
FileEnumCallbackData
structure.
frame
FileEnum()
to each of its helper routines.Return: Your callback must return the constant FALSE if the file should be accepted, TRUE if the file should be rejected.
Warnings: Your routine must not do anything that may cause the File Selector or its object block to move in memory (adding variable data fields, for instance).
See Also:
FileEnum()


--- title: "SOC224 3.1 Lab 1: Installing SPSS" lastmod: 2018-05-25T00:00:00 draft: false type: docs maths: true output: blogdown::html_page: toc: true linktitle: "3.1 SPSS 1: Installing SPSS" menu: docs: parent: SOC224 weight: 310 ---
For these labs we will use the statistical package SPSS.
SPSS is one of the most widely used statistical packages in the world. It is owned by the famous company IBM.
The main advantage of SPSS is that it is user friendly - with point and click functions, like most Windows programs.
The disadvantages of SPSS are:
To install SPSS, you will need to access via iLab: (if you are a Macquarie student)
The advantage of iLab is that it is free. The disadvantage is that you need to access via the internet, and sometimes it is a bit hard to transfer files in and out of iLab.


{% extends 'engine/base.html' %}
{% load i18n %}
{% block title %}Attach Port{% endblock %}
{% block page_header %}
{# to make searchable false, just remove it from the include statement #}
{% include "steer/common/_page_header.html" with title=_("Attach Port") %}
{% endblock page_header %}
{% block dash_main %}
{% include 'engine/ports/_attach.html' with form=attach_form %}
{% endblock %}


RSS
blog.ville.oikarinen.org - Mapping thoughts to language
Mapping thoughts to language
Ville Oikarinen blogging (mostly) about programming since 2005
Another sourceforge to github migration
(2018-04-03)
I'm back
(2018-03-27)
Dependency visibility
(2011-04-29)
Automated analysis, hand-picked data
(2011-04-29)
Iteration and clicks correlation
(2011-04-19)
Architecture design as a graph layout problem
(2011-01-28)
Software architecture is human-only communication
(2011-01-26)
Why modules
(2010-09-14)
Traceability and entry points
(2010-09-09)
Walking on red carpet
(2010-05-07)
A new frog in a new kettle
(2010-04-26)
Test the zero case first
(2009-08-27)
Post-vacation cleanup
(2009-08-27)
Blueberry bonus
(2009-08-20)
Bottom-up to TDD
(2009-06-30)
If not AST, edit whole lines at least
(2009-06-30)
Nested fluent builder
(2008-12-31)
TODO test and implement
(2008-12-02)
Fluent events
(2008-10-28)
Entity, valuetype and equals
(2008-10-24)
connect-the-dots, top or bottom
(2008-10-21)
Defensive and offensive programming
(2008-06-27)
A file is a target is a property
(2008-05-21)
Comparison of UIs as languages
(2008-03-26)
Where, what and how, in that order
(2008-02-19)
Learning by overdoing
(2008-02-15)
The aesthetics of complex simplicity
(2008-02-13)
Hierarchy is not a property
(2008-02-11)
Startup scripts without a PRODUCT_HOME variable
(2008-02-05)
Subversion and the direction of merges
(2008-01-30)
Eagerly find dish machines to empty
(2008-01-30)
Race driving stories
(2007-12-03)
The art of getting rid of art
(2007-10-09)
Missing Person
(2007-10-05)
Java package hierarchy is only in the name
(2007-09-21)
My shell scripts start to get infected with meta
(2007-08-06)
Java method call performance
(2007-06-19)
Search keywords and urls as a textual user interface
(2007-05-28)
ngrease 0.1.0 released
(2007-05-02)
Optimizing the SW development algorithm
(2006-11-03)
Usage driven interface, test driven semantics
(2006-06-13)
Server-client is a deployment model, not architectural
(2006-01-04)
Splitting project to subprojects for easy dependency management
(2005-12-14)
Only different in your mind
(2005-11-24)
Coding by need
(2005-10-07)
CVS module structure for a multiproject with a main build script
(2005-08-12)
Easy testing with embedded openejb and hsql
(2005-05-03)
Multiple exit points and cyclomatic complexity
(2005-02-25)
You are what you feed your brain with
(2005-02-25)
Io is to syntaxes what a proverb is to wise thoughts
(2005-02-21)
Methods belong to objects - or do they?
(2005-02-21)
Formalize and expand
(2005-02-03)
Automation as documentation: programming machines, not humans
(2005-02-02)
First post
(2005-01-27)


Before Change
self.model.train = False
total_correct = 0
total_sum = 0
total_gold_count = 0
total_guess_count = 0
total_overlap_count = 0
metrics = {}
steps = len(ts)
conll_output = kwargs.get("conll_output", None)
txts = kwargs.get("txts", None)
handle = None
if conll_output is not None and txts is not None:
handle = open(conll_output, "w")
pg = create_progress_bar(steps)
for batch_dict in pg(ts):
lengths = batch_dict[self.model.lengths_key]
ids = batch_dict["ids"]
y = batch_dict["y"]
pred = self.model.predict(batch_dict)
correct, count, overlaps, golds, guesses = self.process_output(pred, y, lengths, ids, handle, txts)
total_correct += correct
total_sum += count
total_gold_count += golds
total_guess_count += guesses
total_overlap_count += overlaps
total_acc = total_correct / float(total_sum)
// Only show the fscore if requested
metrics["f1"] = f_score(total_overlap_count, total_gold_count, total_guess_count)
metrics["acc"] = total_acc
return metrics
@staticmethod
After Change
total_correct = 0
total_sum = 0
gold_spans = []
pred_spans = []
metrics = {}
steps = len(ts)
conll_output = kwargs.get("conll_output", None)
txts = kwargs.get("txts", None)
handle = None
if conll_output is not None and txts is not None:
handle = open(conll_output, "w")
pg = create_progress_bar(steps)
for batch_dict in pg(ts):
lengths = batch_dict[self.model.lengths_key]
ids = batch_dict["ids"]
y = batch_dict["y"]
pred = self.model.predict(batch_dict)
correct, count, golds, guesses = self.process_output(pred, y, lengths, ids, handle, txts)
total_correct += correct
total_sum += count
gold_spans.extend(golds)
pred_spans.extend(guesses)
total_acc = total_correct / float(total_sum)
metrics["acc"] = total_acc
// Only show the fscore if requested
metrics["f1"] = span_f1(gold_spans, pred_spans)
if self.verbose:
conll_metrics = per_entity_f1(gold_spans, pred_spans)
conll_metrics["acc"] = total_acc * 100
conll_metrics["tokens"] = total_sum
logger.info(conlleval_output(conll_metrics))
return metrics
@staticmethod
def _get_batchsz(y):


The Haskell Prelude is the default import into all Haskell modules, it provides an endless number of ways to shoot ourselves in the foot and historical cruft that can’t be removed. While it is difficult to fix upstream, we can however remove the Prelude entirely on a project-level and replace it with a more sensible set of defaults using the -XNoImplicitPrelude
language extension.
There are two philosophies on building new Preludes:
I don’t prescribe to the large vehicle approach, a lot of the default Prelude is not ideal but good enough to get the job done. And interoperability with the rest of the ecosystem, which typically uses default Base and Prelude, is incredibly important.
In previous posts I’ve written about how rolling our own small-vehicle Prelude is a good idea for large teams working in industry but I left it somewhat ambiguous about what to include. Obviously everyone’s company is different so I thought I’d expand on what I consider a sensible set of defaults that one could use to then build a custom Prelude. We’ll call this a Protolude.
The basic module structure is consists of a main module reexport which we’ll dump everything in called X
. And various miscellaneous functions which we’ll reexport from the root module. Off of this we’ll have several utilities modules which have domain specific functions.
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude (
module X,
identity,
bool,
(&),
uncons,
applyN,
print,
LText,
LByteString,
) where
import qualified Prelude as P
import qualified List as X
import qualified Show as X
import qualified Bool as X
import qualified Debug as X
import qualified Monad as X
import qualified Applicative as X
The Basic types (Int
, Integer
, Float
, Char
) we reexport wholesale along with their associated functions.
-- Base types
import Data.Int as X
import Data.Bits as X
import Data.Word as X
import Data.Bool as X hiding (bool)
import Data.Char as X (Char)
import Data.Maybe as X hiding (fromJust)
import Data.Either as X
import Data.Complex as X
import Data.Function as X (
id
, const
, (.)
, flip
, fix
, on
)
We define the flipped application operator for GHC < 7.10 which does not provide this be default.
(&) :: a -> (a -> b) -> b
x & f = f x
We rename the id
function to identity since it’s far more likely we’ll have variable names called id
over the identity function. This is a contentious point and your mileage may vary with this change.
identity :: a -> a
identity x = x
The bool function (the combinator analogue of maybe
and either
) is provided by GHC 7.10, but we reexport it for earlier versions.
bool :: a -> a -> Bool -> a
bool f t b = if b then t else f
The uncons
function is not provided by default, but it unpacks a list into a Maybe tuple containing the head in the first tuple parameter if it exists.
uncons :: [a] -> Maybe (a, [a])
uncons [] = Nothing
uncons (x:xs) = Just (x, xs)
The applyN
function takes a function and a count and applies it n
number of times.
applyN :: Int -> (a -> a) -> a -> a
applyN n f = X.foldr (.) id (X.replicate n f)
And then we reexport various boolean combinators for working with branching monadic logic.
whenM :: Monad m => m Bool -> m () -> m ()
whenM p m =
p >>= flip when m
unlessM :: Monad m => m Bool -> m () -> m ()
unlessM p m =
p >>= flip unless m
ifM :: Monad m => m Bool -> m a -> m a -> m a
ifM p x y = p >>= \b -> if b then x else y
guardM :: MonadPlus m => m Bool -> m ()
guardM f = guard =<< f
Safe provides Maybe versions of many of the various partial functions (head
, tail
) that are shipped by default. Wrapping it up in a Maybe is widely considered the right approach and if Haskell were designed today, they would not be present.
-- Maybe'ized version of partial functions
import Safe as X (
headMay,
initMay,
tailMay
)
Various debugging and trap commands are still provided since they are useful for partial code and various fatal program logic. However now they have a warning emitted by the compiler if they are left in place, with position information about where they are used. This can be toggled between production code and debugging code.
{-# WARNING undefined "'undefined' remains in code" #-}
undefined :: a
undefined = P.undefined
{-# WARNING error "'error' remains in code" #-}
error :: P.String -> a
error = P.error
{-# WARNING trace "'trace' remains in code" #-}
trace :: P.String -> a -> a
trace = T.trace
{-# WARNING traceShow "'traceShow' remains in code" #-}
traceShow :: P.Show a => a -> a
traceShow a = T.trace (P.show a) a
{-# WARNING traceShowM "'traceShowM' remains in code" #-}
traceShowM :: (P.Show a, P.Monad m) => a -> m ()
traceShowM a = T.traceM (P.show a)
{-# WARNING traceM "'traceM' remains in code" #-}
traceM :: P.Monad m => P.String -> m ()
traceM = T.traceM
{-# WARNING traceIO "'traceIO' remains in code" #-}
traceIO :: P.String -> P.IO ()
traceIO = T.traceIO
{-# WARNING notImplemented "'notImplemented' remains in code" #-}
notImplemented :: a
notImplemented = P.error "Not implemented"
Various either combinators to convert between Maybe and Either probably should be provided but are not, there are four various combinations of these.   Variants like mapM
are provided by Data.Traversable
instead of Control.Monad
.
module Monad (
Monad(..)
, MonadPlus(..)
, (=<<)
, (>=>)
, (<=<)
, forever
, join
, mfilter
, filterM
, mapAndUnzipM
, zipWithM
, zipWithM_
, foldM
, foldM_
, replicateM
, replicateM_
, concatMapM
, guard
, when
, unless
, liftM
, liftM2
, liftM3
, liftM4
, liftM5
, liftM'
, liftM2'
, ap
, (<$!>)
) where
import Prelude (concat, seq)
import Control.Monad
concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
concatMapM f xs = liftM concat (mapM f xs)
Strict versions of liftM
are also provided by default since this is a common source of unexpected laziness.
liftM' :: Monad m => (a -> b) -> m a -> m b
liftM' = (<$!>)
{-# INLINE liftM' #-}
liftM2' :: (Monad m) => (a -> b -> c) -> m a -> m b -> m c
liftM2' f a b = do
x <- a
y <- b
let z = f x y
z `seq` return z
{-# INLINE liftM2' #-}
The applicative module core types are reexported wholesale. Unlike in 7.8 we have the Applicative class in scope by default, as it should be in this day and age.
-- Applicatives
import Control.Applicative as X (
Applicative(..)
, Alternative(..)
, Const(..)
, ZipList(..)
, (<**>)
, liftA
, liftA2
, liftA3
, optional
)
The core GHC typeclasses for ordering and numeric tower are reexported wholesale. We also bring Traversable and Foldable into scope masking a few of the partial functions which generally should be avoided. Semiring is also common enough these days that it should be in scope implicitly.
-- Base typeclasses
import Data.Eq as X
import Data.Ord as X
import Data.Monoid as X
import Data.Traversable as X
import Data.Foldable as X hiding (
foldr1
, foldl1
, maximum
, maximumBy
, minimum
, minimumBy
)
import Data.Semiring as X
import Data.Functor.Identity as X
import Data.Functor as X (
Functor(..)
, ($>)
, (<$>)
, void
)
Deepseq is usually an important typeclass to derive for various usecases, and so we bring in the deepseq
library and it’s various functions.
-- Deepseq
import Control.DeepSeq as X (
NFData(..)
, ($!!)
, deepseq
, force
)
The core data structures provided by GHC are reexported, but with List we make sure to mask the partial functions, and operators are provided in more general interfaces.
-- Data structures
import Data.Tuple as X
import Data.List as X (
splitAt
, break
, intercalate
, isPrefixOf
, drop
, filter
, reverse
, replicate
)
The containers library all provide functions which overlap with each other (lookup, insert, etc) so we just export the types for these structures so we can use them in signatures. On a module level these would then be typically imported using a qualified import like import qualified Data.Map as Map
.
import Data.Map as X (Map)
import Data.Set as X (Set)
import Data.Sequence as X (Seq)
import Data.IntMap as X (IntMap)
import Data.IntSet as X (IntSet)
The basic mtl
transformer stack are usually ubiqitious in modern Haskell, specifically StateT, ReaderT and ExceptT. We don’t export all functions in these modules but just enough that most uses cases of the common transformers are brought into scope.
-- Monad transformers
import Control.Monad.State as X (
MonadState,
State,
StateT,
put,
get,
gets,
modify,
withState,
runStateT,
execStateT,
evalStateT,
)
import Control.Monad.Reader as X (
MonadReader,
Reader,
ReaderT,
ask,
asks,
local,
runReader,
runReaderT,
)
import Control.Monad.Except as X (
MonadError,
Except,
ExceptT,
throwError,
catchError,
runExcept,
runExceptT,
)
import Control.Monad.Trans as X (
MonadIO,
lift,
liftIO,
)
Several basic types (IO, Show) are necessary to do anything so we obviously bring these in. The Exts
provides the various pointer types for working with FFI as well as the Constraint type which is somewhat common in the presence of -XConstraintKinds
and more advanced type family techniques.
-- Base GHC types
import GHC.IO as X (IO)
import GHC.Num as X
import GHC.Real as X
import GHC.Float as X
import GHC.Show as X
import GHC.Exts as X (
Constraint
, Ptr
, FunPtr
, the
)
Generics are also ubiqitious in modern Haskell and the various typeclasses and type synonyms should be provided so that we can -XDeriveGeneric
as well as implement default instances for Generic classes.
-- Generics
import GHC.Generics (
Generic(..)
, Rep
, K1(..)
, M1(..)
, U1(..)
, V1
, D1
, C1
, S1
, (:+:)
, (:*:)
, NoSelector
, Rec0
, Par0
, Constructor(..)
, Selector(..)
, Arity(..)
, Fixity(..)
)
Strings in Haskell are a giant fractal of suffering. In a just world, we would all just use Text most of the time, and ByteString when we needed to deal with network but we don’t live in that world an large portions of Hasell ecosystem still use the wildly-inefficient linked-list of Char.
Controversially we just reexport the Lazy text type as a type synonym LText
and provide the string-conv
library function toS
which automatically converts between any two string types using a multiparam typeclass. String heavy programs might also consider reexporting the various Text and ByteString builder classes.
-- ByteString
import qualified Data.ByteString.Lazy
import qualified Data.ByteString as X (ByteString)
-- Text
import Data.Text as X (Text)
import qualified Data.Text.Lazy
import qualified Data.Text.IO
import Text.Printf as X (printf)
import Data.Text.Lazy (
toStrict
, fromStrict
)
import Data.String.Conv as X (
strConv
, toS
, toSL
, Leniency(..)
)
-- Printf
import Text.Printf as Exports (
PrintfArg
, printf
, hPrintf
)
type LText = Data.Text.Lazy.Text
type LByteString = Data.ByteString.Lazy.ByteString
IO is essentially obvious, so we reexport the various IO operations and command low-level command line option and file handler functions.
-- IO
import System.Exit as X
import System.Environment as X (getArgs)
import System.IO as X (
Handle
, hClose
)
In a just world we’d have a generic putStr
that didn’t require us to put boilerplate imports in every damn module just to print a string, but alas we don’t live in that world. But we can implement a basic class to do this for the common text representation and then just export the class instead of the four libraries that all provide the same interface.
class Print a where
putStr :: MonadIO m => a -> m ()
putStrLn :: MonadIO m => a -> m ()
instance Print T.Text where
putStr = liftIO . T.putStr
putStrLn = liftIO . T.putStrLn
instance Print TL.Text where
putStr = liftIO . TL.putStr
putStrLn = liftIO . TL.putStrLn
instance Print BS.ByteString where
putStr = liftIO . BS.putStr
putStrLn = liftIO . BS.putStrLn
instance Print BL.ByteString where
putStr = liftIO . BL.putStr
putStrLn = liftIO . BL.putStrLn
instance Print [Char] where
putStr = liftIO . Prelude.putStr
putStrLn = liftIO . Prelude.putStrLn
-- For forcing type inference
putText :: MonadIO m => T.Text -> m ()
putText = putStrLn
{-# SPECIALIZE putText :: T.Text -> IO () #-}
putLText :: MonadIO m => TL.Text -> m ()
putLText = putStrLn
{-# SPECIALIZE putLText :: TL.Text -> IO () #-}
Like the functions above we automatically lift print and the various string IO operations into a generic MonadIO
instance so we can embed them in transformer stacks.
print :: (X.MonadIO m, P.Show a) => a -> m ()
print = liftIO . P.print
The basic thread primitives are common enough that they should be brought into scope implicitly. The async
library provides the preferred method of interacting with concurrent logic and so we export this wholesale as well.
-- ST
import Control.Monad.ST as ST
-- Concurrency and Parallelism
import Control.Exception as X
import Control.Concurrent as X
import Control.Concurrent.Async as X
Now in our cabal file we can just add:
default-extensions:
NoImplicitPrelude
And then include your sensible Prelude in your modules. You can escape hatch out of this choice on a module-by-module basis by just pulling in Prelude explicitly using import Prelude
.
So that’s the basic proto-prelude I use for my large multi-cabal-file projects. Your mileage by vary on some of these choices, but I consider this a pretty sensible and practical foundational set of functions and types that should at least provide a good starting point.


Marchocs
Thank your top customers in an enjoyable and memorable way and impress your best prospects so they’ll view you in a favourable light with a mailable box of luxury chocolates that can be fully personalised with your targets’ details and a relevant message.
A minimum order quantity is not required, but we do offer discounts on larger orders. For more information and/or to request a sample, call Tim Lance on 01753 215325 or email<EMAIL_ADDRESS>P.S. The question “Why do we love chocolate?” was asked of Paul A. Young (Master Chocolatier) on a programme broadcast on BBC Two. He answered:
“It makes us really happy.
This marketing tool supports our main business objective – helping our customers maximise their investment when they buy from us.


{% extends "emails/base.html" %}
{% load humanize hc_extras %}
{% block content %}
Hello,
This is a
{% if nag_period == 3600 %}hourly{% endif %}
{% if nag_period == 86400 %}daily{% endif %}
reminder sent by {% site_name %}.
{% if num_down == 1%}
One check is currently DOWN:
{% else %}
{{ num_down }} checks are currently DOWN:
{% endif %}
{% include "emails/nag-summary-html.html" %}
Too many notifications?
Visit the Email Reports
page on {% site_name %} to set your notification preferences.
Cheers,
The {% site_name %} Team
{% endblock %}
{% block unsub %}
Unsubscribe
{% endblock %}


了解更多，扫一扫，关注我！
郝惠如，年龄20岁，出生于山西省临汾市，生日4月18日，爱好有好多，擅长于H5开发，就读于北京网络职业学院,想成为一名全栈工程师。
Hao huiru, aged 20, was born in linfen city, Shanxi Province on April 18. She has many hobbies and is good at H5 development. She studies in Beijing network vocational college and wants to be a full stack engineer after graduation.
House-3 Road-2, Akhalia Ghate R/A, Sylhet
Call: 17635****42
E-mail<EMAIL_ADDRESS>Web: www.themewagon.com


|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.pmd.cpd.cppast.Scope net.sourceforge.pmd.cpd.cppast.ClassScope
Class scope extends Scope in that its search method also searches all its superclasses.
| Constructor Summary | |
ClassScope(java.lang.String name,
Scope parent)
Creates a new class scope in a given scope. |
| Method Summary | |
void |
AddSuper(Scope sc)
Add a super class. |
boolean |
IsTypeName(java.lang.String name)
Overrides the method in Scope. |
| Methods inherited from class net.sourceforge.pmd.cpd.cppast.Scope |
GetScope, PutTypeName, PutTypeName |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ClassScope(java.lang.String name, Scope parent)
| Method Detail |
public void AddSuper(Scope sc)
public boolean IsTypeName(java.lang.String name)
IsTypeName
in class Scope
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


TRANSFORMVECTOR3D transform a vector with a 3D affine transform V2 = transformVector3d(V1, TRANS); Computes the vector obtained by transforming vector V1 with affine transform TRANS. V1 has the form [x1 y1 z1], and TRANS is a [3x3], [3x4], or [4x4] matrix, with one of the forms: [a b c] , [a b c j] , or [a b c j] [d e f] [d e f k] [d e f k] [g h i] [g h i l] [g h i l] [0 0 0 1] V2 = transformVector3d(V1, TRANS); Also works when V1 is a [Nx3] array of double. In this case, V2 has the same size as V1. V2 = transformVector3d(X1, Y1, Z1, TRANS); Specifies vectors coordinates in three arrays with same size. [X2 Y2 Z2] = transformVector3d(...); Returns the coordinates of the transformed vector separately. See also: vectors3d, transforms3d, transformPoint3d --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 25/11/2008 from transformPoint3d


Toggle navigation
Problem 1.1
Dashboard
Portfolio
Blog
SignUp
Register
Timeline
Forms
Typography
Bootstrap Elements
Bootstrap Grid
Messages
2
2 New Messages
Security alert
Security alert
Go to Inbox
2
Steve Miller
Profile
Settings
Log Out
Inputs
Ke
Number of cells.
T0
Initial time.
Spread
Pulse spread.
nsteps
Number of steps.
Calculate!
Visits Based on a 10 days data


Train Time
Chuga Chug Choo Choo!
Current Train Schedule
Train Name
Destination
Frequency (min)
Next Arrival
Minutes Away
Add Train
Train Name
Destination
First Train Time (HH:mm - military time)
Frequency (min)
Submit


Rules: any number divisible by 3 will be changed to ping, any number divisible by 5 will be changed to pong, any number divisible by both will be changed to pingpong


Comp 305 Lab 1copyright.h | /home/lido1/petriedavi/305Comp/project2/nachos/html/
Fri Apr 4 12:09:11 NZDT 2008 |
/* Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved. Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without written agreement is hereby granted, provided that the above copyright notice and the following two paragraphs appear in all copies of this software. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ #ifdef MAIN /* include the copyright message in every executable */ static char *copyright = "Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved."; #endif // MAIN


My good friend X used to tweak a lot. She loves crystal, but for her it is special enough that she only does it occasionally now when she feels it is well deserved. Me and her were going to a two day music festival on the weekend, so she purchased a $60 bag of the white powder for herself with the promise that I could try some.
She picked me up early Saturday morning. She had already shot up at her house. I was scared about what I knew I would be doing that day, but curious and excited at the same time. But I didn't have much time to organize my thoughts. Five minutes later she handed me a pen top with the crystal lined up on the flat part--one bump. I became extremely scared at the prospect of what I was about to do.  But I was brave and I snorted it. Seeing as how I was not dead, my fear vanished and was replaced by excited anticipation, and ten minutes later, I bumped again.
I started to feel the drip about ten minutes later. It was nasty, very foul, and harsh. But I welcomed it because I knew it meant the drug would be taking effect. However, because it was my first time tweaking and I did not pay for the drug, I only bumped once more that day about six hours later in the afternoon. So I actually did not do very much crystal, and the effects were pretty much negligible. But the experience was unique, and I would like to focuss on the few effects that I did notice despite the low dose. It should be noted that throughout the day I smoked a couple of joints and several bowls, probably amounting to at least a dime-sized bag of weed by the end of the day.
 I felt better afterwards though. As we walked towards the place where the festival was being held, I kept seeing a black dot in the far right field of my vision. But when I would turn my head, nothing would be there. I kept wanting to feel the wonderful effects that X had told me about--the incessant talking, the euphoria, the desire to work, etc. But I hadn't taken enough of the drug. I kept saying 'I don't feel anything' and X would tell me that was because I wasn't doing anything. We were just sitting listening to the music, chillin with other people, smokin joints. But if I thought about it, I could slightly feel the threshold effects of the crystal. There are two instances that especially stand out in my mind.
1) We were high in the stands of the stadium. As I looked down at the thousands of people in the field, I started to play a little game with my eyes. The colors already seemed more intense than usual. I would say in my mind 'I want to see red' and all the people wearing red shirts in that crowd of thousands would suddenly stand out. 'I want to see blue' and my eyes would only focus on those who were wearing blue shirts. It was strange but entertaining. I must have played that game for at least 15 minutes.
2) My friend X had brought some ecstacy pills to try to get rid of.  I asked if I could help--for some reason I really wanted to make one of those signs. X had shown me her notebooks that she had filled when she was tweaking. They were full of dark black spotches where she had crossed things out by totally blackening them in. She said that's what she does when she is tweaking. Well that's what I did. I drew the outline of a lowercase 'e' and I started coloring it in as if that was my sole purpose in life. It was strangely satisfying. I must have blackened in that e for at least half an hour, maybe even an hour. I colored so hard that the paper curled and tore. She didn't even use my little sign. But I didn't care--I had so much fun making it. I felt so accomplished and useful.
In conclusion, I would say that at least for myself, three bumps is not enough to fully feel the effects of crystal. But I think it was sufficient for my first time tweaking since I was so scared. Now that my fear is gone, I feel I can later have a stronger experience. Mild intoxication was pleasant, but I am excited to discover what all the fuss about crystal is all about. But please, everyone be careful. Crystal addiction is hard to kick--I've heard the stories firsthand.
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.


 Our main aim to
operate this foundation only to save thousands life of stray dogs ,who are daily loosing their life
due to an accident ,lack of food or by any other reasons.
As we all know that,out of all animal present on earth the dogs are the most loyal animal.
It's just not a content of dogs problem but it is to make you realise in what condition dogs are
living.Those dogs are dependent on human for their needs like shelter,food and rags during
winter etc.Just look around your society and try to show humanity to these helpless animals.
One day one of our founder saw a dog ,which was at his last stage ,he was helpless and finally died
with his pain and problem.This incident shook (founder)from inside.Instantly he informed all of us
and induces us to take action for dogs .And finally we all established this foundation.
We know ,we can not save all lives but for few we can guaranteed.Our one step ahead could save many
life.
Our team kindly request you all ,any type of your help for dog can bring joy and happiness in their
life,moreover it will maintain their community.You can help them by providing them you left over
food,yours rugs for them will be proven beneficial in many ways during winter or
By taking help of our volunteers you can also do financial help to our team by pressing DONATE BUTTON.
As of all our volunteers are students ,the only source of income is our pocket money .We all contribute
from our pocket money and we provide more than 50 kg of food every month for their life and
happiness.
We should also accept that they have their family ,emotion and happiness.
THANK YOU ;)


matrix
property of a Transform object, and then applying that Transform object as
the transform
property of the display object. These
transformation functions include translation(x and y
repositioning), rotation, scaling, and skewing.
Together these types of transformations are known as affine transformations. Affine transformations preserve the straightness of lines while transforming, so that parallel lines stay parallel.
To apply a transformation matrix to a display object, you create a
Transform object, set its matrix
property to the
transformation matrix, and then set the transform
property of
the display object to the Transform object. Matrix objects are also used as
parameters of some methods, such as the following:
draw()
method of a BitmapData objectbeginBitmapFill()
method,
beginGradientFill()
method, or
lineGradientStyle()
method of a Graphics objectA transformation matrix object is a 3 x 3 matrix with the following contents:
In traditional transformation matrixes, the u
,
v
, and w
properties provide extra capabilities.
The Matrix class can only operate in two-dimensional space, so it always
assumes that the property values u
and v
are 0.0,
and that the property value w
is 1.0. The effective values of
the matrix are as follows:
You can get and set the values of all six of the other properties in a
Matrix object: a
, b
, c
,
d
, tx
, and ty
.
The Matrix class supports the four major types of transformations: translation, scaling, rotation, and skewing. You can set three of these transformations by using specialized methods, as described in the following table:
Each transformation function alters the current matrix properties so
that you can effectively combine multiple transformations. To do this, you
call more than one transformation function before applying the matrix to
its display object target(by using the transform
property of
that display object).
Use the new Matrix()
constructor to create a Matrix object
before you can call the methods of the Matrix object.
a
The value that affects the positioning of pixels along the x axis when scaling or rotating an image.b
The value that affects the positioning of pixels along the y axis when rotating or skewing an image.c
The value that affects the positioning of pixels along the x axis when rotating or skewing an image.d
The value that affects the positioning of pixels along the y axis when scaling or rotating an image..tx
The distance by which to translate each point along the x axis.ty
The distance by which to translate each point along the y axis.m
The matrix to be concatenated to the source matrix.For example, if matrix m1
scales an object by a factor of
four, and matrix m2
rotates an object by 1.5707963267949
radians(Math.PI/2
), then m1.concat(m2)
transforms m1
into a matrix that scales an object by a factor
of four and rotates the object by Math.PI/2
radians.
This method replaces the source matrix with the concatenated matrix. If
you want to concatenate two matrixes without altering either of the two
source matrixes, first copy the source matrix by using the
clone()
method, as shown in the Class Examples section.
scaleX
The factor by which to scale horizontally.scaleY
The factor by which scale vertically.rotation
The amount to rotate, in radians.tx
The number of pixels to translate(move) to the right along the x axis.ty
The number of pixels to translate(move) down along the y axis.Using the createBox()
method lets you obtain the same
matrix as you would if you applied the identity()
,
rotate()
, scale()
, and translate()
methods in succession. For example, mat1.createBox(2,2,Math.PI/4,
100, 100)
has the same effect as the following:
width
The width of the gradient box.height
The height of the gradient box.rotation
The amount to rotate, in radians.tx
The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width
parameter.ty
The distance, in pixels, to translate down along the y axis. This value is offset by half of the height
parameter.beginGradientFill()
and lineGradientStyle()
methods of the Graphics class. Width and height are scaled to a
scaleX
/scaleY
pair and the
tx
/ty
values are offset by half the width and
height.
For example, consider a gradient with the following characteristics:
GradientType.LINEAR
0,
255
SpreadMethod.PAD
InterpolationMethod.LINEAR_RGB
The following illustrations show gradients in which the matrix was
defined using the createGradientBox()
method with different
parameter settings:
point
The point for which you want to get the result of the matrix transformation.transformPoint()
method, the deltaTransformPoint()
method's transformation
does not consider the translation parameters tx
and
ty
.
After calling the identity()
method, the resulting matrix
has the following properties: a
=1, b
=0,
c
=0, d
=1, tx
=0,
ty
=0.
In matrix notation, the identity matrix looks like this:
angle
The rotation angle in radians.The rotate()
method alters the a
,
b
, c
, and d
properties of the
Matrix object. In matrix notation, this is the same as concatenating the
current matrix with the following:
sx
A multiplier used to scale the object along the x axis.sy
A multiplier used to scale the object along the y axis.sx
, and the y axis it is multiplied by
sy
.
The scale()
method alters the a
and
d
properties of the Matrix object. In matrix notation, this
is the same as concatenating the current matrix with the following
matrix:
a
, b
, c
, d
, tx
, and ty
.point
The point for which you want to get the result of the Matrix transformation.
If you do not provide any parameters to the
new Matrix()
constructor, it creates an identity matrix with the following values:In matrix notation, the identity matrix looks like this:


--- title: "Optimisation of a Poisson survival model using Optimx in R" author: "Joshua Philipp Entrop" date: '2020-07-22' output: html_document categories: [Optimisation, R] tags: [R, survival analysis, manual optimisation] draft: FALSE ---
In this blog post, we will fit a Poisson regression model by maximising its likelihood function using optimx() in R. As an example we will use the lung cancer data set included in the {survival} package. The data set includes information on 228 lung cancer patients from the North Central Cancer Treatment Group (NCCTG). Specifically, we will estimate the survival of lung cancer patients by sex and age using a simple Poisson regression model. You can download the code that I will use throughout post here. The general survival function \(S(t)\) for our model can be specified as
\[ S(t) = \exp(-\lambda t) \]
where the hazard function \(h(t)\) is equal to
\[ h(t) = \lambda = \exp(\alpha + \beta_1 x_{female} + \beta_2 x_{age}). \] To get started we first need to load all the packages that we will need for our estimations and set up the data set.
# 1. Prefix -------------------------------------------------------------------
# Remove all files from ls
rm(list = ls())
# Loading packages
require(survival)
require(flexsurv)
require(optimx)
require(numDeriv)
require(dplyr)
require(tibble)
require(car)
# 2. Loading dataset ----------------------------------------------------------
#Reading the example data set lung from the survival package
lung <- as.data.frame(survival::lung)
#Recode dichotomous vairables
lung$female <- ifelse(lung$sex == 2, 1, 0)
lung$status_n <- ifelse(lung$status == 2, 1, 0)
At this point we would usually call survreg() or flexsurvreg() to fit our Possion model. However, in this post we will use the likelihood function of our Possion regression model together with optimx() from the {optimx} package instead. For this we first need to find the likelihood function for our model and then use optimx() to find the values for our parameters, that maximise our likelihood function.
The log likelihood (\(\ln L_i\)) for a survival model can be specified as
\[ \ln L_i = d_i \ln h(t_i) + \ln S(t_i). \] Where \(d_i\) indicates whether the \(i^{th}\) subject experienced an event (1) or did not experience an event (0) during follow up and \(t_i\) is the time from the beginning of follow up until censoring.
To obtain the log likelihood function for our Possion model we can substitute \(h(t)\) and \(S(t)\) with our previously defined hazard and survival function respectively. Thus, we get the following equation for our log likelihood
\[\ln L_i = d_i \ln \lambda - \lambda t_i \]
where \(\lambda\) is defined as mentioned above.
The next step is now to write our likelihood function as a function in R, which can be maximised by optimx(). Please keep in mind, that optimx() by default minimises the function we pass to it. However, in our case we need to find the maximum of our likelihood function. To yield the estimates, that maximise our function we can just ask optimx() to minimise the negative of our likelihood. For more information on setting up the likelihood function for optimx() or optim() please take a look at this earlier blog post.
Lets set up our likelihood function in R.
# 3. Define log-likelihood function for Poisson regression model --------------
negll <- function(par){
#Extract guesses for alpha, beta1 and beta2
alpha <- par[1]
beta1 <- par[2]
beta2 <- par[3]
#Define dependent and independent variables
t <- lung$time
d <- lung$status_n
x1 <- lung$female
x2 <- lung$age
#Calculate lambda
lambda <- exp(alpha + beta1 * x1 + beta2 * x2)
#Estimate negetive log likelihood value
val <- -sum(d * log(lambda) - lambda * t)
return(val)
}
To improve the optimisation we can further pass the gradient function of our likelihood function to our optimx() call. After partially deriving \(L_i\) for \(\alpha\) and \(\beta_i\) we yield the two following equations for the gradient of \(L_i\).
\[ \sum d_i - \lambda_i t_i = 0\]
\[ \sum d_i x_{ij} - \lambda_i x_{ij} t = 0\]
Given these gradient equations we can now define our gradient function in R. For this we need to create a function, that returns the gradient for each of our unknown parameters. Since we have three unknown parameters our gradient function will return a vector gg with three values.
# 4. Define gradient function for Poisson regression model -------------------
negll.grad <- function(par){
#Extract guesses for alpha and beta1
alpha <- par[1]
beta1 <- par[2]
beta2 <- par[3]
#Define dependent and independent variables
t <- lung$time
d <- lung$status_n
x1 <- lung$female
x2 <- lung$age
#Create output vector
n <- length(par[1])
gg <- as.vector(rep(0, n))
#Calculate pi and xb
lambda <- exp(alpha + beta1 * x1 + beta2 * x2)
#Calculate gradients for alpha and beta1
gg[1] <- -sum(d - lambda * t)
gg[2] <- -sum(d * x1 - lambda * x1 * t)
gg[3] <- -sum(d * x2 - lambda * x2 * t)
return(gg)
}
We can compare the results of our gradient function with the results from the grad() function included in the {numDeriv} package, before we begin with the optimisation of our functions. This is just a check to be sure our gradient function works properly.
# 4.1 Compare gradient function with numeric approximation of gradient ========
# compare gradient at 0, 0, 0
mygrad <- negll.grad(c(0, 0, 0))
numgrad <- grad(x = c(0, 0, 0), func = negll)
all.equal(mygrad, numgrad)
## [1] TRUE
Looks like our gradient functions does a good job. Now that we have all the functions and information we need for our optimisation, we can call optimx() and pass our functions to it.
The output of optimx() provides us with estimates for our coefficients and information regarding whether the optimisation algorithm converged (convcode == 0) besides the maximum value of the negative log likelihood obtained by the different algorithms. Hence, it is useful to sort the results by convcode and value.
# 5. Find maximum of log-likelihood function ----------------------------------
# Passing names to the values in the par vector improves readability of results
opt <- optimx(par = c(alpha = 0, beta_female = 0, beta_age = 0),
fn = negll,
gr = negll.grad,
hessian = TRUE,
control = list(trace = 0, all.methods = TRUE))
# Show results for optimisation alogrithms, that convergered (convcode == 0)
summary(opt, order = "value") %>%
rownames_to_column("algorithm") %>%
filter(convcode == 0) %>%
select(algorithm, alpha, beta_female, beta_age, value)
## algorithm alpha beta_female beta_age value
## 1 nlminb -6.840606 -0.4809343 0.01561870 1156.099
## 2 BFGS -6.840627 -0.4809436 0.01561907 1156.099
## 3 L-BFGS-B -6.840636 -0.4809316 0.01561902 1156.099
## 4 Nelder-Mead -6.832428 -0.4814582 0.01547911 1156.099
The summary of our optimx() call shows, that the nlminb algorithm yielded the best result. Lets see if this result is equal to the results we will get, if we use flexsurvreg from the {flexsurv} package to fit our desired model.
# 6. Estimate regression coeficents using flexsurvreg -------------------------
pois_model <- flexsurvreg(Surv(time, status_n == 1) ~ female + age,
data = lung,
dist = "exp")
# 7. Comparing results from optimx and flexsurvreg ----------------------------
pois_results <- unname(coef(pois_model))
coef_opt <- coef(opt)
lapply(1:nrow(coef_opt), function(i){
opt_name <- attributes(coef_opt)$dimnames[[1]][i]
mle_pois1 <- (coef_opt[i, 1] - pois_results[1])
mle_pois2 <- (coef_opt[i, 2] - pois_results[2])
mle_pois3 <- (coef_opt[i, 3] - pois_results[3])
mean_dif <- mean(mle_pois1, mle_pois2, mle_pois3, na.rm = TRUE)
data.frame(opt_name, mean_dif)
}) %>%
bind_rows() %>%
filter(!is.na(mean_dif)) %>%
mutate(mean_dif = abs(mean_dif)) %>%
arrange(mean_dif)
## opt_name mean_dif
## 1 nlminb 2.678650e-07
## 2 BFGS 2.091779e-05
## 3 L-BFGS-B 2.911668e-05
## 4 Nelder-Mead 8.178948e-03
## 5 CG 6.816256e+00
## 6 Rvmmin 6.840606e+00
The mean difference between our estimates and the estimates obtained by using flexsurvreg() are close to zero. Seems like our optimisation using the log likelihood did a good job.
However, the result obtained with flexsurvreg() provided us with estimates for the standard errors (SEs) of our hazard estimates, too. Since the measurement of uncertainty is at the heart of statistics, I think it is worthwhile to obtain the SEs for our estimates with the information provided by our optimx() call. For a more detailed discussion on how this is done please take a look at one of my previous blog posts here.
Let’s obtain the SEs for our model by using the results from our optimx() call and compare them with the SEs obtained by flexsurvreg().
# 8. Estimate the standard error ----------------------------------------------
#Extract hessian matrix for nlminb optimisation
hessian_m <- attributes(opt)$details["nlminb", "nhatend"][[1]]
# Estimate SE based on hession matrix
fisher_info <- solve(hessian_m)
prop_se <- sqrt(diag(fisher_info))
# Compare the estimated SE from our model with the one from the flexsurv model
# Note use res.t to get the estimates on the reale scale without transformaiton
ses <- data.frame(se_nlminb = prop_se,
se_felxsurvreg = pois_model$res.t[, "se"]) %>%
print()
## se_nlminb se_felxsurvreg
## rate 0.587477415 0.587136471
## female 0.167094278 0.167094285
## age 0.009105681 0.009097022
all.equal(ses[, "se_nlminb"], ses[, "se_felxsurvreg"])
## [1] "Mean relative difference: 0.000457798"
Looks like we got nearly equal results. Let us use these information and estimate the 95% confidence intervals (CIs) for our estimates now.
# 9. Estimate 95%CIs using estimation of SE -----------------------------------
# Extracting estimates from nlminb optimisaiton
coef_test <- coef(opt)["nlminb",]
# Compute 95%CIs
upper <- coef_test + 1.96 * prop_se
lower <- coef_test - 1.96 * prop_se
# Print 95%CIs
data.frame(Estimate = coef_test,
CI_lower = lower,
CI_upper = upper,
se = prop_se)
## Estimate CI_lower CI_upper se
## alpha -6.8406062 -7.992061931 -5.68915046 0.587477415
## beta_female -0.4809343 -0.808439062 -0.15342949 0.167094278
## beta_age 0.0156187 -0.002228433 0.03346584 0.009105681
One usual way to plot the results of our estimation is plotting the survival function \(S(t)\). Since, uncertainty is important I also want to plot the CI for our survival function. To obtain estimates for the SE of the survival function \(S(t)\) is a little bit more complicated. However, the amazing deltaMethod() function included in the {car} package makes it fairly easy to obtain estimates for the SEs. We just need to provide deltaMethod() with a vector of our coefficients, our covariance matrix and the computation for which we would like to obtain the SEs.
# 10. Plot survival curve with 95%-CI -----------------------------------------
# 10.1 Use Delta Method to compute CIs across time of follow-up ===============
# Get coefficents for nlminb optimisation
nlminb_coef <- coef(opt)["nlminb", ]
# Compute CIs for a 60 year old female across follow-up time
surv_optim_female <- lapply(as.list(seq(0.01, 1000.01, 10)), function(t){
g <- paste("exp(-exp(alpha + beta_female + 60 * beta_age) *", t, ")")
fit <- deltaMethod(nlminb_coef, g, solve(hessian_m))
data.frame(time = t,
estimate = fit[, "Estimate"],
ci_low = fit[, "2.5 %"],
ci_up = fit[, "97.5 %"])
}) %>%
bind_rows()
We can now use these information to plot our survival curve \(S(t)\) together with a grey shaded area that indicates the CIs for our survival function.
# 10.2 Plot survival curve with CIs ===========================================
plot(surv_optim_female$time,
surv_optim_female$estimate,
ylim = c(0, 1),
type = "n",
xlab = "Time in Days",
ylab = "S(t)",
main = "Survival after lung cancer \n for 60 year old females")
polygon(c(surv_optim_female$time, rev(surv_optim_female$time)),
c(surv_optim_female$ci_low, rev(surv_optim_female$ci_up)),
border = NA,
col = "grey")
lines(surv_optim_female$time,
surv_optim_female$estimate)
legend(0, 0.15,
fill = "grey",
"95% CI")
To sum it up, in this blog post we learned how to fit a Possion regression model using the log likelihood function in R instead of going the usual way of calling survreg() or flexsurvreg(). I think doing this is a good way of gaining a deeper understanding of how estimates for regression models are obtained. In my next post I will take this a step further and show how we can fit a Weibull regression model in R using the log likelihood function in combination with optimx().


Hardware Designing and Verification of Three-Phase to Sequence Decomposer
- Tech Stack: Verilog, Embedded Systems, Signal Processing
- Github URL: Project Link | Publication
The objective of this project is to develop a hardware model of 3-Phase to sequence converter. It will be useful in relaying circuits for faster action on any faults. The model will be implemented on a FPGA board using Verilog HDL. The input analog signal is first converted into digital signal by using ADC (Analog to Digital Converter) which can be done using the inbuilt ADC on FPGA board. A digital circuit is implemented which takes the 3-phase discrete signals as input and gives the discrete values of Positive, Negative and Zero sequence components. Finally, the sequence values can be used for the identification of the unbalanced and balanced faults (L-G, L-L, L-L-G and L-L-L) and sends the control signals to respective relays.
Developed a frequency adaptive hardware model of 3-phase to sequence decomposer for faster action on an electrical fault in the power system using FPGA boards and Verilog HDL. Got the work done published in the form of a research paper in IEEE journal.


This is a movie making competition with no specific theme. The submissions will be taken online through a google form. There will be a set deadline and late submission won’t be allowed in any case.
Theme :No specific theme.
Submission Deadline :TBD
Maximum Entries : 1
Entrance Fee :Rs 150/-
Time Limit: 3 - 10 min (including credits)
Prizes :TBD
Submission:Final movie, some uncut major raw shots used to make the final movie.
Regulations:
Judging Criteria (100 marks) :
|
Story and Screenplay |
30 |
|
Cinematography |
30 |
|
Editing (also includes background score, sound design, foley, VFX, etc) |
15 |
|
Acting |
10 |
|
Overall Impact (production value, overall vibes from the film, etc) |
15 |


Intent
public struct Intent
Basic Data Structure used for sending BLE communication’s to a Vuzix device.
Modeled after an Android Intent and very similar in practice to broadcasting and receiving.
Reference: Android Intent
-
package who sent this intent.
This value will be in the extras. This property is for convinence.
Declaration
Swift
public var sendingPackage: String? { get }
Return Value
if the intent comes from the Blade it will have a value, otherwise it will be nil.
-
The general action to be performed.
Declaration
Swift
public var action: String
-
Add a new category to the intent.
Declaration
Swift
public var category: String?
-
Add additional flags to the intent.
Standard Android Flags, see Android Intent
Declaration
Swift
public var flags: Int?
-
Add extended data to the intent.
Declaration
Swift
public var extras: BundleContainer?
-
Set an explicit application package name that limits the components this Intent will be sent to.
If nil then it gets sent to all apps on recieving end.
Declaration
Swift
public var package: String?
-
Create an intent.
Note
dictionary keys supported: action, flags, extras, package
var intent = Intent(dictionary: ["action": "com.3rdparty.login", "package": "com.3rdparty.bladeApp"]) intent.addExtra("username"<EMAIL_ADDRESS>intent.broadcast()
Declaration
Swift
public init?(dictionary: [String : Any])
Parameters
dictionary
Dictionary contain key/value pairs to create an intent from.
-
Create an intent.
Example: creates Intent, adds package, adds extra data, broadcasts it to the device.
var intent = Intent(action: "com.3rdparty.login") intent.package = "com.3rdparty.bladeApp" intent.addExtra("username"<EMAIL_ADDRESS>intent.broadcast()
Declaration
Swift
public init(action: String)
Parameters
action
the intent’s action.
-
Convinence method to add a simple key/value pair as an extra to the intent
Declaration
Swift
public mutating func addExtra(key: String, value: Any)


Aside: Debugging
Just a quick note on getting the vscode interactive debugger playing nicely with the in-docker development.
You can probably work out for yourself that you need to install the LLDB
debugging extension in the container (the Dockerfile already had a line to
install LLDB itself), so in devcontainer.json
"extensions": [
...
"vadimcn.vscode-lldb",
...
]
But, if you now spin up the container and try to start debugging, you’ll be greeted with a lovely error like:
process launch failed: ‘A’ packet returned an error: 8
This is fantastically unhelpful, but the error is actually coming from LLDB
itself. The error “8” appears to be ENOEXEC
(defined in
errno-base.h
) or “exec format error”. This is a clue, because
it’s an error from the exec
family of system calls, which are used to spawn
new processes.
Long story short, debuggers like gdb
and lldb
use the syscall ptrace
to
attach to their target processes. By default, docker containers are stripped of
many priviliges (which is part of the isolation which is the whole reason we
use docker). One of these stripped privileges, though, is exactly ptrace
.
Following the docker documentation,
we can give ourselves this privilege back with the docker argument
--cap-add=SYS_PTRACE
. Hooray!
But…
Even this wasn’t enough for me. Looking more closely at the Docker documentation you find this
The default seccomp profile will adjust to the selected capabilities, in order to allow use of facilities allowed by the capabilities, so you should not have to adjust this, since Docker 1.12. In Docker 1.10 and 1.11 this did not happen and it may be necessary to use a custom seccomp profile or use –security-opt seccomp=unconfined when adding capabilities.
Right, I’m using an up-to-date Docker, so this shouldn’t apply? Anyway, trying
out --security-opt seccomp=unconfined
and rebuilding the container…
debugging works! devcontainer.json:
"runArgs": [
...
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
]
I’m not entirely sure why this didn’t seem to work as documented, but I’ve spent too much time on this already and have lost all motivation to learn more right now.