About Me
Hello, I am Chao Zhang (aka Alex Zhang), Now I’m working at Yuozan Inc as a Middleware Development Engineer. My Email is<EMAIL_ADDRESS>and github ID is tokers. Why “tokers”? Because the name “Alex” in github is a “critical resource”, and “tokers” is the nickname that I created (random? maybe) since I was in college and played the ACM/ICPC competitions.
My tech stack is somewhat “hybrid”. I use Nginx, OpenResty, OpenSSL, Golang, Kubernetes, Redis and so forth.
I’m an OpenResty contributor. Moreover, I’m passionate with those techs.
This site is used as my tech blog, interesting things will be archived.
My Career
- Youzan Inc - Middleware Development Engineer (2019.6 - present)
- UPYUN Inc - System Development Engineer (2016.7 - 2019.6)
My Own Projects
These Nginx C modules are used for taking the power of ZStandard to Nginx.
There are two modules here, one is “static”, for serving the existing .zstd file on the disk. And the other one, is used to compress data with the sreaming way.
This Nginx C module provides the basic file operations APIs with a mechanism that never block Nginx’s event loop. For now, it leverages Nginx’s thread pool, I/O operations might be offloaded to one of the free threads, and current Lua coroutine (Light Thread) will be yield until the I/O operations is done, in the meantime, Nginx in turn processes other events.
It’s worth to mention that the cost time of a single I/O operation won’t be reduced, it was just transferred from the main thread (the one executes the event loop) to another exclusive thread. Indeed, the overhead might be a little higher, because of the extra tasks transferring, lock waiting, Lua coroutine resumption (and can only be resumed in the next event loop) and so forth. Nevertheless, after the offloading, the main thread doesn’t block due to the I/O operation, and this is the fundamental advantage compared with the native Lua I/O library.
The APIs are similar with the Lua I/O library, but with the totally different internal implementations, it doesn’t use the stream file facilities in libc (but keep trying to be consistent with it), the buffer is maintained inside this module, and follows Cosocket’s internals.
Yet Another HTTP library for OpenResty! This HTTP library is for human beings, just like Python Request, APIs are trivil but wonderful.
It provides many features:
- HTTP/1.0, HTTP/1.1 and HTTP/2 (WIP).
- SSL/TLS support.
- Chunked data support.
- Convenient interfaces to support features like json, authorization and etc.
- Stream interfaces to read request body.
- HTTP/HTTPS proxy.
- Latency metrics.
- Session support.
I’m still working on this project and will improve it continuously.
The HTTP/2 Protocol (Client Side) Implementation for OpenResty.
This pure Lua library implements the client side HTTP/2 protocol, but not all the details are covered, for example, the stream dependencies is maintained but never used.
There are some inherent limitations which are not solved, however. For more details, you can just read the README.
- Hmmm, I will replenish this list in the future. :)


by scope:
================
name: {{name}}
password: {{password}}
content: {{content}}
by element:
=========================
content: {{eContent}}


MM Usage Example
Take a look at Farfetch - where you can shop the world's best boutiques in one website. Plus, since I'm already a Farfetch customer, if you mention my name at the checkout when you place your order, you can receive 10% off too!
Send


{{registerationType}}
Request Secure token and Public Key from Third Party Service Generate Keys
Public
Private
Registeration Form:


