{% extends "base-documentation.html" %} {% block documentation %}
While you can interact with Liftpass via the API - a more user friendly way is to use the Dashboard. It requires no sophisticated server to run it as it is a standalone web application. It comes as part of the documentation that is built with Liftpass.
For more information on how to build and run the Dashboard can be found in the How To section.


The council shall have the power:
To plan, design, construct, acquire, repair, reconstruct, operate and maintain within and without the city, facilities for the handling of storm waters and other surface waters.
To regulate the construction, repair, reconstruction, operation and maintenance by others of such facilities.


Getting Started with feems
¶
This notebook illustrates a minimal example of how to run feems
on a dataset of North American gray wolves published in Schweizer et al. 2015.
Imports¶
First we import the required packages and feems
:
[191]:
# base
import math
import numpy as np
import pkg_resources
from sklearn.impute import SimpleImputer
from pandas_plink import read_plink
from sklearn.metrics.pairwise import haversine_distances
from scipy.spatial.distance import pdist, squareform
import statsmodels.api as sm
import pickle
# viz
import matplotlib.pyplot as plt
from matplotlib import gridspec
import cartopy.crs as ccrs
# feems
from feems.utils import prepare_graph_inputs
from feems import SpatialGraph, Viz, Objective, query_node_attributes
from feems.cross_validation import run_cv, comp_mats
# change matplotlib fonts
plt.rcParams["font.family"] = "Arial"
plt.rcParams["font.sans-serif"] = "Arial"
def cov_to_dist(S):
s2 = np.diag(S).reshape(-1, 1)
ones = np.ones((s2.shape[0], 1))
D = s2 @ ones.T + ones @ s2.T - 2 * S
return(D)
Data¶
Note we have packaged this example dataset in the feems
package and use the pkg_resources
package to find the path of those files:
[2]:
data_path = pkg_resources.resource_filename("feems", "data/")
Next we read the plink
formatted genotype data and impute any missing SNPs with the mean at each SNP:
[3]:
# read the genotype data and mean impute missing data
(bim, fam, G) = read_plink("{}/wolvesadmix".format(data_path))
imp = SimpleImputer(missing_values=np.nan, strategy="mean")
genotypes = imp.fit_transform((np.array(G)).T)
n, p = genotypes.shape
print("n_samples={}, n_snps={}".format(genotypes.shape[0], genotypes.shape[1]))
Mapping files: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 49.77it/s]
n_samples=111, n_snps=17729
As we can see we have 111 samples and 17,729 SNPs. For preparing the graph inputs to run feems
you have two options:
Prepare your own input files
Use the
feems
functionprepare_graph_inputs
which intersects a discrete global grid (DGG) with the sample range
We’ll show off the later option. We read the sample coordinates (coords
), coordinates of the outer polygon that defines the habitat of the sample (outer
) and a discrete global grid file which has laid down a triangular grid that is uniformly spaced on earth (grid_path
). We then intersect this global grid with the outer file to define the graph that we use to optimize (edges
and grid
):
[4]:
%%time
# setup graph
coord = np.loadtxt("{}/wolvesadmix.coord".format(data_path)) # sample coordinates
outer = np.loadtxt("{}/wolvesadmix.outer".format(data_path)) # outer coordinates
grid_path = "{}/grid_100.shp".format(data_path) # path to discrete global grid
# graph input files
outer, edges, grid, _ = prepare_graph_inputs(coord=coord,
ggrid=grid_path,
translated=True,
buffer=0,
outer=outer)
CPU times: user 5.18 s, sys: 70.2 ms, total: 5.25 s
Wall time: 5.28 s
Lets take a peek at each of these inputs:
[6]:
outer[:5, ]
[6]:
array([[-126.2547116, 48.6329086],
[-127.5731488, 49.1817034],
[-128.9351421, 50.1205781],
[-130.2099765, 50.930738 ],
[-131.8797738, 51.8900539]])
[7]:
edges[:5, ]
[7]:
array([[838, 839],
[357, 386],
[605, 637],
[536, 537],
[136, 158]])
[8]:
grid[:5, ]
[8]:
array([[-166.637, 59.732],
[-166.585, 60.675],
[-166.529, 61.623],
[-168.75 , 62.088],
[-166.467, 62.576]])
Setup the SpatialGraph
object¶
We then setup the SpatialGraph
object which is the core workhorse of feems
. SpatialGraph
specifies the graph, allele frequency data, and runs the optimizers to fit the edge weights of the graph:
[5]:
%%time
sp_graph = SpatialGraph(genotypes, coord, grid, edges, scale_snps=True)
CPU times: user 1min 51s, sys: 2.94 s, total: 1min 54s
Wall time: 1min 54s
This might take a few minutes to construct at first b/c it initializing a number of graph matrices that are slow to build. First, before any fitting we’ll visualize the graph and samples. Let’s setup the projection we’ll be using for this dataset:
[57]:
projection = ccrs.EquidistantConic(central_longitude=-108.842926, central_latitude=66.037547)
Now lets make a map of the sample coordinates, graph and observed nodes:
[58]:
fig = plt.figure(dpi=300)
ax = fig.add_subplot(1, 1, 1, projection=projection)
v = Viz(ax, sp_graph, projection=projection, edge_width=.5,
edge_alpha=1, edge_zorder=100, sample_pt_size=10,
obs_node_size=7.5, sample_pt_color="black",
cbar_font_size=10)
v.draw_map()
v.draw_samples()
v.draw_edges(use_weights=False)
v.draw_obs_nodes(use_ids=False)
The black points are the observed locations for each sample and the gray points show the nodes that samples were assigned to. The gray lines represent the graph that will be fitted.
Initial test run of feems
with \(\lambda =1\)¶
To test everything is working, let’s make an initial run of feems
with the regularization parameter \(\lambda\) set to 1.
If you see an initial feems
output map, continue onwards to help choose \(\lambda\) using cross-validation and to inspect your outputs more carefully.
If using your own data (rather than the wolf data), and you get an error at this point, it may be because your input data may have pecularities (e.g. duplicate individuals, monomorphic loci, pairs of loci that are in complete LD). One check on this is to inspect the sample covariance matrix and make sure there are no negative eigenvalues (see the ‘Miscellaneous’ section below).
[196]:
%%time
fig = plt.figure(constrained_layout=True, dpi=300, figsize=(6, 6))
spec = gridspec.GridSpec(ncols=1, nrows=2, figure=fig)
lamb=2.0
sp_graph.fit(lamb = lamb)
ax = fig.add_subplot(2, 1, 1, projection=projection)
v = Viz(ax, sp_graph, projection=projection, edge_width=.5,
edge_alpha=1, edge_zorder=100, sample_pt_size=20,
obs_node_size=7.5, sample_pt_color="black",
cbar_font_size=10)
v.draw_map()
v.draw_edges(use_weights=True)
v.draw_obs_nodes(use_ids=False)
v.draw_edge_colorbar()
constant-w/variance fit, converged in 132 iterations, train_loss=2795677.6543430
lambda=2.0000000, alpha=0.8354260, converged in 86 iterations, train_loss=2767069.6406216
CPU times: user 9.46 s, sys: 1.25 s, total: 10.7 s
Wall time: 3.67 s
Fit feems
with cross-validation¶
We’ll fit FEEMS across a grid of possible regularization values and choose the one that minimizes the cross-validation error. This will take approximately 15 minutes on a single CPU. If you want to skip this step for time reasons, you can set ‘LoadCVFromDisk’ in the second code block (or set lamb_cv to 0.77 manually) and skip ahead past this code block and the next.
[12]:
%%time
LoadCVFromDisk = True
# define grid
# Publication grid for this dataset
#lamb_grid = np.geomspace(1e-6, 1e2, 20)[::-1]
# Exploratory grid:
lamb_grid = np.geomspace(1e-4, 1e1, 10)[::-1]
# run cross-validation
if not LoadCVFromDisk:
cv_err = run_cv(sp_graph, lamb_grid, n_folds=sp_graph.n_observed_nodes, factr=1e10)
pickle.dump(cv_err,open("cv_err.pkl","wb"))
CPU times: user 237 µs, sys: 29 µs, total: 266 µs
Wall time: 243 µs
Now we plot the CV error:
[13]:
LoadCVFromDisk = True
if LoadCVFromDisk:
cv_err = pickle.load(open("cv_err.pkl","rb"))
# average over folds
mean_cv_err = np.mean(cv_err, axis=0)
# argmin of cv error
lamb_cv = float(lamb_grid[np.argmin(mean_cv_err)])
fig, ax = plt.subplots(dpi=300)
ax.plot(np.log10(lamb_grid), mean_cv_err, ".");
ax.set_xlabel("log10(lambda)");
ax.set_ylabel("L2 CV Error");
ax.axvline(np.log10(lamb_cv), color = "orange")
lamb_cv
[13]:
0.7742636826811278
And then we can refit the model the lambda we found above that minimizes the cross-validation error (‘lamb_cv’), and plot the result.
[213]:
# re-fit
sp_graph.fit(lamb_cv)
# Plot the FEEMS result
fig = plt.figure(dpi=300)
ax = fig.add_subplot(1, 1, 1, projection=projection)
v = Viz(ax, sp_graph, projection=projection, edge_width=.5,
edge_alpha=1, edge_zorder=100, sample_pt_size=20,
obs_node_size=7.5, sample_pt_color="black",
cbar_font_size=10)
v.draw_map()
v.draw_edges(use_weights=True)
v.draw_obs_nodes(use_ids=False)
v.draw_edge_colorbar()
constant-w/variance fit, converged in 132 iterations, train_loss=2795677.6543430
lambda=0.7700000, alpha=0.8354260, converged in 97 iterations, train_loss=2761102.8933011
Comparing the fitted distances model to geographic distances and a “simple” isolation-by-distance mdoel¶
We next want to inspect how these spatial models perform in terms of representing the genetic distances in the data. Let’s produce a figure showing observed genetic distances vs great circle geographic distances, vs distances in a model fit with constant migration weights (w), and vs the distances fitted in the model with varying w and regularization matching our cross-validation chosen value of \(\lambda\).
[192]:
def cov_to_dist(S):
s2 = np.diag(S).reshape(-1, 1)
ones = np.ones((s2.shape[0], 1))
D = s2 @ ones.T + ones @ s2.T - 2 * S
return(D)
# Initialize figure
fig = plt.figure(constrained_layout=True, dpi=300, figsize=(6, 6))
spec = gridspec.GridSpec(ncols=2, nrows=2, figure=fig)
# (A) Genetic distance vs geographic distance
D_geno = squareform(pdist(genotypes, metric="sqeuclidean")) / p
coord_rad = coord[:,::-1] * math.pi / 180.0
D_geo = haversine_distances(coord_rad) * 6371000/1000
tril_idx = np.tril_indices(n, k=-1)
x = D_geo[tril_idx]
y = D_geno[tril_idx]
X = sm.add_constant(x)
mod = sm.OLS(y, X)
res = mod.fit()
muhat, betahat = res.params
ax_00 = fig.add_subplot(spec[0, 0])
ax_00.set_title("A", loc='left')
ax_00.scatter(x,
y,
marker=".",
alpha=1,
zorder=0,
color="black",
s=3)
x_ = np.linspace(np.min(x), np.max(x), 20)
ax_00.plot(x_, muhat + betahat * x_, zorder=2, color="orange", linestyle='--', linewidth=1)
ax_00.text(3500, .6, "R²={:.4f}".format(res.rsquared))
ax_00.set_xlabel("great circle distance (km)")
ax_00.set_ylabel("genetic distance")
# (B) Genetic distance vs fitted distance for constant w model
tril_idx = np.tril_indices(sp_graph.n_observed_nodes, k=-1)
ax_01 = fig.add_subplot(spec[0, 1])
ax_01.set_title("B", loc='left')
sp_graph.fit_null_model()
sp_graph.comp_graph_laplacian(sp_graph.w)
obj = Objective(sp_graph)
fit_cov, _, emp_cov = comp_mats(obj)
fit_dist = cov_to_dist(fit_cov)[tril_idx]
emp_dist = cov_to_dist(emp_cov)[tril_idx]
X = sm.add_constant(fit_dist)
mod = sm.OLS(emp_dist, X)
res = mod.fit()
muhat, betahat = res.params
ax_01.scatter(fit_dist,
emp_dist,
marker=".",
alpha=1,
zorder=0,
color="black",
s=3)
x_ = np.linspace(np.min(fit_dist), np.max(fit_dist), 20)
ax_01.plot(x_, muhat + betahat * x_, zorder=2, color="orange", linestyle='--', linewidth=1)
ax_01.text(4.2, 2, "R²={:.4f}".format(res.rsquared))
ax_01.set_xlabel("fitted distance (constant w)")
# (C) Genetic distance vs fitted distance for lambda = lambda_cv
tril_idx = np.tril_indices(sp_graph.n_observed_nodes, k=-1)
ax_10 = fig.add_subplot(spec[1, 0])
ax_10.set_title("C", loc='left')
lamb = lamb_cv
sp_graph.fit(lamb=lamb,
lb=math.log(1e-6),
ub=math.log(1e+6))
sp_graph.comp_graph_laplacian(sp_graph.w)
obj = Objective(sp_graph)
fit_cov, _, emp_cov = comp_mats(obj)
fit_dist = cov_to_dist(fit_cov)[tril_idx]
emp_dist = cov_to_dist(emp_cov)[tril_idx]
X = sm.add_constant(fit_dist)
mod = sm.OLS(emp_dist, X)
res = mod.fit()
muhat, betahat = res.params
ax_10.scatter(fit_dist,
emp_dist,
marker=".",
alpha=1,
zorder=0,
color="black",
s=3)
x_ = np.linspace(np.min(fit_dist), np.max(fit_dist), 20)
ax_10.plot(x_, muhat + betahat * x_, zorder=2, color="orange", linestyle='--', linewidth=1)
ax_10.text(4.2, 2, "R²={:.4f}".format(res.rsquared))
ax_10.set_xlabel("fitted distance ($\lambda = \lambda_{CV}$)")
ax_10.set_ylabel("genetic distance")
# (D) Genetic distance vs fitted distance for lambda = 1e-3*lambda_cv
tril_idx = np.tril_indices(sp_graph.n_observed_nodes, k=-1)
ax_11 = fig.add_subplot(spec[1, 1])
ax_11.set_title("C", loc='left')
lamb = 0.001*lamb_cv
sp_graph.fit(lamb=lamb,
lb=math.log(1e-6),
ub=math.log(1e+6))
sp_graph.comp_graph_laplacian(sp_graph.w)
obj = Objective(sp_graph)
fit_cov, _, emp_cov = comp_mats(obj)
fit_dist = cov_to_dist(fit_cov)[tril_idx]
emp_dist = cov_to_dist(emp_cov)[tril_idx]
X = sm.add_constant(fit_dist)
mod = sm.OLS(emp_dist, X)
res = mod.fit()
muhat, betahat = res.params
ax_11.scatter(fit_dist,
emp_dist,
marker=".",
alpha=1,
zorder=0,
color="black",
s=3)
x_ = np.linspace(np.min(fit_dist), np.max(fit_dist), 20)
ax_11.plot(x_, muhat + betahat * x_, zorder=2, color="orange", linestyle='--', linewidth=1)
ax_11.text(4.2, 2, "R²={:.4f}".format(res.rsquared))
ax_11.set_xlabel("fitted distance ($\lambda = \lambda_{CV}\cdot 10^{-3}$)")
ax_11.set_ylabel("genetic distance")
constant-w/variance fit, converged in 132 iterations, train_loss=2795677.6543430
constant-w/variance fit, converged in 132 iterations, train_loss=2795677.6543430
lambda=0.7700000, alpha=0.8354260, converged in 96 iterations, train_loss=2761102.8751542
constant-w/variance fit, converged in 132 iterations, train_loss=2795677.6543430
lambda=0.0007700, alpha=0.8354260, converged in 1585 iterations, train_loss=2744773.8668649
[192]:
Text(0, 0.5, 'genetic distance')
While comparing the \(R^2\) values of a linear fit is an informal exercise, what is the relative ordering of the different predictors of genetic distance in terms of their \(R^2\) values?
In the final panel we decreased the value of \(\lambda\) below \(\lambda_{CV}\) and got a higher \(R^2\), but how should the two values of the cross-validation error compare?
Inspect the observed vs fitted covariances on sampled demes¶
It’s helpful to see what pairs of demes may not be fit by the model well. Let’s look at the fitted and observed demic covariance matrices and plot pairs of demes with the largest residuals. We use the variable \(K\) belowo to affect how many pairs we will look at.
[227]:
K = 50
# Plot Observed vs Fitted Covariances and residuals
obj = Objective(sp_graph)
fit_cov, _, emp_cov = comp_mats(obj)
# Set diagonals to zero to focus on covariances
np.fill_diagonal(fit_cov,0)
np.fill_diagonal(emp_cov,0)
# Plot matrices
fig = plt.figure(figsize = [15,5])
ax1 = fig.add_subplot(141)
ax1.imshow(emp_cov, interpolation='nearest')
ax1.set_xlabel("empirical covariance")
ax2 = fig.add_subplot(142)
ax2.imshow(fit_cov, interpolation='nearest')
ax2.set_xlabel("fitted covariance")
ax3 = fig.add_subplot(143)
ax3.imshow(emp_cov-fit_cov, interpolation='nearest')
ax3.set_xlabel("residuals")
ax4 = fig.add_subplot(144)
ax4.hist(emp_cov.flatten())
ax4.set_xlabel("empirical covariance")
print("Min empirical covariance {:.2f}".format(np.min(emp_cov)))
print("25th percentile empirical covariance {:.2f}".format(np.percentile(emp_cov,0.25)))
print("75th percentile empirical covariance {:.2f}".format(np.percentile(emp_cov,0.75)))
print("Max empirical covariance {:.2f}".format(np.max(emp_cov)))
# Plot the map with top K poorly fit covariances highlighted
fig = plt.figure(dpi=300)
ax = fig.add_subplot(1, 1, 1, projection=projection)
v = Viz(ax, sp_graph, projection=projection, edge_width=.5,
edge_alpha=1, edge_zorder=100, sample_pt_size=20,
obs_node_size=7.5, sample_pt_color="black",
cbar_font_size=10)
v.draw_map()
v.draw_obs_nodes(use_ids=False)
v.draw_edges(use_weights=True)
#v.draw_edge_colorbar()
# Compute matrix of residuals and order them
res_mat = emp_cov-fit_cov
iu1 = np.triu_indices(res_mat.shape[0])
res_mat[iu1] = 0
abs_res_mat = abs(res_mat)
res_ord=np.argsort(abs_res_mat,axis=None)
permuted_idx = query_node_attributes(v.sp_graph, "permuted_idx")
obs_perm_ids = permuted_idx[: v.sp_graph.n_observed_nodes]
obs_grid = v.grid[obs_perm_ids, :]
for i in range(1,K):
pair = np.unravel_index(res_ord[-i], res_mat.shape)
v.ax.plot(
[obs_grid[pair[0], 0],obs_grid[pair[1],0]],
[obs_grid[pair[0], 1],obs_grid[pair[1],1]],
color = 'gray', linewidth = 0.5
)
v.ax.text(
obs_grid[pair[0], 0],obs_grid[pair[0], 1], str(pair[0]),
horizontalalignment="center", verticalalignment="bottom",
size=v.obs_node_textsize*0.8, zorder=v.obs_node_zorder,
)
v.ax.text(
obs_grid[pair[1], 0],obs_grid[pair[1], 1], str(pair[1]),
horizontalalignment="center", verticalalignment="bottom",
size=v.obs_node_textsize*0.8, zorder=v.obs_node_zorder,
)
v.ax.text(
np.mean([obs_grid[pair[0], 0],obs_grid[pair[1], 0]]),
np.mean([obs_grid[pair[0], 1],obs_grid[pair[1], 1]]),
str("{:.1f}".format(res_mat[pair[0],pair[1]])),
horizontalalignment="center",
verticalalignment="center",
size=v.obs_node_textsize*0.7
)
Min empirical covariance -0.19
25th percentile empirical covariance -0.16
75th percentile empirical covariance -0.15
Max empirical covariance 1.04
From this plot we can see that the genetic simlarity among pairs of locations in the far northwest (e.g. Alaska) are the most difficult to model and the fitted covariances tend to be too large (negative residuals, i.e. there is less empirical covariance than the feems model conveys). There are also some poorly modeled pairs in Baffin Island that have higher empirical covariance than the model conveys. There are also a few sporadic pairs with more covariance than the model conveys.
Varying the regularization¶
Here’s a code block for running a single fit with a pre-specified value of ‘lambda’. Experiment with changing lambda to see the impact of stronger or weaker regularization. There is also an optional portion of the code block to check the cross-validation error for a given \(\lambda\) value.
[201]:
%%time
fig = plt.figure(constrained_layout=True, dpi=300, figsize=(6, 6))
spec = gridspec.GridSpec(ncols=1, nrows=2, figure=fig)
lamb=10
sp_graph.fit(lamb = float(lamb))
ax = fig.add_subplot(2, 1, 1, projection=projection)
v = Viz(ax, sp_graph, projection=projection, edge_width=.5,
edge_alpha=1, edge_zorder=100, sample_pt_size=20,
obs_node_size=7.5, sample_pt_color="black",
cbar_font_size=10)
v.draw_map()
v.draw_edges(use_weights=True)
v.draw_obs_nodes(use_ids=False)
v.draw_edge_colorbar()
fittedVsObserved = True
if fittedVsObserved:
ax1 = fig.add_subplot(2,1,2)
sp_graph.comp_graph_laplacian(sp_graph.w)
obj = Objective(sp_graph)
fit_cov, _, emp_cov = comp_mats(obj)
fit_dist = cov_to_dist(fit_cov)[tril_idx]
emp_dist = cov_to_dist(emp_cov)[tril_idx]
X = sm.add_constant(fit_dist)
mod = sm.OLS(emp_dist, X)
res = mod.fit()
muhat, betahat = res.params
ax1.scatter(fit_dist,
emp_dist,
marker=".",
alpha=1,
zorder=0,
color="black",
s=3)
x = np.linspace(np.min(fit_dist), np.max(fit_dist), 20)
ax1.plot(x_, muhat + betahat * x_, zorder=2, color="orange", linestyle='--', linewidth=1)
ax1.text(4.2, 2, "R²={:.4f}".format(res.rsquared))
ax1.set_xlabel("fitted distance")
ax1.set_ylabel("genetic distance")
CVerr = False
if CVerr:
lamb_grid = np.linspace(lamb,lamb,1)
cv_err_0 = run_cv(sp_graph, lamb_grid, n_folds=sp_graph.n_observed_nodes, factr=1e10)
mean_cv_err_0 = np.mean(cv_err_0, axis=0)
mean_cv_err_0
ax1.text(4.2, 1.5, "CV error={:.4f}".format(float(mean_cv_err_0)))
constant-w/variance fit, converged in 132 iterations, train_loss=2795677.6543430
lambda=10.0000000, alpha=0.8354260, converged in 67 iterations, train_loss=2779012.3618279
CPU times: user 8.92 s, sys: 1.42 s, total: 10.3 s
Wall time: 3.76 s
Challenge exercises¶
Run admixture and PCA on these data and compare the insights to population structure gained from each approach. (Hint: Also see the original Schweizer et al paper and supporting figures in Marcus et al).
Selectively drop samples from the dataset and see how it impacts the results.
Subsample SNPs and see how it impacts the results.
Closing¶
With this workshop you’ve gained some initial experience using feems
. While the cross-validation is time-consuming - individual fits are quick. We encourage experimenting with inclusion/exclusion of samples or markers (and other perturbations) so that you can understand the method better and what signals are robustly found in your data. If you develop interestig ways of parsing the outputs, let us know via email or a pull request!