class: center, middle, title-slide count: false # Regressions, Classification and PyTorch Basics
.bold[Marc Lelarge] --- # Supervised learning basics ## Linear regression ## Gradient descent algorithms ## Logistic regression ## Classification and softmax regression # Writing a PyTorch module --- ## Linear regression ### a probabilistic model The .bold[dataset] is made of $m$ .bold[training examples] $(x(i), y(i))\_{i\in [m]}$, where $x(i) \in \mathbb{R}^d$ are the .bold[features] and $y(i)\in \mathbb{R}$ are the .bold[target] variables. -- count: false Assumption, there exists $\theta\in \mathbb{R}^d$ such that: $$ y(i) = \theta^T x(i) +\epsilon(i), $$ with $\epsilon(i)$ i.i.d. Gaussian random variables (mean zero and variance $\sigma^2$). -- count: false Computing the .bold[likelihood] function gives: $$\begin{aligned} L(\theta) &= \prod\_{i=1}^m p\_\theta(y(i) | x(i))\\\\ & = \prod\_{i=1}^m \frac{1}{\sigma\sqrt{2\pi}}\exp\left(-\frac{(y(i)-\theta^T x(i))^2}{2\sigma^2}\right) \end{aligned} $$ --- ## Linear regression Maximizing the .bold[log likelihood]: $$\begin{aligned} \ell(\theta) &= \log L(\theta)\\\\ & = -m\log(\sigma\sqrt{2\pi}) -\frac{1}{2\sigma^2}\sum\_{i=1}^m(y(i)-\theta^T x(i))^2 \end{aligned}$$ is the same as minimizing the .bold[cost function]: $$ J(\theta) = \frac{1}{2}\sum\_{i=1}^m(y(i)-\theta^T x(i))^2, $$ giving rise to the .bold[ordinary least squares] regression model. -- count: false The gradient of the least-squares cost function is: $$ \frac{\partial}{\partial \theta\_j}J(\theta) = \sum\_{i=0}^m (y(i)-\theta^T x(i))\frac{\partial}{\partial \theta\_j}\left( y(i)-\sum\_{k=0}^d\theta\_k x\_k(i) \right) = \sum\_{i=0}^m (y(i)-\theta^T x(i))x\_j(i) $$ --- ## Gradient descent algorithms .bold[Batch gradient descent] perfoms the update: $$ \theta\_j := \theta\_j +\alpha \sum\_{i=0}^m (y(i)-\theta^T x(i))x\_j(i), $$ where $\alpha$ is the .bold[learning rate]. This method looks at every example in the entire training set on every step. -- count: false .bold[Stochastic gradient descent] works very well. The sum above is 'replaced' by a loop over the training examples, so that the update becomes: for $i=1$ to $m$: $$ \theta\_j := \theta\_j +\alpha (y(i)-\theta^T x(i))x\_j(i). $$ --- ## Linear regression Recall that under mild assumptions, the explicit solution for the ordinary least squares can be written explicitely as: $$ \theta^* = (X^TX)^{-1}X^T Y, $$ where the linear model is written in matrix form $Y = X\theta +\epsilon$, with $Y=(y(1), \dots y(m))\in \mathbb{R}^m$ and $X = (x(1),\dots x(m))\in \mathbb{R}^{m\times d}$. Exercise: show the above formula is valid as soon as $\text{rk}(X) = d$. -- count: false In other words, __optimization is useless for linear regression!__ (if you are able to invert $X^TX$) Nevertheless, gradient descent algorithms are important optimization algorithms with theoretical guarantees when the cost function is .bold[convex]. We used linear regression as a simple example to understand PyTorch framework. --- ## PyTorch implementation for batch gradient descent ```py import torch model = torch.nn.Sequential(torch.nn.Linear(2, 1)) loss_fn = torch.nn.MSELoss(reduction='sum') model.train() optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate) for epoch in range(n_epochs): y_pred = model(x) loss = loss_fn(y_pred, y) optimizer.zero_grad() loss.backward() optimizer.step() ``` code taken from this [notebook](https://github.com/mlelarge/dataflowr/blob/master/Notebooks/02_basics_pytorch_colab.ipynb) -- count: false But the important piece of code is (assuming x and y are numpy array): ```py *dtype = torch.FloatTensor *x = torch.from_numpy(x).type(dtype) *y = torch.from_numpy(y).type(dtype).unsqueeze(1) ``` The default type for weights and biases are torch.FloatTensor. So, you'll need to cast your inputs to torch.FloatTensor. Moreover, the shape of y needs to be $[\text{batch size},1]$. --- ## Logistic regression ### a probabilistic model A natural (generalized) linear model for .bold[binary classification]: $$ \begin{aligned} p\_\theta(y=1|x) &= \sigma(\theta^T x),\\\\ p\_\theta(y=0|x) &= 1-\sigma(\theta^T x), \end{aligned} $$ where $\sigma(z) = \frac{1}{1+e^{-z}}$ is the .bold[sigmoid function] (or .bold[logistic function]). -- count: false Why is it a natural model? Because it belongs to the family of generalized linear model ;-) Denote $f(x) = \log \frac{p\_\theta(y=0,x)}{p\_\theta(y=1,x)}$, so that we get $$ \begin{aligned} p\_\theta(y=1|x) &= \frac{p\_\theta(y=1,x)}{p\_\theta(y=1,x)+p\_\theta(y=0,x)}\\\\ &= \sigma(f(x)). \end{aligned} $$ Assuming $f$ is linear, sigmoid function appears naturaly. --- ## A pause on notations We (mainly) use the compact notations used in .bold[information theory]: the function $p(.)$ is defined by its argument so that $p(x)$ is the distribution of the r.v. $X$ and $p(y)$ the distribution of the r.v. $Y$: $$ \begin{aligned} p(x) &= P(X=x)\\\\ p(y) &= P(Y=y)\\\\ p(x,y) &= P(X=x, Y=y)\\\\ p(y|x) &= P(Y=y|X=x)\\\\ &= \frac{p(x,y)}{p(x)} = \frac{p(x,y)}{\sum\_y p(x,y)} \end{aligned} $$ -- count: false In particular, we can write our model more compactly as: $$ p\_\theta(y|x) = \sigma(\theta^T x)^y(1-\sigma(\theta^T x))^{(1-y)}. $$ --- ## Logistic regression The likelihood function is now: $$ L(\theta) = \prod\_{i=1}^m \sigma(\theta^T x(i))^{y(i)}\left( 1-\sigma(\theta^T x(i))\right)^{1-y(i)} $$ -- count: false So that the log likelihood is: $$\ell(\theta) = \sum\_{i=1}^m y(i)\log \sigma(\theta^T x(i))+(1-y(i))\log \left( 1-\sigma(\theta^T x(i))\right) $$ There is no closed form fomula for $\arg\max \ell(\theta)$ so that we need now to use iterative algorithms. -- count:false The gradient of the log likelihood is: $$ \frac{\partial}{\partial \theta\_j}\ell(\theta) = \sum\_{i=1}^m (y(i)-\sigma(\theta^T x(i))x\_j(i), $$ where we used the fact that $\sigma'(z) = \sigma(z)(1-\sigma(z))$. --- ## Logistic regression ### Binary cross entropy loss torch.nn.BCELoss computes Binary Cross Entropy between the targets $y=(y(1),\dots, y(m))\in \\{0,1\\}^m$ and the output $z=(z(1),\dots, z(m))\in [0,1]^m$ as follows: $$\begin{aligned} \text{loss}(i) &= -[y(i)\log z(i) +(1-y(i))\log(1-z(i))]\\\\ \text{BCELoss}(z,y) &= \frac{1}{m}\sum\_{i=1}^m \text{loss}(i). \end{aligned} $$ In summary, we get $$ \text{BCELoss}(\sigma(X^T \theta),y) = - \frac{1}{m} \ell(\theta), $$ where the sigmoid function is applied componentwise. -- count: false To do a logistic regression with torch.nn.BCELoss, the last layer of the network needs to be a Sigmoid layer: torch.nn.Sigmoid --- ## Logistic regression ### Binary cross entropy with logits loss torch.nn.BCEWithLogitsLoss combines a Sigmoid layer and the BCELoss in one single class. $$\begin{aligned} \text{loss}(i) &= -[y(i)\log \sigma(z(i)) +(1-y(i))\log(1-\sigma(z(i)))]\\\\ \text{BCEWithLogitsLoss}(z,y) &= \frac{1}{m}\sum\_{i=1}^m \text{loss}(i). \end{aligned} $$ -- count: false This version is more numerically stable. Note the default $1/m$ factor, where $m$ is typically the size of the batch. This factor will be directly multiplied with the learning rate. Recall the batch gradient descent update: $$ \theta\_j := \theta\_j +\alpha \frac{\partial}{\partial \theta\_j}\text{loss}(\theta). $$ --- We solved the homewrok with 1 new line of code! ```py import torch model = torch.nn.Sequential(torch.nn.Linear(2, 1)) #loss_fn = torch.nn.MSELoss(reduction='sum') *loss_fn = torch.nn.BCEWithLogitsLoss(reduction='sum') model.train() optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate) for epoch in range(n_epochs): * out = model(x) * loss = loss_fn(out, z) optimizer.zero_grad() loss.backward() optimizer.step() ``` --- ## Classification and softmax regression ### a probabilistic model We now have $c$ classes and for a training exampkle $(x,y)$, the quantity $\theta\_k^T x$ should be related to the probability for the target $y$ to belong to class $k$. By analogy with the binary case, we assume: $$ \log p\_\theta(y = k| x) \propto \theta\_k^T x, \quad \text{for all }k=1,\dots, c. $$ As a consequence, we have with $\theta=(\theta\_1,\dots, \theta\_c)\in\mathbb{R}^{d\times c}$: $$ p\_\theta(y = k| x) = \frac{e^{\theta\_k^T x}}{\sum\_l e^{\theta\_l^T x}} $$ and we can write it in vector form: $$ (p\_\theta(y = k| x))\_{k=1,\dots,c } =\text{softmax}(\theta\_1^T x,\dots,\theta\_c^T x) $$ --- ## Classification and softmax regression For the .bold[softmax regression], the log-likelihood ca be written as: $$\begin{aligned} \ell(\theta) &= \sum\_{i=1}^m \sum\_{k=1}^c 1(y(i) =k) \log \left( \frac{e^{\theta\_k^T x(i)}}{\sum\_l e^{\theta\_l^T x(i)}}\right)\\\\ & = \sum\_{i=1}^m \log \text{softmax}\_{y(i)}(\theta\_1^T x(i),\dots,\theta\_c^T x(i)) \end{aligned} $$ In PyTorch, if the last layer of your network is a LogSoftmax() function, then you can do a softmax regression with the torch.nn.NLLLoss(). -- count: false Most of the time, we are not interested in softmax regression but in classification, i.e. we need to output a class not a probability vector on the classes. For classification of the feature $x$, we output the most probable class: $$ \arg\max \\{ \theta\_1^T x,\dots, \theta\_c^T x\\} $$ --- ## Classification and softmax regression For 2 classes, we recover the logistic regression: $$ \begin{aligned} p\_\theta(y=1|x) &= \frac{e^{\theta\_1^T x}}{e^{\theta\_1^T x}+e^{\theta\_0^T x}}\\\\ &= \frac{1}{1+e^{(\theta\_0-\theta\_1)^T x}}\\\\ &= \sigma\left( (\underbrace{\theta\_1-\theta\_0}_{\theta})^T x\right) \end{aligned} $$ -- The prediction for the class of feature $x$ is then given by the simple rule: $$ 1(\theta^T x\geq 0), $$ i.e. for prediction, we replace the smooth sigmoid function by the Heaviside step function. --- ## Back to dogs and cats! In the [dogs and cats example](https://github.com/mlelarge/dataflowr/blob/master/01_intro_DLDIY_colab.ipynb), we were interested in classification (and not logistic regression!). Hence we used the following modification of the VGG classifier : ```py model_vgg.classifier._modules['6'] = nn.Linear(4096, 2) model_vgg.classifier._modules['7'] = torch.nn.LogSoftmax(dim = 1) ``` so that we get an output of dimension 2 and we then used torch.nn.NLLLoss() As shown above, this approach extends nicley to more than 2 classes. --- ## Classification in PyTorch .grid[ .kol-6-12[ .left[ ```py import numpy as np from numpy.random import random from scipy.stats import bernoulli from scipy.special import expit x = random((data_size,2)) *x_test = random((test_size,2)) y = np.dot(x, w_source) + b_source *y_test = np.dot(x_test, w_source) + b_source Z = bernoulli.rvs(expit(y)) *Z_test = bernoulli.rvs(expit(y_test)) import torch x = torch.from_numpy(x).type(torch.FloatTensor) *x_test = torch.from_numpy(x_test).type(torch.FloatTensor) *Z = torch.from_numpy(Z).float() *Z_test = torch.from_numpy(Z_test).float() ```] .left[ Note the type of the targets need to be torch.LongTensor and the targets' shape is $[\text{batch size}]$ (as opposed to $[\text{batch size},1]$ with BCEWithLogitsLoss) ]] .kol-6-12[ .left[ ```py import torch.nn as nn n_classes = 2 feat_dim =2 *model = nn.Sequential(torch.nn.Linear(feat_dim, n_classes), * torch.nn.LogSoftmax(dim=1)) *loss_fn = nn.NLLLoss() model.train() optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate) for epoch in range(num_epochs): log_p = model(x) loss = loss_fn(log_p, Z) optimizer.zero_grad() loss.backward() optimizer.step() if epoch %10 ==0: * log_p = model(x_test) * _, preds = torch.max(log_p,1) * acc = torch.sum(preds == Z_test) * print("progress:", "epoch:", epoch, * "loss train", loss.data.item(), * "loss test", loss_fn(log_p, Z_test).item(), * "accuracy", acc.item()/test_size) ```] ] ] --- ## Why not directly maximizing the accuracy? Going back to the binary classification task, the binary loss is: $$\begin{aligned} \text{Binary loss}(\theta) = \sum\_{j=1}^m 1(y(j) =\not 1(\theta^T x(j)\geq 0)). \end{aligned} $$ The binary cross entropy loss was a convex function of $\theta$ (proof left as exercise!) but here, we replace it by a discrete optimization problem. -- count: false Note that the loss is 'flat' so that the gradient is zero and the optimizer step will not update weights. -- count: false The .bold[perceptron learning algorithm] uses the following greedy update rules: for $i=1$ to $m$: $$ \theta\_j := \theta\_j +\alpha (y(i)-1(\theta^T x(i)\geq 0))x\_j(i). $$ More on this, latter... --- # Writing a PyTorch module In practice, we use previous analysis to treat the last layer of the deep neural network, so that we now have: $$ \log p\_\theta(y=1| x),\dots, \log p\_\theta(y=c| x) \propto f\_\theta(x)\_1,\dots , f\_\theta(x)\_c, $$ where the vector $(f\_\theta(x)\_1,\dots, f\_\theta(x)\_c)$ is the output of the last layer on the input $x$ and $\theta$ takes now into account all the weights in the different layers. In order to create more complex network $f\_\theta(.)$, we will need to write a PyTorch module. --- # Writing a PyTorch module To create a module, one has to inherit from the base class `torch.nn.Module` and implement the constructor `__init__(self, ...)` and the forward pass `forward(self, x)`. Here is the code for our last model: ``` import torch import torch.nn as nn *import torch.nn.functional as F class classifier(nn.Module): def __init__(self): super(classifier, self).__init__() self.fc = nn.Linear(in_features=feat_dim, out_features=n_classes) def forward(self,x): x = self.fc(x) * return F.log_softmax(x, dim=1) model = classifier() ``` --- # Writing a PyTorch module Inheriting from `torch.nn.Module` provides many mechanisms implemented in the superclass. First, the `(...)` operator is redefined to call the `forward(...)` method. All `Parameters` added as class attributes are seen by `Module.parameters()`. As long as you use autograd-compliant operations, the backward pass is implemented automatically. This is crucial to allow the update of the `Parameters` with your optimizer. --- # Writing a PyTorch module Define a loss and an optimizer as before: ``` loss_fn = nn.NLLLoss() optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate) ``` -- count: false One step of gradient descent is done as before: ``` log_p = model(x) loss = loss_fn(log_p, Z) optimizer.zero_grad() loss.backward() optimizer.step() ``` -- count: false In other words, the training loop we wrote is still working: ```py for epoch in range(num_epochs): log_p = model(x) loss = loss_fn(log_p, Z) optimizer.zero_grad() loss.backward() optimizer.step() ``` So now is time to construct more complex architectures! --- class: end-slide, center count: false The end.


This post is a part of a series i plan to write periodically to document my exploits with CNC machines and other stuff i have built! This post is about a stepper system tester i built a while back.
Stepper motors are quite widely used for CNCs/3D Printers or other Electromechanical hacks like the polar plotter etc. ! There is as always a constant need to run the motor to check whether its aligned properly or not? Does the flex coupling has any issues? Is the driver dead or alive and the best one- whether the current setting is fine to generate enough torque to hold or move the lead screw/Belt.
Pestered by the same above questions i wanted to build my own driver/motor tester overnight and it 'must' be built ACAP (As cheap as possible) :D ! I stumbled open this awesome project that i saw on Hack-A-Day.
It uses an ATiny AVR microcontroller which I did'nt have and the least capable one i had was the MSP430G2230 which came in a SOIC pkg a bit difficult to go on the perfboard and my laziness propelled me away from etching a board for accommodating the same (I now feel the need though). I thought of building a microcontroller-less one as most modern stepper drivers like the ones from Pololu need just two signal i.e STEP and DIR.
A pulse on step pin will initiate a step to the internal indexer that handles what coil has to be energized based on the sequence and micro-stepping settings, while the DIR is a level signal whose level decides whether the internal indexer of the driver counts up or down!
So, only two inputs i.e Pulsed input for STEP and level input for DIR. This can be achieved using the 555 timer in the astable mode. The Output of 555 i.e pin 3 will go into the step pin and the DIR pin is pulled up using a resistor and it is also connected to ground via switch.
This gets the job done! We can also have a POT to vary the frequency since some motors don't respond to faster pulses due to rotor inertia.The driver i am using is based on DRV8825 from TI. It is slightly wider than the polulu one. (You might call me a TI fan boy). I designed it myself based on reference designs by TI and had the PCBs made by SeeedStudio's Fusion PCB Service. It took about 30 odd days to reach. The driver is two layer in-contrast the Pololu ones are 4 layer. I had to widen the PCB to provide enough dissipating area for the inbuilt heatsink on the the HTSSOP pkg of the DRV8825. Also the SMD resistor cousins of those lower value resistors were not available here in Delhi, so had to go with through hole ones. Ditto for the POT !

The circuit is as follows:
It has two power inputs 12v, 5v and a common ground, all of which are sourced from an ATX! The circuit itself is pretty simple.
The final build on a perfboard is shown below.
I chose to use a SMD 0603 10K resistor between pin 8 and 7 to reduce the space and connected 104 (0.1uF) Ceramic caps as shown. The switch is a 10xx and the capacitor is required at the input of stepper driver to reduce supply dips when it draws current. I have used female headers for the motor since most motors come with a connector that can be easily wired up with a single strand wire. I used the Power Terminal connectors for the main 12V Driver supply as the driver is rated for 2.5A which is too high for the usual jumper cables !
TIP: If you are using the non-tinned/less tinned headers that have been lying around in the component box for a while, make sure to rub the connectors using sandpaper to remove corrosion residue on the contacts else it might seem soldered but it wont actually be soldered. Also you may use some extra flux.
Video:
Cheers !
Rohit Gupta


Healthy Hot Chocolate
October 20 2021
Servings: 1 People
Total Time: 5 min
Ingredients List:
- 2 TBS Cocoa Powder
- 2 Tbs Honey
- 1 Cup Milk
Directions:
- Mix Honey & Cocoa Powder Together till they form a sauce.
- Heat the milk till it becomes warm.
- Pour the warm milk over the chocolate sauce.
- Mix Together & Enjoy with a slice of cake.


×
Close
Select your device
Put a device list here
to be continue
to be continue
to be continue
to be continue
to be continue
×
Close
Upload your photo
Select files...
Device
Photo
Filter
Choose your device
Your device: {{.PhoneDispName}}
iPhone 6P
iPhone 5s
iPhone 5c
iPhone 5
iPhone 4/4s
Select a photo
Instagram
Facebook
Upload
Test
Select a filter
SAVE THIS DESIGN
Product
Photo
Filter
Device
Case
Choose Your Device
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
iPhone 6
Instagram
Facebook
Upload
Select files...
Login
Filter