| Created | Submission UUID | Status | |
|---|---|---|---|
| {{submissionEnvelope.submissionDate | date: "medium"}} | {{getSubmissionUuid(submissionEnvelope)}} |
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
{{submissionEnvelope.submissionState}}
|
|
| Loading your submissions... | |||
| You do not currently have any submissions |


Fine-ding Dining
This application will search for food in your area!
Restaurant Name (no spaces! See example)
Restaurant Type (no spaces!)
zipcode you are looking for (REQUIRED)
Carryout
Reset
Weather
temperature
temperature feels like
description
wind speed


August is not the best period for important decisions but it seems a good time to sketch plans for the second active half of the year. Authorities in several countries have shared their intentions regarding the regulation and oversight of the crypto space. The club of crypto-...
Seems more like 2 lines thrown there with no context
But ultimately. The bottom is wedging so eventually it will burst up
Deleted User17-Aug-18 10:14 AM
siu - Chainmakers17-Aug-18 10:16 AM
It already looks like a done correction. Ita just a matter of time
Deleted User17-Aug-18 10:23 AM
Do Decentralized ICO's have any prerequisites? I was thinking (of course no one would do this but hypothetically) failed ICO's or scam/worthless investments are capital loss events to the ATO.
Hypothetically could a bad actor make an anonymous D-ico of which he invests in it himself, which has 0 value and fails miserably, hence the capital loss of said funds, while he gets to keep the "raised funds" off the books/not in his trade history?
jansako17-Aug-18 10:36 AM
It could be done, in theory. In practice you need to consider: How much money this is, who are you hiding it from (the 'real IRS or a Zimbabwean one?), and is it worth for them to go after you...
Mylo17-Aug-18 10:37 AM
hehe that bottom line should be closer to the red line thru my amateur eye
jansako17-Aug-18 10:38 AM
If it is worth for 'them' to go after you, they will get you once you start spending it, or you need to tax it anyway as income later so you did not really gain anything except pushed the 'income' into later, and there are better ways to do that
Deleted User17-Aug-18 10:50 AM
I mean if they had 3 mil, paid tax on 2 mil, and put the other mil into the ico, that capital loss would make taxable on 1m, so in essence theyve gotten 1m tax paid, 1m taxfree, and 1m "off the books" aka buy gold
@siu - Chainmakers how long do you see before we pump?
siu - Chainmakers17-Aug-18 11:18 AM
I cant talk in terms of timing
Deleted User17-Aug-18 11:19 AM
gotta rush these damn debtors to pay me back
Bittersweet17-Aug-18 11:33 AM
@Deleted User not sure that's what they expect
@siu - Chainmakers if btc shits the bed it's over anyway
siu - Chainmakers17-Aug-18 11:40 AM
Imo btc is about to be short squeezed
Too many newbies thinking they know what they are doing shortig at these levels
siu - Chainmakers17-Aug-18 11:49 AM
Feels the contrary to the top. People take loans to buy at thr top. But they also do thr same to short the bottoms. And it looks like in the trading chats everyone is getting too cozy with shorting to raise margin up to 100x lol(edited)
Deleted User17-Aug-18 11:56 AM
So i should 100x long?
siu - Chainmakers17-Aug-18 11:57 AM
If you fly with the confidence of a bald eagle, then yes
with the coming 1 mln tx/s test coming up, it might be smart to say that it was on mainnet (what it is) because for the last test a lot of people said it doesn't matter on testnet etc.
the chains are real no need to name them test
blackjok3r17-Aug-18 02:11 PM
Ok, they are named TXSCLxxx or Transaction Scale there is no test in there
They are just a massive cluster of Assetchains
the blockchains will be saved, if anyone wants them... although they are expected to be at least 6TB to 10TB of data.

My portfolio is up today
2
Gordon Komodo17-Aug-18 07:11 PM
harry.stall you need colon cleansing, sell all and put it in KMD.(edited)
Cryptoon17-Aug-18 07:38 PM
Poor wrong harry
2
Gordon Komodo17-Aug-18 08:08 PM
the "." disabled me to tag the correct one lol(edited)
Gordon Komodo17-Aug-18 08:36 PM
if we can confine him in trading channel only, it will be fine


{% extends 'base.html' %} {% load static %} {% block content %}
This is an image caption generation model based on the "Show, Attend, and Tell" paper and trained on the Flickr8k dataset.
Parameters used to train the model:
The model is served using Django on an AWS EC2 instance.


Space Travelling Salesman
Player:
Credits:
₡
Time left:
Goods
Stardock
Name
Units
Buy price
Sell price
₡
₡
Destination:
Travel
Cargo
/
Units
Name
Units in cargo
Trade
/
Units
Name
Units on planet
Buy Price
Sell price
Units in cargo
Credits:
(
) ₡
Trade
Sell all
Reset
₡
₡
Buy max
Sell all
Game over!
Your final credits:
₡
Exit to start screen


Request sent
Your reference number is
98HGS3F
What happens next?
Your training provider will log on to their account and start adding apprentice details to the cohort. They’ll then send the cohort back to you for review and approval.


git clone https://github.com/dahfazz/pugrace.git
port: '8880', // The port you want to launch the game on ip: 'localhost' // The IP address you want to launch the game on
$ npm install
$ node app.js > here we go on localhost:8880


Park at the nearest available parking meter without paying the meter and call<PHONE_NUMBER> to report the problem. We will note and approve your alternate location and will investigate the cause of the shortage in your assigned facility.
Park at the nearest available parking meter without paying the meter and call<PHONE_NUMBER> to report the problem. We will note and approve your alternate location and will investigate the cause of the shortage in your assigned facility.
Park at the nearest available parking meter without paying the meter and call<PHONE_NUMBER> to report the problem. We will note and approve your alternate location and will investigate the cause of the shortage in your assigned facility.
Nils Frahm is a German musician, composer and record producer based in Berlin. He is known for combining classical and electronic music and for an unconventional approach to the piano in which he mixes a grand piano, upright piano, Roland Juno-60, Rhodes piano, drum machine, and Moog Taurus.
Agnes Caroline Thaarup Obel is a Danish singer/songwriter. Her first album, Philharmonics, was released by PIAS Recordings on 4 October 2010 in Europe. Philharmonics was certified gold in June 2011 by the Belgian Entertainment Association (BEA) for sales of 10,000 Copies.
Fear of complicated buildings:
A complex complex complex.
Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit sit amet non magna. Maecenas faucibus mollis interdum. Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Sed posuere consectetur est at lobortis.


There is no any task in progress
00:00:00
HH:MM:SS
pause
play_arrow
Break
00:00:00
Achieved task: 0
Task
Description
26/100
Work time:
Short Break:
Long Break:
start
start
start
start
start
Priority
add
Add
play_arrow
Play
Pending Task
add
close
Do you want to add the current task to pending list?
Yes, Add
No, I'm done


TLS termination using your own certificates
The goal of this tutorial is to expose a service via https using a certificate generated by openssl.
If you already have an up and running otoroshi instance, you can skip the following instructions
Let’s start by downloading the latest Otoroshi.
curl -L -o otoroshi.jar 'https://github.com/MAIF/otoroshi/releases/download/v16.8.0/otoroshi.jar'
then you can run start Otoroshi :
java -Dotoroshi.adminPassword=password -jar otoroshi.jar
Now you can log into Otoroshi at http://otoroshi.oto.tools:8080 with<EMAIL_ADDRESS>Create a new route, exposed on http://myservice.oto.tools:8080
, which will forward all requests to the mirror https://mirror.otoroshi.io
. Each call to this service will returned the body and the headers received by the mirror.
curl -X POST 'http://otoroshi-api.oto.tools:8080/api/routes' \
-H "Content-type: application/json" \
-u admin-api-apikey-id:admin-api-apikey-secret \
-d @- <<'EOF'
{
"name": "my-service",
"frontend": {
"domains": ["myservice.oto.tools"]
},
"backend": {
"targets": [
{
"hostname": "mirror.otoroshi.io",
"port": 443,
"tls": true
}
]
}
}
EOF
Try to call the service.
curl 'http://myservice.oto.tools:8080'
This should output something like
{
"method": "GET",
"path": "/",
"headers": {
"host": "mirror.opunmaif.io",
"accept": "*/*",
"user-agent": "curl/7.64.1",
"x-forwarded-port": "443",
"opun-proxied-host": "mirror.otoroshi.io",
"otoroshi-request-id": "1463145856319359618",
"otoroshi-proxied-host": "myservice.oto.tools:8080",
"opun-gateway-request-id": "1463145856554240100",
"x-forwarded-proto": "https",
},
"body": ""
}
Let’s try to call the service in https.
curl 'https://myservice.oto.tools:8443'
This should output
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to myservice.oto.tools:8443
To fix it, we have to generate a certificate and import it in Otoroshi to match the domain myservice.oto.tools
.
If you already had a certificate you can skip the next set of commands and directly import your certificate in Otoroshi
We will use openssl to generate a private key and a self-signed certificate.
openssl genrsa -out myservice.key 4096
# remove pass phrase
openssl rsa -in myservice.key -out myservice.key
# generate the certificate authority cert
openssl req -new -x509 -sha256 -days 730 -key myservice.key -out myservice.cer -subj "/CN=myservice.oto.tools"
Check the content of the certificate
openssl x509 -in myservice.cer -text
This should contains something like
Certificate:
Data:
Version: 1 (0x0)
Serial Number:<PHONE_NUMBER>320067790 (0x84d9fef455f188ce)
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=myservice.oto.tools
Validity
Not Before: Nov 23 14:25:55 2021 GMT
Not After : Nov 23 14:25:55 2022 GMT
Subject: CN=myservice.oto.tools
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (4096 bit)
Modulus:
...
Once generated, go back to Otoroshi and navigate to the certificates management page (top right cog icon / SSL/TLS certificates
or at /bo/dashboard/certificates
) and click on Add item
.
Set myservice-certificate
as name
and description
.
Drop the myservice.cer
file or copy the content to the Certificate full chain
field.
Do the same action for the myservice.key
file in the Certificate private key
field.
Set your passphrase password in the private key password
field if you added one.
Let’s try the same call to the service.
curl 'https://myservice.oto.tools:8443'
An error should occurs due to the untrsuted received certificate server
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
End this tutorial by trusting the certificate server
curl 'https://myservice.oto.tools:8443' --cacert myservice.cer
This should finally output
{
"method": "GET",
"path": "/",
"headers": {
"host": "mirror.opunmaif.io",
"accept": "*/*",
"user-agent": "curl/7.64.1",
"x-forwarded-port": "443",
"opun-proxied-host": "mirror.otoroshi.io",
"otoroshi-request-id": "1463158439730479893",
"otoroshi-proxied-host": "myservice.oto.tools:8443",
"opun-gateway-request-id": "1463158439558515871",
"x-forwarded-proto": "https",
"sozu-id": "01FN6MGKSYZNJYHEMP4R5PJ4Q5"
},
"body": ""
}


Part I: Defensive Techniques and Technologies
The missing documentation for Apple's proprietary security mechanisms
Chapter I: Authentication
1
SetUID and SetGID (MacOS)
3
The Pluggable Authentication Module (MacOS)
4
- Experiment: Tinkering with PAM configuration files
7
- Maintaining permissions
9
- Experiment: Manipulating local users using dscl(1)
10
- Experiment: Manipulating local users using dscl(1) (cont.)
11
Communicating with clients
12
- Experiment: Domonstrating XPC behind the scenes of getXX APIs
13
- com.apple.opendirectoryd.membership
14
- com.apple.opendirectoryd.api
15
- com.apple.opendirectoryd.rpc
15
The LocalAuthentication Framework
16
Chapter 2: Auditing (MacOS)
21
- Auditing Concepts (a refresher)
22
- Experiment: Tweaking and viewing auditing in real time
24
- Figure 2-12: The implementation of auditing in the MacOS kernel
27
- [get/set]auid (#353, #354)
31
- [get/set]audit_addr (#357, #358)
31
- Reading Audit Records
32
- Writing Audit Records
33
Auditing Considerations
34
Chapter 3: Authorization (KAuth)
35
- Authorizing vnode operations
41
KAuth Identity Resolvers (MacOS)
42
- Experiment: Exploring the identitysvc() system call
43
Chapter 4: Mandatory Access Control Framework
45
- Experiment: Finding MAC Policy modules in MacOS and *OS
48
- Experiment: Figuring out policy operations from a disassembly
52
- expose_task (MacOS 10.11)
57
Chapter 5: Code Signing
61
The Code Signature Format
62
- LC_CODE_SIGNATURE and the SuperBlob
62
- Experiment: Code Signature Blobs
63
- The Code Directory Blob
64
Experiment: Viewing Code Signatures
65
- Experiment: Demonstrating the special signature slots
68
- Experiment: Generating (self-signed) code signature
69
Code Signature Requirements
71
- The Requirements Grammar
71
- Encoding requirements
72
- Experiment: Examining requirement blobs
73
- Requirement validation
74
Code Signature Enforcement
77
- Code Signing Weaknesses
81
- Bait-and-Switch inode reuse (< iOS 9)
81
- Lack of validation on __DATA sections and writable memory
82
- Exploiting kernel bugs
82
- Framework-Level Wrappers
84
- Experiment: Locating entitlement producing daemons
85
- DTrace probes (MacOS)
86
Chapter 6: Software Restrictions (MacOS)
89
- The authorization database
90
- Experiment: Examining the authorization database
91
- Experiment: Executing with privileges
93
- Precursor: Quarantine
94
- Experiment: Displaying the quarantine attributes of a file
95
- Experiment: Making sense of the policy database
101
- MacOS 13: Secure Kernel Extension Loading
102
- Testing translocation
104
- Experiment: Behind the scenes of Path Translocation
105
- Experiment: Behind the scenes of Path Translocation (cont.)
106
Managed Clients (MacOS)
107
- Managed Preferences
113
Chapter 7: AppleMobileFileIntegrity
117
AppleMobileFileIntegrity.kext
118
- proc_check_cpumon (*OS)
121
- proc_check_inherit_ipc_ports
121
- proc_check_get_task
122
- proc_check_map_anon (*OS)
123
- proc_check_library_validation
125
- proc_check_mprotect (*OS)
126
- proc_check_run_cs_invalid (*OS)
126
- vnode_check_exec (*OS)
127
- vnode_check_signature
128
- cred_label_update_execve
129
- Exception Handling hooks (MacOS 12+)
130
- Daemon-Kext communication
132
- Experiment: Inspecting amfid Mach messages
134
Provisioning Profiles
139
- Experiment: Examining provisioning profiles
141
- Profile/UDP "databases"
143
The AMFI Trust Caches
147
Chapter 8: The SandBox
149
The Evolution of the Sandbox
150
- (semi)-Voluntary confinement
152
- Experiment: Toying with the App Sandbox
153
- Diagnosing and controlling the App Sandbox
154
Mobile Containers (*OS)
155
- Sandbox profile language
157
- Experiment: Exploring sandbox profiles with sandbox-exec
158
- Table 8-9: Sandbox operations (as of v592)
161
- Exploring: Steps to decompile a sandbox profile
163
- Experiment: Reversing the Sandbox extension token format
166
- sandbox_[un]suspend
167
- sandbox tracing (460+)
168
- User state items (570+)
168
- hook_policy_initbsd
172
- hook_policy_syscall
173
- The Sandbox MACF Hooks
173
- Experiment: Reversing a sandbox hook implementation
174
- Experiment: Reversing a sandbox hook implementation (cont.)
175
- Handling process execution
176
- Daemon-Kext Implementation
180
Chapter 9: System Integrity Protection (MacOS)
181
- Filesystem protections
184
- Debugging protections
184
- Entitlement/Disablement
186
Transparency, Consent and Control
192
- Protected Information
192
- The TCC Database(s)
193
- Experiment: Examining the TCC database
194
- Prompting for access
195
- Experiment: Exploring tccd's XPC interface
197
Unique Device Identifiers
199
Differential Privacy (MacOS 12/iOS 10)
201
Chapter 11: Data Protection
203
Volume-level Encryption (MacOS)
204
- Mounting Encrypted Volumes
206
- corestorage daemons
207
File-level Encryption (*OS)
210
- com.apple.system.cprotect and protection classes
210
- Experiment: Viewing data protection classes
212
- Experiment: Reversing the keybagd XPC interface
220
The AppleKeyStore.kext
221
- Experiment: Inspecting KeyChain internals
227
Part II: Vulnerabilities and Exploitation
A detailed exploration of bugs and their exploits
Chapter 12: MacOS Vulnerabilities
231
10.1: The ntpd remote root (CVE-2014-9295)
232
10.2: The rootpipe privilege escalation (CVE-2015-1130)
234
10.3: Racing Kextd (CVE-2015-3708)
236
10.4: DYLD_PRINT_TO_FILE privilege escalation (CVE-2015-3760)
238
10.5: DYD_ROOT_PATH privilege escalation
240
11.0: tpwn privilege escalation and/or SIP neutering
242
11.3: "Mach Race" local privilege escalation (CVE-2016-1757)
244
11.4: LokiHardt'S Trifecta (CVE-2016-1796,1797,1806)
246
- Arbitrary Code Execution (CVE-2016-1796)
246
- Sandbox Escape (CVE-2016-1797)
248
- SubmitDiagInfo (CVE-2016-1806)
248
Chapter 13: Jailbreaking
253
The jailbreaking process
257
- Running arbitrary (unsigned) code
257
- Getting on the device
257
- Bypassing code signing
258
- Escaping the confines of the Application Sandbox
258
- Elevating Privileges
259
- Reading and Writing Kernel Memory
259
- MACF sysctl patches
261
- Root filesystem remount
268
Kernel Patch Protection
269
- Experiment: Inspecting KPP with joker and jtool
271
- Experiment: Inspecting KPP with joker and jtool (cont.)
272
- Cryptographic algorithm
274
- iOS 10 kernel changes
275
- KTRR (iPhone 7 and later)
275
Evolution of iOS Jailbreaks
279
- Shebang Shenanigans
283
- Pièce de Résistance - Code Signing
285
- Persistence through /etc/launchd.conf
287
- Kernel Memory Layout: I - Zone ("heap") Layout
290
- Kernel Code Execution: IOUSBDeviceFamily's stallPipe()
292
- Arbitrary Memory Read/Write with Mach OOL Descriptors
296
- Kernel Memory Layout: II - Kernel base
298
- Refinement: Read (small) Primitive
299
- Refinement: Read (large) Primitive
299
- Refinement: Write Gadget
300
Chapter 15: Evasi0n 7
303
- Injecting the Application
305
- Dyld Injection (I): Loading gameover.dylib
306
- Privilege Escalation
307
- Dylib Injection (II): Replacing xpcd_cache.dylib
308
- Dylib Injection (III): Trojaning libmis.dylib
309
- Reproducing the jailbreak
310
Chapter 16: Pangu 7 (PanguAxe) (盘古斧)
321
- Certificate Injection
323
- The Jailbreak Payload
324
- Leaking the kernel stack
327
- Breaking early_random()
330
- Kernel Memory Overwrite(1): IODataQueue
332
- Kernel Memory Overwrite(2): IOHIDEventServiceUserClient
333
- Refinement: Arbitrary kernel memory overwrite
334
Chapter 17: Pangu 8 (軒轅劍)
337
- Certificate Injection
339
- Loading the Exploit Library
339
- Bypassing code signatures
341
Chapter 18: TaiG (太极)
347
- Sandbox Escape: AFC and BackupAgent
349
- libmis.dylib and overlapping segments (again)
353
- KASLR Info Leak via OSBundleMachOHeaders (again)
356
- Experiment: Observing the Get Loaded Kext Info exploited
357
- mach_port_kobject strikes again
358
- IOHIDFamily... Again...
360
- Experiment: Obtaining a kernel dump using TaiG 1
365
Chapter 20: Pangu 9 (伏羲琴)
385
- Loading the Jailbreak App (10-20%)
388
- Configuring the Environment (45%)
388
- Launching the Pangu App (75%)
390
The Jailbreak Payload
392
- Arbitrary Code Execution - I: Bypassing KASLR
396
- Arbitrary Code Execution - II: Inspecting gadgets
396
- Experiment: Examining Pangu 9 shared cache
399
- Experiment: Examining Pangu 9 shared cache (cont.)
400
- Anti-Anti-Debugging
401
Chapter 21: Pangu 9.3 (女娲石)
405
- The Exploit primitive
408
- Arbitrary Code Execution
409
Chapter 22: Pegasus (Trident)
411
Kernel Memory Read and KASLR Bypass
416
Arbitrary Kernel Memory Write
418
- Experiment: Figuring out what the leaked kernel address is
426
Putting it all together - a Phœnix rises!
429
Chapter 23: mach_portal
433
Mach port name urefs handling
435
- Applying the attack to launchd
437
XNU UaF in set_dp_control_port
441
Disabling protections
443
- Unsandboxing - The "ShaiHulud Maneuver"
443
- Root filesystem r/w
443
Bypassing code signatures
444
Chapter 24: Yalu (10.0-10.2)
447
- [Read/Write]Anywhere64
448
10.2: A deadly trap and a recipe for disaster
455
- Experiment: Adapting a PoC to a different kernel version
459
- The exploit (Todesco & Grassi)
460
- Constructing a fake Mach object
460
- Triggering the overflow
462
- Getting the kernel task port
465
Kernel Memory Corruption
473
- Kernel function call primitive
474
Post-Exploitation: The Jailbreak Toolkit
476
- Prerequisite: Manipulating the process and task lists
476
- Remounting the root filesystem as read-write
480
- Injecting entitlements - I - The CS Blob
482
- Injecting Entitlements - II - AMFI
483
- Replacing entitlements
485
- Borrowing entitlements
486
- Bypassing code signing
488
- The AMFI Trust Cache
488
Appendix A: MacOS Hardening Guide
497
Mandatory Access Control (MACF)
511
APFS Snapshot mount (iOS 11.3)
514


The price and availability of items at Rapidobuild.com are subject to change.
The shopping cart is a temporary place to store a list of your items and reflects each item's most recent price.
Do you have a promotional code? We'll ask you to enter your claim code when it's time to pay.


Results
Back
Retry Level y
In order to proceed to the next level, you need to get all 10 questions in a row correct.
Tap here to continue


Wiggam Week 2: CAD, Fusion 360 and Design
In this section we learned to use Fusion 360. We started out getting used to the challenging software and then took on our own project.
For my project I made a headphone stand to put on my desk along with the CSGO logo engraved on the top.
Narrative: This project taught me how to maneuver in Fusion 360. I started by created ractangles and then piecing them together
in the shape of my headphone stand. I then extruded the item to give it depth and to make it 3D. I used the chamber and fillet tools to
round off my edges and to make the item look more friendly and contemporary.


Hi, you must be new around here. I'm the unobtrusive little box that stores your files and stuff. Before we start working together, I'd like you to tell me a secret.
You see, I don't really do the whole password thing, so a secret is how I know it's you. A secret can be almost anything, but should be something only you and I know.
You could tell me a secret like, "Rocky Road is absolutely my most favorite ice cream flavor in the whole entire world." Or it could be something shorter, like "All my socks have holes." Be creative, but make sure you can remember it.
When you find yourself needing help with something, like pesky system passwords you might have forgotten, just come back here and tell me your secret. I'll know it's you and then I can help you reset those passwords. I'll help you set your initial passwords, too.
If you don't have a secret yet, think of a good one. Type it in the box and hit . I'll remember your secret for next time. Make sure you do too.


Week Six Cultural Blog
Stereotype threat is the risk of confirming oneself negative stereotype about ones group. In 1995, the term was first used by Steele and Aronson who had created several experiments displaying stereotype threat among minorities. Over 300 experiments on stereotype threat have been published in peer-reviewed journals.
There are more consequences for stereotype threat than underachievement in academics, like reducing a sense of belonging or it can lead to self-handicapping strategies. Stereotype threat has been shown to affect stereotyped individuals’ performance in a number of domains beyond academics, such as white men in sports, women in negotiation, homosexual men in providing childcare, and women in driving.
Honestly, I don't feel like I have dealt with stereotype threat personally. I am a blonde white woman who doesn't let others opinions change me.  I'm smart, I'm a good driver.. I speed but I do that on purpose and have full control while doing so, and yeah I cook, but I enjoy cooking for my fiancé. Jokes about me being dumb can hurt, but I don't believe them nor allow them to change me to fail.
I'm a very friendly person and hang out with everyone, doesn't matter what race, age, or gender. I am the one who invites someone over to sit with my group if they are sitting by themselves. I put in effort to get to know people. Thats just how I am, but that will make people feel more comfortable and less likely to feel stereotype threat.
comments powered by Disqus


microformats logo in svg format
h-menu ideas
early draft ideas for a proposed h-menu type to mark up food menus with microformats, based on h-menu brainstorming ideas
include pattern idea
idea for a new include pattern
based on the HTML5
itemref
attribute as used in
microdata


I like make things happen through coding. I'm passionate about the complete digital design. The design understood as how things work not how they look. I want do it using Ruby, PHP and Python for now.
I enjoy writing front-end code with these technologies and also I am learning more and more every day. You would be amazed with the things you can learn in an hour or you would be a master just getting started with 20 hour of intense practice.


|
Max API
8.2.0
|
Functions | |
| void * | jit_getbytes (long size) |
| Allocates a pointer to memory. More... | |
| void | jit_freebytes (void *ptr, long size) |
| Frees a pointer to memory. More... | |
| void ** | jit_handle_new (long size) |
| Allocates a memory handle. More... | |
| void | jit_handle_free (void **handle) |
| Frees a memory handle. More... | |
| long | jit_handle_size_get (void **handle) |
| Retrieves a memory handle's size in bytes. More... | |
| t_jit_err | jit_handle_size_set (void **handle, long size) |
| Sets a memory handle's size in bytes. More... | |
| long | jit_handle_lock (void **handle, long lock) |
| Sets a memory handle's lock state. More... | |
| void | jit_copy_bytes (void *dest, const void *src, long bytes) |
| Copy bytes from source to destination pointer. More... | |
| long | jit_freemem (void) |
| Reports free memory. More... | |
| char * | jit_newptr (long size) |
| Allocates a pointer to memory. More... | |
| void | jit_disposeptr (char *ptr) |
| Frees a pointer to memory. More... | |
| void jit_copy_bytes | ( | void * | dest, |
| const void * | src, | ||
| long | bytes | ||
| ) |
Copy bytes from source to destination pointer.
| dest | destination pointer |
| src | source pointer |
| bytes | byte count to copy |
References sysmem_copyptr().
| void jit_disposeptr | ( | char * | ptr | ) |
Frees a pointer to memory.
| ptr | pointer to memory |
References sysmem_freeptr().
| void jit_freebytes | ( | void * | ptr, |
| long | size | ||
| ) |
Frees a pointer to memory.
Depending on the size of the pointer, jit_freebytes will free from either the faster memory pool or the system memory pool.
| ptr | pointer to memory |
| size | size in bytes allocated |
References sysmem_freeptr().
Referenced by jit_matrix_freedata(), and max_jit_obex_free().
| long jit_freemem | ( | void | ) |
Reports free memory.
| void* jit_getbytes | ( | long | size | ) |
Allocates a pointer to memory.
Depending on the size requested, jit_getbytes will allocate from either the faster memory pool or the system memory pool.
| size | size in bytes to allocate |
References sysmem_newptr().
Referenced by jit_matrix_getcell(), max_jit_classex_setup(), and max_jit_obex_new().
| void jit_handle_free | ( | void ** | handle | ) |
Frees a memory handle.
| handle | memory handle |
References sysmem_freehandle().
Referenced by jit_matrix_free().
| long jit_handle_lock | ( | void ** | handle, |
| long | lock | ||
| ) |
Sets a memory handle's lock state.
| handle | memory handle |
| lock | state (1=locked, 0=unlocked) |
References sysmem_lockhandle().
| void** jit_handle_new | ( | long | size | ) |
Allocates a memory handle.
Handles are relocatable sections of memory which should be locked before dereferencing, and unlocked when not in use so that they may be relocated as necessary.
| size | size in bytes to allocate |
References sysmem_newhandle().
| long jit_handle_size_get | ( | void ** | handle | ) |
Retrieves a memory handle's size in bytes.
| handle | memory handle |
References sysmem_handlesize().
| t_jit_err jit_handle_size_set | ( | void ** | handle, |
| long | size | ||
| ) |
Sets a memory handle's size in bytes.
| handle | memory handle |
| size | new size in bytes |
References sysmem_resizehandle().
| char* jit_newptr | ( | long | size | ) |
Allocates a pointer to memory.
Always allocates from the the system memory pool.
| size | size in bytes to allocate |
References sysmem_newptr().


Layouts, Positioning, and the View Hierarchy
Objective
In this chapter, you will learn how to lay out your user interface components using Titanium's various positioning properties. You will examine the coordinates system used by Titanium, its view hierarchy, and the layering and positioning rules that it follows when rendering your UI.
Contents
In this chapter, we're going to explore the following factors that affect how you position elements within your app's UI:
-
The coordinates grid
-
Positioning and the view hierarchy
-
Layout modes
-
zIndex & default stacking order
The coordinates grid
Titanium uses a grid coordinate system. Grid values don't correspond directly to pixels due to differences in display density. Instead, values correspond to points, which are in essence density-independent pixels. Typical grid sizes are as follows:
-
iPhone with either original or retina display is based on a 320 x 480 grid.
-
iPad is based on a 1024 x 768 grid.
-
Android devices vary. Considering these emulator examples:
-
HVGA emulator is 320 x 480
-
WVGA800 emulator is 480 x 800
-
WVGA854 emulator is 480 x 854
-
Positioning
Elements in Titanium are positioned relative to their parent container, such as the window or a view. Depending on the positioning properties you use, the reference point will be either the parent's top/left or bottom/right corner. We call this the "view hierarchy." Options include:
-
top and left properties, which specify the grid position of the element's top/left corner relative to the parent's top/left corner.
-
bottom and right properties, which specify the grid position of the element's bottom/right corner relative to the parent's bottom/right corner.
-
center property, which species the position of the element's center point relative to the parent's top/left corner.
The top/left and bottom/right properties accept the following values:
-
Integer "point" value
-
String Values
-
Percentile values, like '50%'
-
Density Independent pixel values, like '100dp'
-
Auto sizing and positioning via 'auto'
-
The center property accepts a dictionary object describing the x,y coordinates, like this:
center = { x: 100, y: 100 };
As with top, bottom, left, and right, you can use either an integer value or string percentile as values. You can even use negative coordinates, which could put the view off screen depending on its size.
In the following example, the red view is positioned at the 20,20 point relative to the window's top/left corner. The yellow view's bottom/right corner is 100 pixels from the bottom/right corner of the display. The blue view's center is at 160,240 and given its width of 50, this means its top-left corner would be at 110,190. The green view has a sufficiently negative top value given its width that it is positioned off the top of the screen.
var window = Ti.UI.createWindow({
backgroundColor:'#fff'
});
var redview = Ti.UI.createView({
top:20,
left:20,
width:10,
height:10,
backgroundColor:"red"
});
window.add(redview);
var yellowview = Ti.UI.createView({
bottom:100,
right:100,
width:10,
height:10,
backgroundColor:"yellow"
});
window.add(yellowview);
var blueview = Ti.UI.createView({
center: {x: 160, y: 240},
width:50,
height:50,
backgroundColor:"blue"
});
window.add(blueview);
var greenview = Ti.UI.createView({
top:-20,
width:10,
height:10,
backgroundColor:"green"
});
window.add(greenview);
window.open();
Layout modes
Titanium views can employ one of three layout modes by setting its layout property to one of the following values:
-
absolute - This is the default mode that we have discussed to this point. You specify point coordinates on a grid relative to the parent container's top/left or bottom/right corner.
-
vertical - This layout mode stacks child views vertically. The child's top property becomes an offset value. It describes the number of points from its previous sibling's bottom edge where the view will be positioned.
-
horizontal - This layout mode lines up child views horizontally. The child's left property, similar to vertical, becomes an offset. This time, it's the position from the previous sibling's right edge.
Here's an exmaple of these layouts in action:
var window = Ti.UI.createWindow({
backgroundColor:'#fff'
});
// uses grid-drawing module from https://gist.github.com/1187384
// to draw grid lines every 20 points
var grid = require('gridlines');
grid.drawgrid(20,window);
// draw a view that fills the window and set its layout property
var view = Ti.UI.createView({
backgroundColor:'transparent',
top:0,
left:0,
width:'100%',
height:'100%',
layout:'vertical'
});
// simple function for making colored boxes
function makeView(color) {
return Ti.UI.createView({
top:20,
left:20,
width:20,
height:20,
backgroundColor:color
});
}
view.add(makeView('red'));
view.add(makeView('yellow'));
view.add(makeView('blue'));
view.add(makeView('green'));
window.add(view);
window.open();
zIndex & default stacking
You can position elements atop one another. By default, as you add views to a parent container, they will overlay any views you previously added (assuming their boundaries overlap). You can control the stacking order by either changing the order you add elements to the container (not always convenient) or by setting the zIndex property. As with HTML elements, zIndex accepts an integer value of zero or greater. The higher the zIndex value, the closer to the top of the stack a view will become.
Hands-on Practice
Goal
In this activity, you will test the position behavior of elements by implementing some of the code examples in this chapter.
Resources
To perform the steps in this activity, you will need the gridlines module from https://gist.github.com/1187384.
Steps
-
Create a new Titanium Mobile project.
-
Create a gridlines.js file containing the code shown at the Gist linked to above.
-
In app.js, remove all of the existing code. Declare a window, require the grid line module, and draw gridlines every 20 points, following the example code as shown in the Gist.
-
Implement the positioning code shown in the example labeled "Positioning" above. This will draw red, blue, yellow, and green boxes at various positions on the screen.
-
Build and run the project. Count the gridlines to confirm that elements were placed as described in this chapter.
-
Adjust the positioning properties of the various boxes to test positioning rules.
-
Try setting the window's layout property to vertical or horizontal to see the effect on the lines and boxes. Adjust the code so that the boxes are visible.
References and Further Reading
Summary
In this section, you learned how to lay out your user interface components using the various positioning properties. You examined the coordinates system used by Titanium, the view hierarchy, and the layering and positioning rules that Titanium follows when rendering your UI. Next we'll discuss how you can handle user interaction via events.


Ill luck made Roger Torraway the subject of the Man Plus Programme, but it was deliberate biological engineering which turned him into a monster -- a machine perfectly adapted to survive on Mars. For according to computer predictions, Mars is humankind's only alternative to extinction. But beneath his monstrous exterior, Torraway still carries a man's capacity for suffering.


Cosa Nostra
Congratulations!
Your account has been successfully activated!
You can now enjoy the full extension of Cosa Nostra.


This is the first time you are logging in! We need you to fill out some details first before we can get started planning your modules. Remember to change your default password too!
{{ errors.other }}
Password must be at least 3 characters.
{{ message }}
No matching combination found
Choose "No Track" if you are not sure.
Choose "Undecided" if you are not sure.


{% extends "global/Page.html" %} {% load otree %} {% block title %} {% if not group_timed_out %} Results {% else %} Time Out {% endif %} {% endblock %} {% block content %} {% if not group_timed_out %}
{% if same_choice %} Both of you chose to {{ my_decision }}. {% else %} You chose to {{ my_decision }} and the other worker chose to {{ opponent_decision }}. {% endif %}
As a result, you earned a bonus of {{ player.payoff }} in this round. {% if not last_round %} You will play the {{next_stakes}} stakes game next round.
{% endif %}You just finished playing the last round in the game.
In every game, there are at least {{Constants.base_rounds}} rounds. After that, another round is played with a 50% probability. And after that, yet another round is played with a 50% probability and so on. The random generator took this into account and determined a maximum length of {{num_rounds}} for your group. You just finished with the {{round_str}} round and you can now claim your bonus
Please finish the survey to receive your completion payment and bonus. Your bonus is the reward that you accumulated over all rounds.
{% endif %} {% next_button %} {% else %} {% if not self_timed_out %}Your partner timed out. You will receive your bonus.
Please finish the survey to receive your completion payment and bonus. Your bonus is the reward that you accumulated over all rounds so far.
{% next_button %} {% else %}You will not receive any payment. The HIT will remain uncompleted.
{% endif %} {% endif %} {% endblock %}


University selector: How many applied for a study between 2012-2016?
Select a university below
Woman percentage
Man percentage
Relative size of subjects


PearsonEbookDownloader
Book URL or bookId:
Bookserver:
Auto (from URL, defaults to PROD1 otherwise)
PROD1
PROD2
PROD3
PPE1
PPE2
PPE3
CERT1
CERT2
CERT3
If you found this utility helpful, please leave a
donation
or recommend it to others.