Adjusts longitudinal regression models using Bayesian methodology for covariance structures of composite symmetry (SC), autoregressive ones of order 1 AR (1) and autoregressive moving average of order (1,1) ARMA (1,1).
| Version: | 0.1.0 |
| Depends: | R (≥ 3.1.0), LearnBayes, mvtnorm, MASS |
| Published: | 2017-07-25 |
| Author: | Edwin Javier Castillo Carreño, Edilberto Cepeda Cuervo |
| Maintainer: | Edwin Javier Castillo Carreño <edjcastilloca at unal.edu.co> |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| NeedsCompilation: | no |
| CRAN checks: | bayeslongitudinal results |
| Reference manual: | bayeslongitudinal.pdf |
| Package source: | bayeslongitudinal_0.1.0.tar.gz |
| Windows binaries: | r-devel: bayeslongitudinal_0.1.0.zip, r-release: bayeslongitudinal_0.1.0.zip, r-oldrel: bayeslongitudinal_0.1.0.zip |
| OS X binaries: | r-release: bayeslongitudinal_0.1.0.tgz, r-oldrel: bayeslongitudinal_0.1.0.tgz |
Please use the canonical form https://CRAN.R-project.org/package=bayeslongitudinal to link to this page.


CouchDB framework in Python
Couchdbkit provides you a full featured and easy client to access and manage CouchDB. It allows you to manage a CouchDB server, databases, doc managements and view access. All objects mostly reflect python objects for convenience. Server and Databases objects could be used for example as easy as using a dict.
from couchdbkit import Server
s = Server()
db = s.create_db("couchbdkit_test")
db['someid'] = { 'test': 'essai' }
doc = db['someid']
Map couchdb object to python object easily with dynamic schema. It's similar to ORMs but with all the couchdb awesomeness.
from couchdbkit import Document
class Greeting(Document):
author = StringProperty()
content = StringProperty()
date = DateTimeProperty()
greet = Greeting()
greet.author = "Me"
greet.homepage = "http://couchdbkit.org"
Manage easily design docs in your Python application with loaders
.
from couchdbkit.designer import pushapps
pushapps('/path/to/designs', db)
Next steps
Grab the code and you can read through the getting started tutorial. After you've gone through that, best thing to do is read the documentation on this site.
If you need help, don't hesitate to contact me.


|
Clustering of quasars in the First Year of the SDSS-IV eBOSS survey : Interpretation and halo occupation distribution |
| Observations of Baryon Acoustic Oscillations offer indispensable information to constrain our cosmological model. In current and future surveys, quasars play a key role by extending our knowledge of the Universe with measurements of the acoustic scale at redshift larger than 1. Here, we present the first clustering study of the quasars observed by the extended Baryon Oscillation Spectroscopic Survey. We measure the clustering of about 70,000 quasars located in the redshift range 0.9 to 2.2 that cover 1,168 square degrees. We model the clustering and produce high-fidelity quasar mock catalogs based on the MultiDark simulation suite. In this aim, we update the (Sub)Halo Abundance Matching model to account for the specificities of the halo population hosting quasars. Finally, we find that quasars are hosted by halos with log halo masses of 12.7 and that their bias evolves from 1.54 (z=1.06) to 3.15 (z=1.98). |
| Please click here to access the mock QSO catalog based on the BigMultiDark Planck Simulation that reproduces the clustering observed in eBOSS Y1Q. |
| If you use these mocks, please cite Rodriguez-Torres et al. 2017 and Rodriguez-Torres, et al. 2016. |
last update, jan. 2017, by J. Comparat


---
layout: post
title: Making HTML5 work with Firefox on Debian Jessie
categories: []
tags: [Linux,Debian,HTML5,Firefox]
status: publish
type: post
published: true
comments: true
meta:
_edit_last: '1'
---
I was getting a bit annoyed at all the disjoint posts around the internet about making HTML5 work with my Firefox install on my work laptop so I thought I'd contribute to the noise.
Getting started, if you go to http://youtube.com/html5 and you see something like the screenshot below, you might want to try out my instructions.
You might see x264 also in red, this guide should fix that as well.
Install Debian multimedia repository
(As root) Add the repo to your sources:
{% highlight bash %}
echo "http://www.deb-multimedia.org jessie main non-free" >> /etc/apt/sources.list.d/deb-multimedia.list
{% endhighlight %}
Update sources and install keyring and update sources again:
{% highlight bash %}
sudo apt-get update
sudo apt-get install deb-multimedia-keyring
sudo apt-get update
{% endhighlight %}
Install Codecs
Remove any leftover ffmpeg implementation from the original repo:
{% highlight bash %}
sudo apt-get remove ffmpeg
{% endhighlight %}
Install Packages:
{% highlight bash %}
sudo apt-get install ffmpeg x264 gstreamer0.10-ffmpeg
{% endhighlight %}
Enable Mediasources in Firefox
Open firefox, go to 'about:config' in your addressbar. Search for 'mediasource'.
Set the following two keys to 'true':
media.mediasource.enabled
media.mediasource.webm.enabled
Restart Firefox
Validate Changes
Go back to http://youtube.com/html5 in firefox and hopefully you will see more blue:
Also don't forget to click the "Request the HTML5 player" on youtube to make good use of this.
Profit!
See! Linux users can have nice things too.


--- layout: archive title: Zulip Chat Archive permalink: /stream/144837-PR-reviews/topic/determinants.html ---
I did some tidying on the determinants PR. I got rid of all the relics of Sym
that weren't actually used for determinants - It's now only a 130 line Pr, versus 481. I also made the proofs hopefully more readable, if longer. Result is here https://github.com/leanprover/mathlib/compare/master...dorhinj:determinants2?expand=1
Old version https://github.com/leanprover/mathlib/pull/378/files
is it PR'd? I want
So now we have determinants, but we don't know that it is a monoid hom. For this we need https://github.com/leanprover/mathlib/pull/375
I don't understand why that thing is called the free_module
Should I just remove that code for now?
The bit on scalar matrices is more important to me
Why do we need it? Like I said diagonal
subsumes it
I think it is nice to have
We also have a * I
which is the way the rest of the world notates this
Hmm... ok
I don't really care
I'm trying to understand what is needed
What is needed is that det
is a monoid hom
That PR doesn't say anything about monoid homs
No, but det_one
uses det_scalar
That stuff was commented out in my det
PR
I don't know if Chris preserved those comments. Let me check
No, those are gone
We have det_one
so it is proven to be a monoid hom. Are monoid Homs defined yet?
Yes they are
So my new PR is a 4-liner.
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


Just envisioning the goals and stating the rules does not get things going. One also has to identify the strategic initiatives people should start working on. We intentionally use the term initiative because the plan of action is usually yet too coarse to speak of well-scoped projects. At this granularity, it is not about a proper project portfolio management: The how is widely unclear, there’s no target architecture in place, and all we have is intentions to start with. A typical scenario would be an imaginary car manufacturer, Cars4Us, which has committed to the goal of keeping existing customers. 1 A high-level business maxim aiming at this goal could be:
We make the customer perceive us as a helpful companion, and we maximize the number of services and contact points accordingly.
The different business units of Cars4Us examine this maxim and come up with initiatives as to how to put this into practice. Customer care concludes they should point the customer to all service incidents and technical checkups in advance. Therefore, they take up a business initiative that models the whole life cycle of a car, with all probable events and corresponding interactions (car care, repairs, new purchase, etc.) with the customer. The IT initiative derived from it implements this process in the customer relationship management (CRM) system and automates such things as sending notification mailings about upcoming technical checkups.
Marketing, on the other hand, intends to extend the services beyond the narrow scope of car caretaking. They kick off an IT initiative centered on mobile applications in order to explore what kind of helpful gadgets could be offered on a smartphone. The range is wide: racing games with Cars4Us models, augmented reality manuals for the car, or apps alerting the user to events such as concerts or football games close by. The initiative is complemented by an investment into customer analytics. Cars4Us wants to learn about the customer and her wishes from the mobile interactions.
This example illustrates that there’s no way to systematically deduce the right initiatives. There’s not even a framework for guidance. One is left to one’s own creativity and a thorough understanding of the enterprise and the way the business is run.
The initiatives usually do not directly lead to implementation projects. The latter are rather pursued by pre-projects detailing the requirements and target architecture to a level that allows for proper project planning of effort, business value, and risks involved.


Lost? Angry? (Please don't be angry ;_;) Find a chart that works for you:
hiragana,
katakana.
Correctly identified kana are available for review again after three hours; incorrect after one.
Come back every day until you feel like you recognise the squiggles well enough.
Each character is considered 100% learned after getting it right five times, removing it from reviews; mistakes dock a point.
This page works offline. You can save it locally, modify the numbers in its code, and just drop it into a browser.
After making any changes here, reload the page.
"reset" sets the success-count to 0, while "remove" sets it to max.
reset all - deletes all data for this character-set
remove all - marks all items complete for this character-set


Hello world!
Bacon ipsum dolor amet turducken drumstick cupim, ball tip short loin kielbasa pancetta chuck chicken venison tongue jowl picanha tenderloin. Sirloin brisket prosciutto beef ground round, pig venison ham hock fatback pastrami flank short loin ball tip bresaola pork belly. Picanha meatball drumstick turkey filet mignon ribeye fatback ground round prosciutto beef strip steak pork chop kevin capicola. Beef ribs pancetta swine sausage, jerky brisket shankle kielbasa jowl doner fatback beef.   Spare ribs ball tip ham ground round cow brisket hamburger.


The goal of sarbR is to provide an easy interface to the monthly release of the South African Reserve Bank Quarterly Bulletin data. Although the SARB has many other datasets, the Quarterly Bulletin makes up the bulk of the statistical release.
At the time of the publication of this package (April 2019), the SARB
still has no easy way of accessing the data through an programmatic
interface (API). The maintainer/s sarbR
package aim to fill
this role by curating the data automatically from the SARB, updating a
dedicated database and giving access to the data through the simple
sarb_code
function.
Please be aware: the data is updated in an automated fashion as soon as a new release is published on the SARB’s website.
This package is in no way endorsed or associated with the South African Reserve Bank (SARB).
Given that no formal API is provided, the maintainers of this package rely on their own infrastructure to collect, curate, clean, maintain an up to date database and give access through a securely built API.
Although the greatest care is taken to provide good data, the maintainer/s of this package take no responsibility in the service OR data being supplied.
The package is built around the main sarb_code
function,
with two helper functions. The first providing a way to search for an
indicator and its meta information: search_indicator
. The
second function is to request an access token for the API:
token_request
.
To install the package
# Install development version from GitHub
remotes::install_github("Stellenbosch-Econometrics/sarbR")
library(sarbR)
Because the database is maintained on a small server and the maintainer wishes to keep the server protected from malicious conduct, it was decided to implement requests on a token basis. This ensures some measure of security, a bit of analytics on request and hopefuly allows the small server to handle everyones request in an orderly manner.
To request a token from the service follow 2 simple steps:
token_request()
#> Successful token creation
#> $status
#> [1] 200
#>
#> $msg
#> [1] "Successful token creation"
#>
#> $info
#> address token
#> <IP_ADDRESS> f84sdsfsdce65eege7dbacd93ac3dc073e364
usethis::edit_r_environ()
, or set it in your current
session using:
options("sarb.token" = "f84sdsfsdce65eege7dbacd93ac3dc073e364")
Sys.setenv("sarb.token" = "f84sdsfsdce65eege7dbacd93ac3dc073e364")
release_info()
#> [1] "Latest release info: 2020-12-15"
all_codes()
#># A tibble: 4,316 x 1
#> code
#> <chr>
#> 1 KBP1000J
#> 2 KBP1000M
#> 3 KBP1005J
#> 4 KBP1005M
#> 5 KBP1006J
#> 6 KBP1006M
#> 7 KBP1007J
#> 8 KBP1007M
#> 9 KBP1008J
#>10 KBP1008M
#># … with 4,306 more rows
This way you will not need to send the token along when making a request for data
The sarb_code
function is the main function of the
package. This functions interacts with a plumber
API that
has access to a MySQL database with the latest quarterly data.
To use request the data, the whole code needs to be provided. As an example, if you would like to reques Expenditure on gross domestic product at Current prices at a yearly frequency, you need to request KBP6045J
sarb_code(code = "KBP6045J")
Or if the the token is not set as in the above mentioned manner (in
the .Renviron
), then it can be passed along to the
function
sarb_code(code = "KBP6045J", token = "f84sdsfsdce65eege7dbacd93ac3dc073e364")
The SARB provides various series with specific codes linked to a series: KBPXXXX. It can be difficult to know which series you are looking.
To help you find a specific frequency of a series (Monthly,
Quarterly, Yearly) or just look in general for a series on say, GDP, we
can use the search_indicator
function. This function is a
convenience wrapper around the indicator_codes
dataset
Using the description to look for specific series:
search_indicator(description = "Expenditure")
#> # A tibble: 6 x 7
#> time_series description_and_vers… series version_description frequency unit_of_measure code
#> <chr> <S3: glue> <chr> <chr> <chr> <chr> <S3: >
#> 1 KBP6045 Expenditure on gross… C Constant 2010 prices K1 RMILL KBP60…
#> 2 KBP6045 Expenditure on gross… D Constant 2010 prices. S… K1 RMILL KBP60…
#> 3 KBP6045 Expenditure on gross… J Current prices J1 RMILL KBP60…
#> 4 KBP6045 Expenditure on gross… K Current prices K1 RMILL KBP60…
#> 5 KBP6045 Expenditure on gross… L Current prices. Seasona… K1 RMILL KBP60…
#> 6 KBP6045 Expenditure on gross… Y Constant 2010 prices J1 RMILL KBP60…
Look up the time series:
search_indicator(time_series = "KBP1000")
#> # A tibble: 2 x 7
#> time_series description_and_version series version_descript… frequency unit_of_measure code
#> <chr> <S3: glue> <chr> <chr> <chr> <chr> <S3: >
#> 1 KBP1000 South African Reserve Bank li… J NA J1 RMILL KBP10…
#> 2 KBP1000 South African Reserve Bank li… M NA M1 RMILL KBP10…
You can also look up a specific series if you know the exact code:
search_indicator(code = "KBP1000J")
#> # A tibble: 2 x 7
#> time_series description_and_version series version_descript… frequency unit_of_measure code
#> <chr> <S3: glue> <chr> <chr> <chr> <chr> <S3: >
#> 1 KBP1000 South African Reserve Bank li… J NA J1 RMILL KBP10…
The package also includes data that helps you understand the
frequency column used in the indicator_codes
dataset
sarbR::frequency_description
#> Description Frequency
#> 1 D6 Daily - Monday to Saturday
#> 2 W3 Weekly as on Wednesday
#> 3 W6 Weekly - Monday to Saturday
#> 4 M1 Monthly
#> 5 K1 Quarterly
#> 6 J1 Annually - 1 January to 31 December
#> 7 J2 Annually - 1 April to 31 March
If you want to make a specific dataset available through the package, a request can be made through the issues page:


:sufficient distance for maneuvering a ship
:an amount of distance maintained for safety give the fire a wide berth
:the place where a ship lies when at anchor or at a wharf
:a space for an automotive vehicle at rest a truck-loading berth
:a place to sit or sleep especially on a ship or vehicle :accommodation
:a billet on a ship
:job position place a starting berth on the team


ONLY I CAN CHANGE MY LIFE
NO ONE CAN DO IT FOR ME
*趙慧姝*
CHO HYE JU / JOY CHO
Be the most wise and beautiful in the world


A little bit
About Hasib
Entrepreneur
As the co-founder of Craftsmen, a software company that provides scalable cloud solutions, I have had the opportunity to lead the company’s growth from a team of 5 to over 70 people. We have earned a reputation as one of Bangladesh’s best software companys to work and grow in, and have been recognized with awards for best startup company and best outsourcing company from BASIS.
During this period, I have had the privilege of working with some of the most gifted engineers, recruiting and mentoring many talented individuals, and having screened over 5k candidates in the process. From that experience, I learned about the traits recruiters look for and how candidates fall short to demonstrate their fit for the role.
Software Artisan
In my 7+ years of experience as a software engineer, I have architected software for one of the largest petroleum companies in Scandinavia, developed features for the world’s largest online freight marketplace, and contributed to systems used by some of the biggest names in the media industry.
In this short journey, I have learned what elevates someone from being a good to a great software engineer, as well as how to avoid pitfalls that could impede one’s progress.
Influential individuals’
Testimonials
How I may
Assist You
Free Session 30 minutes
- Traits of a quality software company
- How to showcase yourself
- How to prepare for interview
- Considerations for contract signing
Exclusive Workshop 2.5 hours workshop • 1 hour test
- Everything from the free session
- The Full Framework, tools & resources
- Mock aptitude test
- Debunking common myths
- Compensation & benefit negotiation
- Software engineering ethics
- Advancing your career
Frequently asked
Questions
-
Where will the workshop be hosted?
The workshop will be hosted online via Zoom. We will also use Discord for communication. -
Will the workshop be recorded for later review?
Unfortunately, it will not be recorded. However, you will be able to access all resources shared through Discord. -
Is it okay for me to ask questions during the workshop?
Yes, it is encouraged for you to ask questions. There will be a designated time for Q&A where you can ask your own questions or vote for others’ questions to be answered. The questions with the most votes will be answered within the allocated time. -
I was not satisfied with the workshop. Is it possible to receive a refund?
Yes, absolutely. Our satisfaction guarantee allows you to request a refund within 5 days of the first session. If you would like to request a refund, please contact me and let me know. I will process your refund as quickly as possible to resolve any issues you may have had with the workshop.


GlassMADA addresses and tackles the cognitive and memory issues concerning people in the earlier stages of Alzheimer's. Our solution aims to behave as a tool for the retrieval and review of forgotten information relevant to the user’s personal life. Specifically, we focused on assisting the user with recognizing people and their relative affiliation as well as recording daily activities via image capture. With real-time people recognition, people with Alzheimer's can avoid the embarrassment of not knowing their families or friends or having to ask who they are. With daily activities recorded in form of photos, people with Alzheimer's and their caregivers will be able to review images in a reflective, therapeutical session about what has happened during the day.
Demo Video Learn More


Rails 5.0.2 (March 01, 2017)
- No changes.
Rails 5.0.1 (December 21, 2016)
- No changes.
Rails 5.0.1.rc2 (December 10, 2016)
- No changes.
Rails 5.0.1.rc1 (December 01, 2016)
Added instance variable
@queue
to JobWrapper.This will fix issues in resque-scheduler
#job_to_hash
method, so we can use#enqueue_delayed_selection
,#remove_delayed
method in resque-scheduler smoothly.mu29
Rails 5.0.0 (June 30, 2016)
Enable class reloading prior to job dispatch, and ensure Active Record connections are returned to the pool when jobs are run in separate threads.
Matthew Draper
Tune the async adapter for low-footprint dev/test usage. Use a single thread pool for all queues and limit to 0 to #CPU total threads, down from 2 to 10*#CPU per queue.
Jeremy Daer
Change the default adapter from inline to async. It's a better default as tests will then not mistakenly come to rely on behavior happening synchronously.
DHH
Fixed serializing
:at
option forassert_enqueued_with
andassert_performed_with
.Wojciech Wnętrzak
Support passing array to
assert_enqueued_jobs
in:only
option.Wojciech Wnętrzak
Add job priorities to Active Job.
wvengen
Implement a simple
AsyncJob
processor and associatedAsyncAdapter
that queue jobs to aconcurrent-ruby
thread pool.Jerry D'Antonio
Implement
provider_job_id
forqueue_classic
adapter. This requires the latest, currently unreleased, version of queue_classic.Yves Senn
assert_enqueued_with
andassert_performed_with
now returns the matched job instance for further assertions.Jean Boussier
Include
I18n.locale
into job serialization/deserialization and use it aroundperform
.Fixes #20799.
Johannes Opper
Allow
DelayedJob
,Sidekiq
,qu
, andque
to report the job id back to ::ActiveJob::Base asprovider_job_id
.Fixes #18821.
Kevin Deisz, Jeroen van Baarsen
assert_enqueued_jobs
andassert_performed_jobs
in block form use the given number as expected value. This makes the error message much easier to understand.y-yagi
A generated job now inherits from
app/jobs/application_job.rb
by default.Jeroen van Baarsen
Add ability to configure the queue adapter on a per job basis.
Now different jobs can have different queue adapters without conflicting with each other.
Example:
class EmailJob < ActiveJob::Base self.queue_adapter = :sidekiq end class ImageProcessingJob < ActiveJob::Base self.queue_adapter = :delayed_job end
tamird
Add an
:only
option toperform_enqueued_jobs
to filter jobs based on type.This allows specific jobs to be tested, while preventing others from being performed unnecessarily.
Example:
def test_hello_job assert_performed_jobs 1, only: HelloJob do HelloJob.perform_later('jeremy') LoggingJob.perform_later end end
An array may also be specified, to support testing multiple jobs.
Example:
def test_hello_and_logging_jobs assert_nothing_raised do assert_performed_jobs 2, only: [HelloJob, LoggingJob] do HelloJob.perform_later('jeremy') LoggingJob.perform_later('stewie') RescueJob.perform_later('david') end end end
Fixes #18802.
Michael Ryan
Allow keyword arguments to be used with Active Job.
Fixes #18741.
Sean Griffin
Add
:only
option toassert_enqueued_jobs
, to check the number of times a specific kind of job is enqueued.Example:
def test_logging_job assert_enqueued_jobs 1, only: LoggingJob do LoggingJob.perform_later HelloJob.perform_later('jeremy') end end
George Claghorn
ActiveJob::Base.deserialize
delegates to the job class.Since
ActiveJob::Base#deserialize
can be overridden by subclasses (likeActiveJob::Base#serialize
) this allows jobs to attach arbitrary metadata when they get serialized and read it back when they get performed.Example:
class DeliverWebhookJob < ActiveJob::Base def serialize super.merge('attempt_number' => (@attempt_number || 0) + 1) end def deserialize(job_data) super @attempt_number = job_data['attempt_number'] end rescue_from(TimeoutError) do |exception| raise exception if @attempt_number > 5 retry_job(wait: 10) end end
Isaac Seymour
Please check 4-2-stable for previous changes.


I will convert your Excel data into one of several web-friendly formats, including HTML, JSON and XML.
Fork me on github.
Delimiter: Auto Comma Tab
Decimal Sign: Dot Comma
Convert formatted number to standard number.
Thousand Separator: Dot Comma Space Apostrophe None
Check for Indian Currency (eg: 1,37,489.38)
First row is the header
Transform: downcase upcase none
Include white space in output
Indent with: tabs spaces


Type in a value in a filter field that will return no results. The no search results empty message should be shown


MVEL is an expression language based on Java-syntax, with some marked differences specific to MVEL. Unlike Java however, MVEL is dynamically typed (with optional typing), meaning type qualification is not required in the the source.
An MVEL expression can be as simple as a single identifier, or as complicated as a full blown boolean expression with method calls and inline collection creations.
In this expression, we simply have a single identifier (user.name),
which by itself, is what we refer to in MVEL as a a property
expression, in that the only purpose of the expression is to
extract a property out of a variable or context object.
Property expressions are one of the most common uses, allowing MVEL
to be used as a very high performance, easy to use,
reflection-optimizer.
MVEL can even be used for evaluating a boolean expression:
user.name == 'John Doe'
Like Java, MVEL supports the full gambit of operator precedence
rules, including the ability to use bracketing to control execution
order.
(user.name == 'John Doe') && ((x * 2) - 1) > 20
The following chart is a complete list and description of all operators present in MVEL.
Operator |
Description |
Example |
|---|---|---|
new |
Object instantiation |
new String("foo") |
with |
Block WITH Operator. Perform multiple operations on a single object instance |
with (value) { name = 'Foo', age = 18, sex = Sex.FEMALE } |
assert |
Assert that a value is true or fail with an AssertionError |
assert foo != null |
isdef |
Tests whether or not a variable is defined within the scope |
isdef variableName |
! |
Boolean negation operator |
!true == false |
Operator |
Description |
Example |
|---|---|---|
== |
Equality Check. Checks to see if the values
on both sides of the operator are equal.
Unlike Java, this is not an identity check. |
"foo" == "foo" is true |
!= |
Not Equals Check. Checks to see if the values
on both sides of the operator are not equal. |
"foo" == "bar" is false |
> |
Greater Than Check. Checks to see if the value on the
left side of the operator is greater than than value on the
right. |
2 > 1 is true |
< |
Less Than Check. Checks to see if the value on the left
side of the operator is less than value on the right. |
1 < 2 is true |
>= |
Greater Than or Equal. Checks to see if the value on the
left hand side is greater than or equal to the value on the
right. |
1 >= 1 is true |
<= |
Less Than or Equal. Checks to see if the value on the
left hand side is less than or equal to the value on the right.
|
2 <= 2 is true |
contains |
Value Containment Check. Checks to see if the value on
the left contains the value on the right. For more
details on how this operator works, see Contains Operator |
var contains "Foo" |
is or instanceof |
Type Checking Operator. Checks to see if the value on the
left is a member of the class on the right. |
var instanceof Integer |
strsim |
String Similarity Check. Compares to strings and returns
a similarity between them as a percentage. See: String Similarity Check. |
"foobie" strsim "foobar" |
soundslike |
Soundex Check. Performs a soundex comparison between two
strings. See: Soundex. |
"foobar" soundslike "fubar" |
Operator |
Description |
Example |
|---|---|---|
&& |
Logical AND. Checks to see that the values on both sides
of the operator are true. |
foo && bar |
|| |
Logical OR. Checks to see if either the value on the left
or the right is true. |
foo || bar |
or |
Chained OR. Checks a sequence of values for emptiness and returns the first
non-empty value. (This operator, or at least it's equivalent
functionality, is referred to as the "elvis operator" in other
languages) |
foo or bar or barfoo or 'N/A' |
~= |
Regular Expression Match. Checks to see if the value on
the left matches the regular expression on the right. |
foo ~= '[a-z].+' |
Operator |
Description |
Example |
|---|---|---|
& |
Bitwise AND. |
foo & 5 |
| |
Bitwise OR. |
foo | 5 |
^ |
Bitwise XOR. |
foo ^ 5 |
Operator |
Description |
Example |
|---|---|---|
+ |
Addition. Adds the value on the left to the value on the
right |
1 + 2 |
- |
Subtraction. Subtracts the value on the right from the
value on the left |
2 - 1 |
/ |
Division. Divides the number on the left by the number on
the right |
2 / 1 |
* |
Multiplication. Multiples the number on the left by the
number on the right |
1 * 2 |
% |
Modulus. Divides the number on the left by the number on
the right and returns the remainder. |
2 % 1 |
Operator |
Description |
Example |
|---|---|---|
+ |
String Concatenation. Overloaded operator for
concatenating two strings together. |
"foo" + ;bar" |
# |
Concatenation
Operator. Concatenates two literals as strings. |
1 # 2 returns "12" |
in |
Projection/Fold. Projects across a collection. See: Projections and
Folds. |
(foo in list) |
= |
Assignment. Assigns the value on the right to the
variable on the left. |
var = "foobar" |
MVEL allows you to express Lists, Maps and Arrays using simple elegant syntax. Consider the following example:
['Bob' : new Person('Bob'), 'Michael' : new Person('Michael')]
This is functionally equivalent to the following code:
Map map = new HashMap(); map.put("Bob", new Person("Bob")); map.put("Michael", new Person("Michael"));
This can be a very powerful way to express data structures inside of MVEL. You can use these constructs anywhere, even as a parameter to a method:
something.someMethod(['foo' : 'bar']);
Lists are expressed in the following format: [item1, item2, ...]
For example:
["Jim", "Bob", "Smith"]
Maps are expressed in the following format: [key1 : value1, key2: value2, ...]
For example:
["Foo" : "Bar", "Bar" : "Foo"]
Arrays are expressed in the following format: {item1, item2, ...}
For example:
{"Jim", "Bob", "Smith"}
One important facet about inline arrays to understand is their special ability to be coerced to other array types. When you declare an inline array, it is untyped, but say for example you are passing to a method that accepts int[]. You simply can write your code as the following:
foo.someMethod({1,2,3,4});
In this case, MVEL will see that the target method accepts an int[] and automatically type the array as such.
A literal is used to represent a fixed-value in the source of a particular script.
String literals may be denoted by single or double quotes.
"This is a string literal" 'This is also string literal'
\\
- Double escape allows rendering of single
backslash in string.\n
- Newline\r
- Return\u####
- Unicode character (Example: \uAE00
)\###
- Octal character (Example: \73
)Integers can be represented in decimal (base 10), octadecimal (base 8), or hexadecimal (base 16).
A decimal integer can be expressed as any number that does not start with zero.
125 // decimal
An octadecimal representation of an integer is possible by prefixing the number with a zero, followed by digits ranging from 0 to 7.
0353 // octal
Hexidecimal is represented by prefixing the integer with
0x
followed by numbers ranging from 0-9..A-F.
0xAFF0 // hex
A floating point number consists of a whole number and a factional part denoted by the point/period character, with an optional type suffix.
10.503 // a double 94.92d // a double 14.5f // a float
You can represent
BigInteger
and
BigDecimal
literals by using the suffixes B
and I
(uppercase is mandatory).
104.39484B // BigDecimal 8.4I // BigInteger
Boolean literals are represented by the reserved keywords true
and false
.
The null literal is denoted by the reserved keywords null
or nil
.
Put simply, projections (also known as list comprehensions) are a way of representing collections. Using a very simple syntax, you can inspect very complex object models inside collections.
Imagine you have a collection of User objects. Each of these objects has a Parent. Now say you want to get a list of all names of the parents (assuming the Parent class has a name field) in the hierarchy of users, you would write something like this:
parentNames = (parent.name in users);
You can even perform nested operations. Imagine instead, that the User object had a collection member called familyMembers, and we wanted a list of all the family members names:
familyMembers = (name in (familyMembers in users));
You can also filter projections with a constraint with the if
operator:
(doSomeMethod() in listOfThings if $.shouldBeRun())
$
serves as the placeholder for the
element being filtered. It is actually a regular variable that
exists inside the context of the projection. You can also use it to
return the current element in the projection to the representative
list.
($ in fooList if $.name contains 'foobie')
Here are some more examples:
(toUpperCase() in ["foo", "bar"]); // returns ["FOO", "BAR"] (($ < 10) in [2,4,8,16,32]); // returns [true, true, true, false, false] ($ in [2,4,8,16,32] if $ < 10); // returns [2,4,8]
Here is a functional Quicksort algorithm implemented using projections:
/** * Sample MVEL 2.0 Script * "Functional QuickSort" * by: Christopher Michael Brock, Inspired by: Dhanji Prasanna */ import java.util.*; // the main quicksort algorithm def quicksort(list) { if (list.size() <= 1) { list; } else { pivot = list[0]; concat(quicksort(($ in list if $ < pivot)), pivot, quicksort(($ in list if $ > pivot))); } } // define method to concatenate lists. def concat(list1, pivot, list2) { concatList = new ArrayList(list1); concatList.add(pivot); concatList.addAll(list2); concatList; } // create a list to sort list = [5,2,4,1,18,10,15,1,0]; // sort it! quicksort(list);
MVEL allows the definition of lambda functions.
A simple lambda expression
threshold = def (x) { x >= 10 ? x : 0 }; result = cost + threshold(lowerBound);
The above example defines a lambda and assigns it to the variable "threshold". Lambda's are essentially functions that are assignable to variables. They are essentially closures and can be used as such.


Into the Blue
Into the Blue is a movie starring Paul Walker, Jessica Alba, and Scott Caan. A group of divers find themselves in deep trouble with a drug lord after they come upon the illicit cargo of a sunken airplane.


If you need to put mask on specific element, change on z-index
or message,
you can set it on mask.setConfig
mask.open
method can set mask additional configuration on.
Paste the following code into the <head>
section of your site's HTML.
Javascript
Declare Mask UI default configuration in advance. Whenever open method is called, its default configuration is applied as inheritance
Mask settings can change the following four attributes.


Teen Hospitalised After Lip Fillers Left Her With ‘Deformed, Rock-Solid Sausage Lips’
by Emily BrownWarning: Graphic Content
A teenager had to spend days in hospital after a lip filler appointment left her with ‘sausage lips’ that oozed green pus.
Advertisements
Lauren Winstanley, from Wigan, Greater Manchester, went to the salon last month in an attempt to transform her ‘small’ lips into a full pout which would allow her to ‘properly’ wear lip liner and lipstick.
The 18-year-old paid £170 to have the fillers injected at a salon where she regularly gets manicures and eyebrow treatments, and the beautician talked her through the procedure before putting numbing cream on Lauren’s lips and injecting them.
Advertisements
Lauren was keen to have ‘plumper’ lips but her excitement soon turned to shock when her mouth started to balloon up.
Recalling the incident, Lauren explained the beautician assured her the swelling would go down but instead the opposite happened and the 18-year-old’s grew ‘bigger and bigger’ over the next few hours.
The teenager, who works as a carer, said:
They started swelling straight away, when I looked in the mirror at them I was shocked because I’d never seen myself with bigger lips.
They were hurting ahead of my night shift starting and over the next few hours they grew bigger and bigger and ended up triple the size they should be.
When I left work my bottom lip in particular was massive and it was starting to feel really sore.
Lauren went to bed with the hope the swelling would go down while she slept but she woke up to find her lips hurt even more than before. Panicked, she messaged the beautician to tell her she was worried about her lips.
Advertisements
The salon worker continued to assure the teen that the reaction was ‘normal’, though she admitted Lauren may have suffered a non-serious allergic reaction and encouraged her to take antihistamines.
After suffering with sore and swollen lips for a day, Lauren decided to go to hospital to get them checked out. Staff assessed her lips and sent her home with a course of antibiotics and painkillers but the pain only continued.
Lauren commented:
Advertisements
I was crying because I was in that much pain, when I looked in the mirror I remember thinking I looked deformed, it was vile.
My lips looked like rock solid sausages and felt bruised and were stinging.
I started to feel sick, had a temperature and my neck and cheek felt bruised.
The concerned teen decided to call 999 and she was rushed to Whiston Hospital in Rainhill, Merseyside, where doctors conducted blood tests and found Lauren had Group A strep infection.
The 18-year-old continued:
I couldn’t eat or drink as my lips were still triple their usual size and kept growing and filling with green and yellow pus.
They were that full under my lip you could see little white holes, which was the infection working its way out of my lip.
I could feel my chin keep getting wet from the infection in my lip leaking out.
When I looked at myself in the mirror it knocked me sick, my lips were disgusting. I have really bad low self-esteem as it is and this was making me feel worse. Thinking I could lose my lip was also freaking me out.
Lauren was hooked up to an IV drip before undergoing surgery to drain the infection and remove infected filler, though the suffering woman ‘begged’ doctors to put her to sleep while they drained her lips because she was ‘in agony’.
She spent a week in hospital as a result of the lip fillers before being sent home with antibiotics and painkillers, though she is still living with after-effects of the procedure, including lumpy lips, a partial loss of sensation and pain when she presses down on her lower lip.
After her ordeal, Lauren learned the beautician had trained less than five months earlier. Though she had treated some of the 18-year-old’s friends, Lauren admitted she would have had her fillers done elsewhere if she knew how inexperienced the salon worker was.
The teen decided to share her ordeal to urge people to do their research before going under the needle, explaining:
I wish I’d have paid extra and had it done by someone medically trained like a dentist or dermal nurse.
It’s put me off getting them done again in future. I would never wish that pain on anyone, it was traumatising.
Professor Ash Mosahebi, Council Member for The British Association of Aesthetic Plastic Surgeons, explained:
Giving treatments in a non-clinical environment without backup and emergency facilities is hazardous even in the expert hand.
When this is combined with poorly trained practitioner then it is a recipe for disaster.
The beautician who injected Lauren’s fillers believes the incident was a result of an ‘infection’ Lauren got which was not related to the filler.
Emily Brown first began delivering important news stories aged just 13, when she launched her career with a paper round. She graduated with a BA Hons in English Language in the Media from Lancaster University, and went on to become a freelance writer and blogger. Emily contributed to The Sunday Times Travel Magazine and Student Problems before becoming a journalist at UNILAD, where she works on breaking news as well as longer form features.


Hands on Artificial Intelligence Robotics
with NAO robot
City Library, City of Adelaide
National Science Week
19 August 2017
What we'll do today?
- Learn basics about NAO robot
- Create programs in Choregraphe to control NAO Robot
- Exercise 1:
- Exercise 2:
- Exercise 3:
- Exercise 4:
1. NAO Robot basics
- What is a Robot?
- A robot is an intelligent system that interacts with the physical environment through sensors and effectors.
- NAO is a humanoid robot developed by Aldebaran Robotics, a French robotics company
- 58-cm tall, 5-kg
- NAO is a completely programmable, autonomous, and interactive robot
NAO sensors and kinematics
- Tactile sensors: Head, Hand, Foot
- Cameras, speakers, microphones, Sonars, joint position sensors, accelerometer
- 25 degrees of freedom
- Turning stiffness on and off - wake up / sleep
- Move NAO’s arm from robot view
Choregraphe software
- Node based code editor (like Scratch or Dynamo)
- Developed by Softbanks
- Drag and drop code “boxes”
Exercise 1: Hello world with NAO
- Make NAO talk and walk with Choregraphe
- Using “Animated say”, make NAO wave and talk
- Make NAO walk a set distance
Animation mode
- Used to create movements from a series of poses
- Controlling motor stiffness
- Adding keyframes to animation timeline
- Keyframes can be copied
Exercise 2: Making NAO dance
- Make NAO raise an arm using animation mode
Autonomous life
- NAO has Basic Awareness enabled, Breathing animation, Speech Recognition and replies using Animated Say
- “Interactive”: one-to-one interaction
- “Solitary”: listening and responding to stimulus from the environment
Exercise 3: Conversations with NAO
- Demo NAO’s autonomous capabilities
Exercise 4: Facial recognition
- Make NAO learn a face and respond if it sees a recognised face
Further programming
- Expand NAO’s capabilities with Python, C++, Java (and more)
Acknowledgements
- Much of the programs shown here were developed while the author was working as NAO Robot Innovator in Residence at the City Library, City of Adelaide, South Australia.
- Thanks to Innovator in Residence peers Helton and Saman.


Table of Contents
To the untrained eye, a camera is simply a box with a button that takes a screen capture of what you point it at. In reality, the physical mechanics of the device is a miracle that is centuries in the making. The oldest known record of a camera was as early as 470 B.C. by the Chinese. They had discoverd the "camera obscura" which is Latin for "Dark room," its the phenomenon and physics behind how a camera works. It's a natural occurence that when an image of a scene on one side of a screen is projected through a small hole, it forms an inverted image on the opposite side of the screen. Over the duration of mankind, we have developed and manipulated this idea to create the cameras we use today. To put it simply, think about a polaroid camera.  Behind that hole is a square photosensitive piece of paper that when exposed to light, the light is burned into the paper. When you point the camera at the object, press the shutter, the hole is revealed and camera obscura happens in milliseconds. The image is inverted onto the photo- sensitive paper, burns the image onto the paper, and prints it out. Certain chemicals fix the image onto the paper which stops the developing process when printed.


After four nervy months, [Gladstone] came close to proposing at the Coliseum on a moonlit January evening. A few days later he did it instead by letter. It was not a proposal to sweep a young girl off her feet.
“I seek much in a wife in gifts better than those of our human pride, and am also sensible that she can find little in me,” he wrote, in a single long-winded sentence, “sensible that, were you to treat this note as the offspring of utter presumption, I must not be surprised: sensible that the life I invite you to share, even if it be not attended, as I trust it is not, with peculiar disadvantages of an outward kind, is one, I do not say unequal to your deserts, for that were saying little, but liable at best to changes and perplexities and pains which, for myself, I contemplate without apprehension, but to which it is perhaps selfishness in the main, with the sense of inward dependence counteracting an opposite sense of my too real unworthiness, which would make me contribute to expose another—and that other!”
On receiving the letter Catherine pleaded for time, no doubt hoping it would give her the opportunity to work out exactly what Gladstone meant.*
*”He really was a frightful old prig,” wrote Clement Attlee… on reading this letter in a biography of Gladstone, “Fancy writing a letter proposing marriage including a sentence of 140 words all about the Almighty. He was a dreadful person.”
from The Lion And The Unicorn : Gladstone vs Disraeli by Richard Aldous (2006)