The first reason listed for using transactions was recoverability. Any logical change to a database may require multiple changes to underlying data structures. For example, modifying a record in a Btree may require leaf and internal pages to split, so a single DB->put() method call can potentially require that multiple physical database pages be written. If only some of those pages are written and then the system or application fails, the database is left inconsistent and cannot be used until it has been recovered; that is, until the partially completed changes have been undone.
Write-ahead-logging is the term that describes the underlying implementation that Berkeley DB uses to ensure recoverability. What it means is that before any change is made to a database, information about the change is written to a database log. During recovery, the log is read, and databases are checked to ensure that changes described in the log for committed transactions appear in the database. Changes that appear in the database but are related to aborted or unfinished transactions in the log are undone from the database.
For recoverability after application or system failure, operations that modify the database must be protected by transactions. More specifically, operations are not recoverable unless a transaction is begun and each operation is associated with the transaction via the Berkeley DB interfaces, and then the transaction successfully committed. This is true even if logging is turned on in the database environment.
Here is an example function that updates a record in a database in a transactionally protected manner. The function takes a key and data items as arguments and then attempts to store them into the database.
int main(int argc, char *argv) { extern int optind; DB *db_cats, *db_color, *db_fruit; DB_ENV *dbenv; int ch; while ((ch = getopt(argc, argv, "")) != EOF) switch (ch) { case '?': default: usage(); } argc -= optind; argv += optind; env_dir_create(); env_open(&dbenv); /* Open database: Key is fruit class; Data is specific type. */ db_open(dbenv, &db_fruit, "fruit", 0); /* Open database: Key is a color; Data is an integer. */ db_open(dbenv, &db_color, "color", 0); /* * Open database: * Key is a name; Data is: company name, cat breeds. */ db_open(dbenv, &db_cats, "cats", 1); add_fruit(dbenv, db_fruit, "apple", "yellow delicious"); return (0); } int add_fruit(DB_ENV *dbenv, DB *db, char *fruit, char *name) { DBT key, data; DB_TXN *tid; int fail, ret, t_ret; /* Initialization. */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); key.data = fruit; key.size = strlen(fruit); data.data = name; data.size = strlen(name); for (fail = 0;;) { /* Begin the transaction. */ if ((ret = dbenv->txn_begin(dbenv, NULL, &tid, 0)) != 0) { dbenv->err(dbenv, ret, "DB_ENV->txn_begin"); exit (1); } /* Store the value. */ switch (ret = db->put(db, tid, &key, &data, 0)) { case 0: /* Success: commit the change. */ if ((ret = tid->commit(tid, 0)) != 0) { dbenv->err(dbenv, ret, "DB_TXN->commit"); exit (1); } return (0); case DB_LOCK_DEADLOCK: default: /* Retry the operation. */ if ((t_ret = tid->abort(tid)) != 0) { dbenv->err(dbenv, t_ret, "DB_TXN->abort"); exit (1); } if (fail++ == MAXIMUM_RETRY) return (ret); break; } } }
Berkeley DB also uses transactions to recover from deadlock. Database operations (that is, any call to a function underlying the handles returned by DB->open() and DB->cursor()) are usually performed on behalf of a unique locker. Transactions can be used to perform multiple calls on behalf of the same locker within a single thread of control. For example, consider the case in which an application uses a cursor scan to locate a record and then the application accesses another other item in the database, based on the key returned by the cursor, without first closing the cursor. If these operations are done using default locker IDs, they may conflict. If the locks are obtained on behalf of a transaction, using the transaction's locker ID instead of the database handle's locker ID, the operations will not conflict.
There is a new error return in this function that you may
not have seen before. In transactional (not Concurrent Data
Store) applications supporting both readers and writers, or
just multiple writers, Berkeley DB functions have an
additional possible error return:
DB_LOCK_DEADLOCK. This means two threads of
control deadlocked, and the thread receiving the
DB_LOCK_DEADLOCK
error return has been
selected to discard its locks in order to resolve the problem.
When an application receives a
DB_LOCK_DEADLOCK
return, the correct
action is to close any cursors involved in the operation and
abort any enclosing transaction. In the sample code, any time
the DB->put() method returns
DB_LOCK_DEADLOCK
, DB_TXN->abort() is called
(which releases the transaction's Berkeley DB resources and
undoes any partial changes to the databases), and then the
transaction is retried from the beginning.
There is no requirement that the transaction be attempted again, but that is a common course of action for applications. Applications may want to set an upper bound on the number of times an operation will be retried because some operations on some data sets may simply be unable to succeed. For example, updating all of the pages on a large Web site during prime business hours may simply be impossible because of the high access rate to the database.
The DB_TXN->abort() method is called in error cases other than deadlock. Any time an error occurs, such that a transactionally protected set of operations cannot complete successfully, the transaction must be aborted. While deadlock is by far the most common of these errors, there are other possibilities; for example, running out of disk space for the filesystem. In Berkeley DB transactional applications, there are three classes of error returns: "expected" errors, "unexpected but recoverable" errors, and a single "unrecoverable" error. Expected errors are errors like DB_NOTFOUND, which indicates that a searched-for key item is not present in the database. Applications may want to explicitly test for and handle this error, or, in the case where the absence of a key implies the enclosing transaction should fail, simply call DB_TXN->abort(). Unexpected but recoverable errors are errors like DB_LOCK_DEADLOCK, which indicates that an operation has been selected to resolve a deadlock, or a system error such as EIO, which likely indicates that the filesystem has no available disk space. Applications must immediately call DB_TXN->abort() when these returns occur, as it is not possible to proceed otherwise. The only unrecoverable error is DB_RUNRECOVERY, which indicates that the system must stop and recovery must be run.
The above code can be simplified in the case of a transaction comprised entirely of a single database put or delete operation, as operations occurring in transactional databases are implicitly transaction protected. For example, in a transactional database, the above code could be more simply written as:
for (fail = 0; fail++ <= MAXIMUM_RETRY &&
(ret = db->put(db, NULL, &key, &data, 0)) == DB_LOCK_DEADLOCK;)
continue;
return (ret == 0 ? 0 : 1);
and the underlying transaction would be automatically handled by Berkeley DB.
Programmers should not attempt to enumerate all possible error returns in their software. Instead, they should explicitly handle expected returns and default to aborting the transaction for the rest. It is entirely the choice of the programmer whether to check for DB_RUNRECOVERY explicitly or not — attempting new Berkeley DB operations after DB_RUNRECOVERY is returned does not worsen the situation. Alternatively, using the DB_ENV->set_event_notify() method to handle an unrecoverable error and simply doing some number of abort-and-retry cycles for any unexpected Berkeley DB or system error in the mainline code often results in the simplest and cleanest application code.


---
layout: page
title: Open Source Projects
description: "A selection of cool projects I've worked on."
footer: false
---
A curated collection of open source projects I built over the years.
{% for proj in site.data.projects %}
{% capture title %} {{proj.title}} {% endcapture %}
{% capture url %} {{proj.url}} {% endcapture %}
{% capture description %} {{proj.description}} {% endcapture %}
{% include project.html %}
{% endfor %}
← Blog Archives
About →


{% extends 'security/form.html' %} {% from "security/_macros.html" import render_field_with_errors, render_field %} {% include "security/_messages.html" %} {% block form_title %}


Hello World!
Tutorial Assignment: 1_3_intro_to_js
Create A Page that Counts the number of times use has clicked a button
Counter
Reset?
Tic Tac Toe, Click The Button to Start
X
Reset?


NPA ready to prosecute culprits in controversial Estina dairy farm project - reports
The National Prosecuting Authority (NPA) is ready to prosecute those implicated in the controversial Gupta-linked Estina dairy farm project, according to media reports.
The project in Vrede, the Free State, was intended to see 100 black emerging farmers receive five cows each as part of an empowerment scheme.
Gifted to Estina in 2013 under a free 99-year lease by the provincial Department of Agriculture, the farm was one of the most controversial transactions between the Guptas and a government entity, News24 earlier reported.
READ: Estina dairy farm project an example of organised robbery, Peter Hain tells Zondo commission
According to IOL, National Director of Public Prosecutions advocate Shamila Batohi and NPA investigative directorate head advocate Hermione Cronje announced on Monday some state capture-related cases would be reinstated as Cronje's unit had gathered enough evidence.
"We are waiting for the last piece of evidence from the United Arab Emirates before we can enrol the case in court," Cronje said at a round table discussion with the media at the NPA's headquarters in Pretoria on Tuesday.
Batohi also revealed she would declassify documents that could ultimately lead to the prosecution of former crime intelligence boss Richard Mdluli.
According to Business Day, she revealed that national police commissioner General Khehla Sitole had written to her last week saying he had agreed to declassify "a whole range of documents that we need".
In September, the commission of inquiry into state capture, chaired by Deputy Chief Justice Raymond Zondo, heard how Mdluli allegedly looted the secret service account (SSA) within crime intelligence.
Hawks investigator Colonel Kobus Roelofse revealed to the commission how Mdluli had spent money from the account for security upgrades, overseas trips and various vehicles.
Mdluli faced charges of fraud, theft and corruption for allegedly looting the crime intelligence slush fund, however, the charges were later withdrawn in 2011.
Roelofse told the commission that this decision "did not make any sense", saying Mdluli had failed to co-operate with officers while he was under investigation for fraud and corruption relating to the SSA, News24 reported.
ALSO READ: Richard Mdluli 'frustrated' investigations into abuse of secret service account
Compiled by Canny Maphanga


VoloStage, next-generation video technology, is an end-to-end Volumetric Video Capturing and Streaming solution. Compatible with mobile devices, browsers, and VR goggles.


Eels sensation Maika Sivo rushed from Fiji to Sydney after mystery infection flares up
by Staff writersParramatta officials insisted Maika Sivo fly home from Fiji for an operation on his hand after a mystery infection flared up on his return home to the Pacific island village of Momi.
“Maika went to hospital in Fiji after it flared up. He then contacted the Eels and they requested he fly back to Sydney. He got home Monday night and went straight to Norwest Hospital,” Sivo’s agent Cameron Phelps told foxsports.com.au.
Stream over 50 sports live & anytime on your TV or favourite device with KAYO SPORTS. The biggest Aussie sports and the best from overseas. Just $25/month. No lock-in contract. Get your 14 day free trial >
The 26-year-old winger is expected to undergo surgery on Tuesday.
Sivo had a breakout rookie season for the Eels in 2019, where he finished as the NRL’s top tryscorer.
MORE NRL NEWS
MEETING MITCHELL: Cowboys spotted dining with exiled Roosters centre
BURNING ISSUES: The issue your club needs to fix ahead of the 2020 season
DEALBREAKER: The key player in the battle for Jai Arrow’s signature
He was recently rewarded for his stunning performances with an upgraded contract at the Eels which will see him remain at the club until the end of 2021.
Sivo featured in 25 NRL games in his first season and went on to represent Fiji at the World Cup Nines and in the Oceania Cup.


view.py |
|
|---|---|
|
The WebCore view registry. WebCore uses a registry of callables to transform values returned by controllers for use as a response. This
translation process is used to support the built-in types (see the A view handler takes the result of calling a controller endpoint and applies the result to the response. It can be
as simple as a bare function that accepts the current
Slightly more useful would be to assign the result directly to the response:
As an example pulled from the "template" extension, you can use an "exit early" strategy to selectively handle subsets of the type your view is registered against, such as only handling 2-tuples with a specific first value:
A view may go so far as to wholly replace the If you frequently hand back serialized data, you may be able to simplify your controller code and reduce boilerplate by simply returning your model instances. By registering a view handler for your model class you can implement the serialization in a single, centralized location, making security and testing much easier. When a controller raises an |
|
Imports |
from __future__ import unicode_literals
from webob.multidict import MultiDict
from marrow.package.canonical import name
from marrow.package.host import PluginManager
from .compat import py3, pypy
|
Module Globals |
|
|
A standard logger object. |
log = __import__('logging').getLogger(__name__)
|
View Registry |
|
|
A This extends plugin naming to support multiple candidates per name, overrides manual registration to log some
useful messages, and makes instances callable. Executing a |
class WebViews(PluginManager):
__isabstractmethod__ = False # Work around a Python 3.4+ issue, since our instances are callable.
|
Python Protocols |
|
|
View registry constructor. The view registry is not meant to be instantiated by third-party software. Instead, access the registry as
an attribute of the the current |
def __init__(self, ctx):
super(WebViews, self).__init__('web.view')
self.__dict__['_map'] = MultiDict()
|
|
Programmers' representation for development-time diagnostics. |
def __repr__(self):
return "WebViews({})".format(len(self._map))
|
|
Identify view to use based on the type of result when our instance is called as a function. This generates a stream of candidates which should be called in turn until one returns a truthy value. |
def __call__(self, result):
rtype = type(result)
|
|
Short-circuit on exact matches. |
for candidate in self._map.getall(rtype):
yield candidate
|
|
More exhaustive search for potentially more crafty use such as ABC, zope.interface, marrow.interface, etc. |
for kind, candidate in self._map.iteritems():
if kind is rtype: continue # We've already seen these.
if isinstance(result, kind):
yield candidate
|
Plugin Registration |
|
|
Register a handler for a given type, class, interface, or abstract base class. View registration should happen within the
The approach of explicitly referencing a view handler isn't very easy to override without also replacing the
extension originally adding it, however there is another approach. Using named handlers registered as discrete
plugins (via the
Otherwise unknown attributes of the view registry will attempt to look up a handler plugin by that name. |
def register(self, kind, handler):
if __debug__: # In production this logging is completely skipped, regardless of logging level.
if py3 and not pypy: # Where possible, we shorten things to just the cannonical name.
log.debug("Registering view handler.", extra=dict(type=name(kind), handler=name(handler)))
else: # Canonical name lookup is not entirely reliable on some combinations.
log.debug("Registering view handler.", extra=dict(type=repr(kind), handler=repr(handler)))
|
|
Add the handler to the pool of candidates. This adds to a list instead of replacing the "dictionary item". |
self._map.add(kind, handler)
return handler
|


Computation times¶
02:08.585 total execution time for auto_examples_cluster files:
- 00:37.642: Comparing different clustering algorithms on toy datasets (
plot_cluster_comparison.py
) - 00:33.416: Various Agglomerative Clustering on a 2D embedding of digits (
plot_digits_linkage.py
) - 00:14.510: Segmenting the picture of greek coins in regions (
plot_coin_segmentation.py
) - 00:10.795: Compare BIRCH and MiniBatchKMeans (
plot_birch_vs_minibatchkmeans.py
) - 00:05.709: Online learning of a dictionary of parts of faces (
plot_dict_face_patches.py
) - 00:04.820: Vector Quantization Example (
plot_face_compress.py
) - 00:02.983: Empirical evaluation of the impact of k-means initialization (
plot_kmeans_stability_low_dim_dense.py
) - 00:02.361: Agglomerative clustering with and without structure (
plot_agglomerative_clustering.py
) - 00:02.338: Comparing different hierarchical linkage methods on toy datasets (
plot_linkage_comparison.py
) - 00:02.062: Color Quantization using K-Means (
plot_color_quantization.py
) - 00:01.667: Spectral clustering for image segmentation (
plot_segmentation_toy.py
) - 00:01.548: Selecting the number of clusters with silhouette analysis on KMeans clustering (
plot_kmeans_silhouette_analysis.py
) - 00:01.464: A demo of K-Means clustering on the handwritten digits data (
plot_kmeans_digits.py
) - 00:01.149: Agglomerative clustering with different metrics (
plot_agglomerative_clustering_metrics.py
) - 00:01.078: Adjustment for chance in clustering performance evaluation (
plot_adjusted_for_chance_measures.py
) - 00:00.950: Feature agglomeration vs. univariate selection (
plot_feature_agglomeration_vs_univariate_selection.py
) - 00:00.796: Demo of affinity propagation clustering algorithm (
plot_affinity_propagation.py
) - 00:00.563: A demo of structured Ward hierarchical clustering on an image of coins (
plot_coin_ward_segmentation.py
) - 00:00.489: Demonstration of k-means assumptions (
plot_kmeans_assumptions.py
) - 00:00.472: A demo of the mean-shift clustering algorithm (
plot_mean_shift.py
) - 00:00.432: Hierarchical clustering: structured vs unstructured ward (
plot_ward_structured_vs_unstructured.py
) - 00:00.409: K-means Clustering (
plot_cluster_iris.py
) - 00:00.360: Comparison of the K-Means and MiniBatchKMeans clustering algorithms (
plot_mini_batch_kmeans.py
) - 00:00.306: Demo of DBSCAN clustering algorithm (
plot_dbscan.py
) - 00:00.266: Feature agglomeration (
plot_digits_agglomeration.py
)


Lets Play!!
About Ping pong Created by:Muriithi Vionna Github username url: Muriithi-003 Level two test for:Java
Rules
PingPong will count upto your number from 1 with the following exceptions:
Enter your number here:


Jeniffer Lopez
American actress, and Dancer
- Name: Jeniffer Lopez
- Age:50
- Gender:Female
- Race:Latina
- Occupation:American Actress, singer and Buisness Women
- Technology: Phone; iphone 11 pro. Laptop; MacBook Pro.
- Attitude:Likes to listen to her own music, prefers to pay it a year in advance,
Reads all comments about her music.
Needs/Goals/Features:
- Ability to check out latest version of music
- Able to check updates
- Enjoys listening to familiar artist
Frustrations:
- Too many adds
- Music stops playing
- Too many unknown albums


Click on the picture to get some more information about what you see.
Istvan is a NASE Dive Master with more than 400 registered underwater dives.
Eszter is a PADI Open Water Diver with about 20 registered underwater dives.
Tiger is Istvan's underwater buddy escorting him tied to his tank.
The second stage is an important part of the scuba equipment, you breath the air through it.
Decompression buoy is used to send to the surface while you are under water for your safety stop.


Structure
Beneficiary
public struct Beneficiary: Equatable
A beneficiary is a payment or transfer destination account which has been authorized by the bank.
Each beneficiary belongs to an account, which means that the given account can send money to that beneficiary.
Relationships
Conforms To
TransferAccountIdentifiable
A type that can be used as an to or from account when initiating a transfer.
Equatable
Properties
accountNumberKind
let accountNumberKind: AccountNumberKind
The kind of the accountNumber
that this beneficiary has.
accountNumber
let accountNumber: String
The account number for the beneficiary.
name
let name: String
The name chosen by the user for this beneficiary.
ownerAccountID
let ownerAccountID: Account.ID
The identifier of the account that this beneficiary belongs to.
transferAccountID
var transferAccountID: String


Class 11: Divide and Conquer I
02-17-2020
“Binary like Yin & Yang”
The main idea of Divide and Conquer is that we can tackle a big problem by solving smaller disjoint sub-problems and then merging these solutions together to get an answer. The interesting part is that if we can find disjoint sub-problems that are similar to the original problem, then we can use recursion.
There are usually three steps in divide and conquer:
- Divide: Forming the sub-problems.
- Conquer: Solving each sub-problem.
- Merge: Using the solutions of the sub-problems to solve the original problem.
Today we will learn about one of the most popular Divide and Conquer algorithms: Binary Search.
Image taken from Pinterest
Motivation
Let’s say that you need to find the position of a value in an array. How would you do it?
The most intuitive way of approaching this problem is to go through all elements in the array and check if it is the one you are looking for (linear search).
#include <bits/stdc++.h>
using namespace std;
int main () {
int num = 10;
int x = 20;
vector <int> arr = {2, 4, 6, 7, 8, 10, 20, 4034, 4535, 5635435, 577436536};
bool found = false;
for (int i = 0; i < arr.size() && !found; i++) {
if (arr[i] == x) {
cout << i + 1 << '\n';
found = true;
}
}
if (!found) {
cout << x << " is not in the array\n";
}
return (0);
}
This approach has a complexity of \(O(n)\). In general, this complexity is pretty good, however looking for a specific element in an array is a basic operation that usually needs to be done more than once. What happens if we do this linear search thousands of times? How many times can we do it without exceeding the time limit? Is there a better way?
Binary search
There is a better way and it’s called Binary Search. This is one of the most basic and powerful concepts. It can be used in thousands of algorithms to boosts up the performance significantly. Most importantly, as we will see, its uses go beyond searching for an element in an array. The only condition that needs to hold for binary search to work is that the array (or our search domain) must be sorted.
- Divide: We can compare our value to the element in the middle of the array. As the array is sorted this will tell us if the element is to the right or the left of the middle.
- Conquer: We can now search for the element in the corresponding half of the array.
- Merge: If we find the element in its corresponding half we have also found it in the array.
First approach
#include <bits/stdc++.h>
using namespace std;
int binary_search (int* seq, int size, int x) {
int left = 0;
right = size - 1;
while (left <= right) {
int med = left + (right - left) / 2;
if (arr[med] == x) {
return med;
} else if (arr[med] > x) {
right = med - 1;
} else {
left = med + 1;
}
}
return -1;
}
Take a sight to the following problem: SPOJ - Count the Pairs
Before looking the code, think for few minutes how to use binary search to solve this problem.
#include <bits/stdc++.h>
using namespace std;
bool bs (int *num, int l, int r, int x) {
while (l <= r) {
int med = l + (r - l) / 2;
if (num[med] == x) return true;
if (num[med] > x) r = med - 1;
else l = med + 1;
}
return false;
}
int main () {
int n, k;
cin >> n >> k;
int num[n];
for(int& i: num) cin >> num[i];
sort(num, num + n);
int cont = 0;
for (int i = 0; i < n; i++) {
if (bs(num, i + 1, n - 1, k + num[i])) {
cont++;
}
}
cout << cont << '\n';
return 0;
}
Take count what is the range in the binary method for each value \(k + num[i]\).
Now, what happen if there exists many equal values in the array. What position does the binary method return?
int arr[] = {2, 4, 6, 7, 8, 10, 10, 10, 20, 4034, 4535, 5635435, 577436536};
In this cases we need more information in order to determine what value we have to return. Even though in many problems it doesn’t matter which we pick, in many others it will. For those cases, we are going to work with what is called lower and upper bound.
The lower bound is the first element that does not compare less than the value we are looking for. In simpler words, is the first occurrence of the search value. The following is a possible implementation of lower bound, however, std::lower_bound
can simplify things for us.
#include <bits/stdc++.h>
using namespace std;,
int binary_search(int* arr, int size, int x) {
int left = 0;
int right = size - 1;
int pos = -1;
while (left < right) {
int med = left + (right - left) / 2;
if (arr[med] == x) {
pos = med;
}
if (arr[med] >= x) {
right = med;
} else {
left = med + 1;
}
}
return pos;
}
// If we want to use lower_bound of STL
int array[] = {10, 10, 10, 20, 20, 20, 30, 30, 40, 60};
// 3: returns the first position where 30 is
cout << lower_bound(array, array + 10, 30) - arr << '\n';
vector <int> vec(array, array + 10);
// 8: returns the first position where 30 is.
cout << lower_bound(vec.begin(), vec.end(), 40) - vec.begin() << '\n';
This is the last element that compares less than or equal to our value. Similarly, it can be found using the following algorithm:
#include <bits/stdc++.h>
using namespace std;
int binary_search (int* arr, int size, int x) {
int left = 0;
int right = size - 1;
int pos = -1;
while (left < right) {
int med = left + (right - left + 1) / 2;
if (arr[med] == x) {
pos = med;
}
if (arr[med] >= x) {
right = med - 1;
} else {
left = med;
}
}
return pos;
}
// If we want to use upper_bound of STL
int array[] = {10, 10, 10, 20, 20, 20, 30, 30, 40, 60};
// 7: returns the first position where 30 is
cout << upper_bound(array, array + 10, 30) - arr << '\n';
vector <int> vec(array, array + 10);
// 8: returns the first position when 30 is.
cout << upper_bound(vec.begin(), vec.end(), 40) - vec.begin() << '\n';
Sure you are thinking why we need to add one inside the difference between right and left.
Take a sight the next example and compute this searching without adding one in med.
int array[] = {10, 20};
// med here is left + (right - left) / 2
cout << bs(array, 2, 20) << '\n';
There exists a bucle inside the form because med is always 0. So, if we want to solve this inconvenience just add one and that is all.
You may find useful to search
Now, let’s see one interesting problem: Less or equal elements
And again, take a few minutes before looking the code.
#include <bits/stdc++.h>
using namespace std;
int bs (int* num, int size, int x){
int l = 0, r = size - 1;
while (l < r) {
int med = l + (r - l + 1) / 2;
if (num[med] > x) r = med - 1;
else l = med;
}
return l;
}
int main () {
int n, m, x;
cin >> n >> m;
int a[n];
for (int& i: a) cin >> i;
sort(a, a + n);
for (int i = 0; i < m; i++) {
cin >> x;
if (i > 0) cout << " ";
if (x < a[0]) {
cout << 0;
continue;
}
cout << bs(a, n, x) + 1;
}
cout << endl;
return 0;
}
As it was mentioned before, binary search is not only useful for finding values in an array, but it also has other uses. In this section we will explore some of these variations.
Solving an equation
Let’s say we want to solve the equation: \(f(x) = ax^3 + bx^2 + cx + d = e\), where \(a, b, c, d, e > 0\). The answer must be right to 4 decimal places. How can we do this efficiently? We can use binary search to solve this in \(O(\log n)\) time. The key idea is to realize that \(f\) is an non-decreasing function, then \(x_a \leq x_b \rightarrow f(x_a) \leq f(x_b)\). Therefore, we can run a binary search in \(x\) in order to find the answer. However our binary search will be slightly different as now we don’t need to find a precise answer, but one with a precision of 4 decimal places. This means that we want to find an x such that \(|e - f(x)| < 0.0001\).
Searching for the Answer
Let’s consider this problem.
- What would be the brute force approach?
- How can we improve this basic solution?
The key thing is to realize that if we can reach the top with an initial strength \(k_0\), then any initial strength \(k, k > k_0\) can also reach the top. Therefore we can use binary search to look for the minimum value of \(k\) that reaches the top from 1 to \(r + 1\). As we can determine for a given \(k\) if it is possible to reach the top, then this solution would have a complexity of \(O(n \log(r))\).
Finally, we would like to show you an interesting problem. This problem shows how to combine force brute and binary search in an unexpected way.
Please, enter the next link and read carefully the problem: Aggresive cows.
Like always take few minutes before looking the code.
#include <bits/stdc++.h>
using namespace std;
const int size = 1e5 + 1;
int ns[size];
int n, c;
bool query (int x) {
int cont = 1;
int p = ns[0];
for (int i = 1; i < n; i++) {
if (ns[i] - p >= x) {
cont++;
p = ns[i];
}
}
if (cont >= c) return true;
return false;
}
int bs(int l,int r){
while (l < r) {
int med = l + (r - l + 1) / 2;
if (query(med)) l = med;
else r = med - 1;
}
return l;
}
int main() {
int t;
scanf("%d", &t);
while(t--){
scanf("%d %d", &n, &c);
for(int i = 0; i < n; i++) scanf("%d", &ns[i]);
sort(ns, ns + n);
int l = ns[0], r = ns[n - 1];
printf("%d\n", bs(l,r));
}
return 0;
}
Recommended readings:
- Errichto - Binary search lecture (C++ and Python)
- Topcoder - Binary search
- Competitive Programmer’s Handbook, chapter 3
- Principles of Algorithmic Problem Solving, section 10.3
You can find the contest here.
A: Easy Calculation
Easy Calculation
For the statement you can notice that there is just one answer, then \(A \cdot x + B \cdot \sin(x) - C = 0\) must have a change of sign around x, we can find it with binary search.
Code
#include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
int main () {
ios::sync_with_stdio(false); cin.tie(0);
int tc;
cin >> tc;
while (tc--) {
int a, b, c;
cin >> a >> b >> c;
double l = -1e9, r = 1e9;
for (int it = 0; it < 100; it++) {
double m = (l + r) / 2.0;
if (a * m + b * sin(m) - c < 0) l = m;
else r = m;
}
cout << fixed << setprecision(6) << l << '\n';
}
return (0);
}
B: Frodo and pillows
Frodo and pillows
If you put \(x\) pillows in Frodo’s position, then the optimal is to put \(x - 1\) pillows to its left and right, \(x - 2\) to the next position to the left and right, and so on. Moreover, if we can put \(x\) pillows in Frodo’s position with this strategy, we can put \(x - 1\) pillows, too. Then, we can fix the number of pillows with binary search and calculate how many pillows are needed.
Code
#include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
int main () {
ios::sync_with_stdio(false); cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
int l = 1, r = m;
auto sum = [&] (ll val, ll pos) {
ll sum = val * (val + 1) / 2;
if (pos <= val) {
sum -= (val - pos) * (val - pos + 1) / 2;
} else {
sum += pos - val;
}
return sum;
};
auto check = [&] (int val) {
return (val + sum(val - 1, k - 1) + sum(val - 1, n - k) <= m);
};
while (l != r) {
int m = (l + r + 1) / 2;
if (check(m)) l = m;
else r = m - 1;
}
cout << l << '\n';
return (0);
}
C: Sagheer and Nubian Market
Sagheer and Nubian Market
If you fix the value of \(k\) you can compute the cost of each item and take the minimum \(k\) prices. Moreover, if you can buy \(k\) items, you can buy \(k - 1\) items, too. Then, we can find \(k\) using binary search.
Code
#include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
int main () {
ios::sync_with_stdio(false); cin.tie(0);
int n, s;
cin >> n >> s;
vector <int> arr(n);
for (int& elem: arr) cin >> elem;
auto get = [&] (int k) {
vector <ll> n_arr(n);
for (int i = 0; i < n; i++) n_arr[i] = arr[i] + 1LL * (i + 1) * k;
sort(all(n_arr));
return accumulate(begin(n_arr), begin(n_arr) + k, 0LL);
};
int l = 0, r = n;
while (l != r) {
int m = (l + r + 1) / 2;
if (get(m) <= s) l = m;
else r = m - 1;
}
cout << l << ' ' << get(l) << '\n';
return (0);
}
D: Modified GCD
Modified GCD
We can find the divisor of \(a\) and \(b\), then for each query iterate for the divisors of \(a\), and for each divisor of \(a\) that is in \([l, r]\) check if it is in the divisors of \(b\) using binary search.
Code
#include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
int main () {
ios::sync_with_stdio(false); cin.tie(0);
int a, b;
cin >> a >> b;
auto getDivisors = [&] (int num) {
vi div;
for (int d = 1; d * d <= num; d++) {
if (num % d) continue;
div.pb(d);
if (d * d != num) div.pb(num / d);
}
return div;
};
vi div_a = getDivisors(a);
vi div_b = getDivisors(b);
sort(all(div_b));
int q;
cin >> q;
while (q--) {
int l, r;
cin >> l >> r;
int ans = -1;
for (int d: div_a) {
if (not (l <= d and d <= r)) continue;
if (binary_search(all(div_b), d)) {
ans = max(ans, d);
}
}
cout << ans << '\n';
}
return (0);
}
E: Solve it
Solve it
There must be a change of sign around \(x\), then we can find the value of \(x\) using binary search and check if the \(x\) found holds the equation.
Code
#include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
int main () {
ios::sync_with_stdio(false); cin.tie(0);
double p, q, r, s, t, u;
while (cin >> p >> q >> r >> s >> t >> u) {
auto eval = [&] (double x) {
return p * exp(-x) +
q * sin(x) +
r * cos(x) +
s * tan(x) +
t * x * x +
u;
};
double l = 0, r = 1;
for (int it = 0; it < 100; it++) {
double m = (l + r) / 2.0;
if (eval(m) > 0) l = m;
else r = m;
}
const double EPS = 1e-8;
if (abs(eval(l)) < EPS) {
cout << fixed << setprecision(4) << l << '\n';
} else {
cout << "No solution\n";
}
}
return (0);
}
F: The Stern-Brocot Number System
The Stern-Brocot Number System
It holds:
\[\frac{a}{b} < \frac{c}{d} \to ad < bc\]
\[ad < bc \to ad + ab < bc + ab \to a(b + d) < b(a + c) \to \frac{a}{b} < \frac{a + c}{b + d}\]
\[ad < bc \to ad + cd < bc + cd \to (a + c)d < (b + d)c \to \frac{a + c}{b + d} < \frac{c}{d} \]
\[\to \frac{a}{b} < \frac{a + c}{b + d} < \frac{c}{d} \]
Initialiy we have: \(\frac{a}{b} = \frac{0}{1}, \frac{c}{d} = \frac{1}{0}\)
Then, using the above property we can know where should we go and as in each step the numerator or denominator of one bound is increasing, the algorithm will finish in \(O(n + m)\) where \(n, m\) is the numerator and denominator given.
Code
#include <bits/stdc++.h>
using namespace std;
int main () {
int n, m;
while (cin >> n >> m) {
if (n == 1 and m == 1) break;
int a = 0, b = 1;
int c = 1, d = 0;
while (true) {
int p = a + c;
int q = b + d;
if (p == n and q == m) {
break;
}
if (p * m < q * n) {
cout << 'R';
a = p, b = q;
} else {
cout << 'L';
c = p, d = q;
}
}
cout << '\n';
}
return (0);
}
G: K-Dominant Character
K-Dominant Character
We can fix each different letter of the given string, then for each letter if it is a \(k\)-dominant character, then it is also a \((k + 1)\)-dominant character, then we can use binary search and the idea of cummulative sums to get the minimum \(k\) for each letter.
Code
#include <bits/stdc++.h>
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int main () {
ios::sync_with_stdio(false); cin.tie(0);
string s;
cin >> s;
set <char> sigma(all(s));
int ans = sz(s);
auto check = [&] (int m, char c) {
vector <int> frec(30, 0);
for (int i = 0; i < m; i++) frec[s[i] - 'a']++;
bool ok = (frec[c - 'a'] > 0);
for (int i = m; i < sz(s); i++) {
frec[s[i - m] - 'a']--;
frec[s[i] - 'a']++;
ok &= (frec[c - 'a'] > 0);
}
return ok;
};
for (char c: sigma) {
int l = 1, r = sz(s);
while (l != r) {
int m = (l + r) / 2;
if (check(m, c)) r = m;
else l = m + 1;
}
ans = min(ans, l);
}
cout << ans << '\n';
return (0);
}


Make snowflake patterns, learn how to create a five-pointed star with a single cut (like Betsy Ross) and more!
Instructions for our online paper folding activity are below; or you can go straight to the gallery to see what others have been up to and start folding paper online yourself! Or - jump right in and make a flake: from prefolded paper (easiest); with folding guidelines; from scratch (for experts).
Here are the basic rules:It's not origami, is it, but has many similarities. We plan to introduce some additional folding techniques that will enable us to do more origami-ish stuff. Take a look at these origami simulations:
In the meantime, try making snowflakes or other interesting shapes (there are zillions of sites with instructions; here are a few):
http://www.myweb3000.com/snowflakes.html
http://www.papersnowflakes.com/preview1.htm
http://www.geocities.com/starsandflakes/
http://ms-t-inc.com/pdf-file/snowflak.pdf
http://mama.essortment.com/papersnowflake_rfiq.htm
http://flagday.com/history/star_in_one_cut/flagstar.shtml
A shockwave snowflake "designer"!: http://www.explorescience.com/activities/Activity_page.cfm?ActivityID=13


Umeed - A drop of hope (NGO) is formed to provide a platform to nation youth.
Founder: Mr. Shubhrajeet Gautam (January 26, 2011)
Currently we are having an outreach of 30,000+ volunteers in 7 states across the country.
We are working every single day for the under-privileged sections of our society.
Tracing back to the inception, Umeed was established with a small cloth donation campaign as its
first stepping milestone for the organisation.
The main motive behind the establishment was child welfare.
We rely on donations to carry out our vision.


Path with wildcards
Supported wildcards:
?
(single character except "/"),
*
(any count of characters except "/"),
**
(any count of characters)
Covert
As C# regular expression


- Women in Tech Panelist - HackCU Feb 2018
- Keynote Speaker - ChickTech Denver Jan 2018
- CS Women Panelist with NCWIT - WCET Oct 2018
- Anita Borg Scholar - Grace Hopper Conference Oct 2018
- President & Cofounder - DU Women in Computing 2014-2017
Please reach out to me if you have an opportunity, and I would love to
help!


WTO Chief Azevedo: China a champion of multilateral system - Xinhua
by Dhwani MehtaIn a recent interview with China’s state news agency, Xinhua, Roberto Azevedo, Director-General of the World Trade Organization (WTO), made some comments on the recent challenges faced by the global economy, in light of the US-China trade war.
Key Quotes:
“China has been an important supporter of multilateral collaboration.”
"Uncertainty is dragging down the economy because investors are not investing in projects, in enterprises, that are critical to keep the economy growing, and that kind of uncertainty needs to be scaled down
"There's not a whole lot of room" now for most countries to use traditional tools in fiscal and monetary policies to stimulate the economy.
"Trade conflicts heighten uncertainty, which is leading some businesses to delay the productivity-enhancing investments that are essential to raising living standards."
"I think what is left is making sure that the trade tensions diminish and that the uncertainties (are) reduced, and ... the best way to do it is through more collaboration."
"The more we can do to help diminish the trade tensions, the more we can do to reduce the level of uncertainties in the world, the better it will be for the global economy and for everybody else."
Unilateral actions cannot be "the end of the game" of trade tensions, as solutions and agreements are the ultimate objectives.
"The longer we take to get there, the more the global economies would suffer."
"There are no winners in this scenario."


A list of past FITE Club events.
|
Speaker |
Company |
Topic |
|
Leo Martins |
Pontus Networks |
Automating performance tuning |
|
Wadud Miah |
Hierarchical parallelism: MPI etc. |
|
|
Stephen Ball |
Embarcadero |
Taking data "safely" to mobile |
|
Matthew Revell |
Couchbase |
Sub-millisecond NoSQL for finance |
|
Jason Lango |
Bracket Computing |
Enterprise Computing Reimagined |
|
Mark Shuttleworth |
Canonical |
Why you should specialise |
|
Andrew Wilson |
Junocube |
Scale-out real-time risk aggregation |
|
Prateep Bandharangshi |
Waratek |
Securing your Java Runtime Environment |
|
Uri Cohen |
Gigaspaces |
In-memory data grids |
|
Jacoby Thwaites |
SPARKL |
Business transaction router |
|
Richard Weerasinghe |
Elastic Box |
Application automation |
|
Tim Moreton |
Acunu |
Analytics on FIX message streams |
|
Chuck Doerr |
openf.in |
Using HTML5 to replace thick clients |
|
Stuart McCaul & Richard Shaw |
Basho |
NoSQL: Safer than SQL? |
|
Alex Heneveld |
Cloudsoft |
Working Models, or how cloud is growing up and thinking about applications |
|
John O'Hara |
AMQP.org |
The Advanced Message Queuing Protocol |
|
Peter Holditch |
AppDynamics |
Evolving toward DevOps through transaction-centric performance management |
|
Patrick Kerpan |
CohesiveFT |
The Software Defined Data Center |
|
Andy Piper and Darach Ennis |
Push Technology |
Diffusion - Innovation at the edge and beyond |
|
John Matthew Holt |
Waratek |
Achieving Genuine Java Multitenancy |
|
Ian Pratt |
Bromium |
Securing the Desktop with Micro-virtualization |
|
Ilan Kinreich |
Radware |
DDoS Attacks - Lessons Learned from Real Life Experience |
|
David White |
Kusiri |
Fueling the Big Data Revolution |
|
Mark Dawber (Business Development Manager, Intergence) and Stace Hipperson (CTO of Real Status) |
Intergence and Real Status |
Hyperglance |
|
Dave Farley |
LMAX Ltd. |
Continuous Delivery |
|
Joe Baguley and Beth Brown |
VMWare | CloudFoundry |
|
Luke Marsden |
Hybrid Logic |
Hybrid Cluster, and how to build failure-tolerant distributed systems |
|
Andy Ormsby |
Acunu | Big Data and Apache Cassandra |
| Lorenzo Alberton Chief Technical Architect |
Mediasift | Mining the Real Time Web |
|
Steve Elliott and Simon Cook |
Oracle |
Java 7 and 8 |
|
Jim Moores |
OpenGamma |
Open source risk management |
|
John Ashley |
NVIDIA |
CUDA for Finance |
|
Mark Delbaere |
Swift |
ISO 20022 For Internal Integration |
|
Richard Fichera |
Forrester |
HP and Cisco - Technology Strategy and Execution |
|
Richard Croucher |
Informatix Solutions |
Bypassing TCP to lower latency and increase performance |
|
Jack Kreindler |
GenieDB |
Cutting through the new database jungle: A 'consistent argument' for Finance |
|
Jay Bregman |
eCourier |
Creating Network Value in a SaaS World: Building a Platform for On-Demand Logistics |
|
Richard Nicholson |
Paremus |
Complexity Components & Clouds |
|
Christine Ashton |
Transport for London (TfL) |
Enterprise 2.0 |
|
Ian Pratt |
Citrix |
Local Client Virualization |
|
Alexis Richardson and Matthias Radestock |
RabbitMQ |
Innovation in finance. AMQP |
|
Dan Chester |
Iceotope |
Liquid cooled servers for the data centre |
|
William Fellows |
The 451 Group |
The Cloud Codex |
|
Brian Oliver |
Oracle (Tangosol) |
Trading on a Data Grid |
|
Matt Deacon |
Microsoft |
Disruptive innovation and the changing software lanscape |
|
Richard Fichera |
HP |
A talk on HP Perspectives: Data Center Thermal Issues and Internal IT Consolidation |
|
Henry Harrison |
Detica |
The challenges of using FPGAs in investment banking |
|
Dr. Richard Nicholson & David Savage |
Paremus Ltd |
A talk on OSGi Construction and Assembly of Solutions using Service Component Architecture |
|
Dr. Mike Edwards |
IBM |
Service Oriented Architecture: Construction and Assembly of Solutions using Service Component Architecture and Service Data Objects |
|
Adrian Colyer |
Interface 21 |
The Vocabulary of Enterprise Applications - Simplifying Enterprise Application Development with Spring 2.0 and AOP |
|
Richard Nicholson |
Paremus |
Autonomic Computing and the Enterprise |
|
Andy Carmichael |
Ivis Technologes |
Who moved my process? An exploration of agile management for agile teams |
|
Graeme Burnett |
Enhyper Solutions |
Open Source Intelligence in Finance |
|
Dr. Mike Stonebraker |
StreamBase Systems |
Stream Processing in Real-time Financial Services |
|
Melvyn White |
Paremus |
Architecting With No Frame Of Reference |
|
Steve Ross-Talbot |
Pi4 Technologies |
Why do I need to Choreograph as opposed to Orchestrate my services in financial IT? |
|
Alastair Green |
Choreology |
What WS-BPEL will do for you .. and what it won't! |
|
Guy Bunker |
Symantec Corp. |
Automating Information Lifecycle Management |
|
Dave Pearson |
Oracle Corporation |
SOA enabled Enterprise Grids and Progress in Grid Standards |
|
Philip Longden |
UBS Investment Bank |
Practical Experience of Model-Driven Architecture at UBS |
|
Hugh Grant |
Credit Suisse First Boston |
Enterprise SOA without UDDI |
|
Dr. Terry Payne |
University of Southampton |
UDDI and Semantic Web (Services) |
|
Graeme Burnett |
Deutsche Bank |
HDF5 in Finance |
|
Lance Walton |
TeamInABox |
Agile Methods - An Introduction With an Example of their Application to the Problem of Poor Data Quality |
|
Alexis Richardson |
MetaLogic Oy |
Providing a clean fast and resilient distributed shared memor |
|
Nigel Warren |
Fireflies Turtles and the Life of Information |
|
|
Alastair Green |
Choreology |
Business Transaction Management (BTM) software |
|
Guy Bunker |
Veritas |
Uutility computing within the modern enterprise |
|
Professor David Walker |
Cardiff University |
Grid technology: a serious contender or a pretender? |
|
Melvyn White |
Deloittes & Touche |
Obtaining Tax Credits against R&D projects |
|
Andrew Harrison |
Sun |
CMT - multicore processor technology , Infiniband vs TCP Offload, Performance experiences with Oracle RAC. |


Gala's Radamel Falcao will not play against Real Madrid
The Colombian forward has not recovered from injury
by Sport ENGalatasaray will not be able to call on star forward Radamel Falcao to play Real Madrid at the Santiago Bernabeu on Wednesday, because the player has not recovered from a tendon injury.
Falcao got injured at PSG on October 4 and is taking treatment in Spain at the moment. Falcao might, as a former Atletico Madrid player, have liked to take on Los Blancos.
The Colombian legend will stay in Spain getting treatment until Nov. 11, as revealed by Galatasaray medic Yener Ince on their social media accounts.


Google Earth Enterprise Documentation Home | Fusion tutorial
About This Tutorial
Google Earth Enterprise Fusion is designed for organizations that want to display their own geospatial data in Google Earth and Google Maps. You can use it to create graphically rich geographic information system (GIS) databases for distribution to your customers or in-house end users. With Google Earth Enterprise Fusion, you can integrate your own geospatial data, publish it to the Google Earth Enterprise Server, and view it using Google Earth Enterprise Client (EC), the Google Maps API, or the Google Earth API.
Before you begin working with real data in Google Earth Enterprise Fusion, it is important for you to familiarize yourself with the process of defining and building different types of data. This tutorial provides a series of exercises that you can perform in an environment where it is all right to make mistakes. Once you start working with real data, it will be more difficult to correct mistakes, so please take your time working through the tutorial until you feel comfortable with Google Earth Enterprise Fusion.
The Basic Tasks section of this tutorial guides you through building a Google Earth Enterprise Fusion database from raw source material, and publishing it using the Google Earth Enterprise Server, using the tutorial files provided on the Google Earth Enterprise Fusion installation DVD.
Note: Work through the first five lessons in order.
The Advanced Tasks section of this tutorial guides you through more advanced topics. You can work through the advanced lessons in any order you wish. Alternatively, you can skip the Advanced Tasks section until you want to learn about something new. Then, you can come back to the tutorial and work through the lessons of your choice.
Audience
This guide is intended for individuals who are new to Google Earth Enterprise Fusion. It assumes that you have some familiarity with GIS data and have used a Google Earth client, but have no familiarity with this application. It also assumes that Google Earth Enterprise Fusion, the Google Earth Enterprise Server, and Google Earth EC have been installed either on a network drive accessible to you or on your local workstation. If any of those three applications are not installed, contact your system administrator or refer to Installation overview.
In This Guide
This guide provides five basic lessons and nine advanced lessons.
The Basic Tasks section includes:
- Setting Up the Tutorial
- Defining and Building Resources
- Defining and Building Projects
- Defining and Building Databases
- Publishing and Viewing a Database
The Advanced Tasks section includes:
- Configuring Display Rules for Point Data
- Configuring Display Rules for Polygon Data
- Importing and Exporting Style Templates
- Configuring a Searchable Database
- Specifying Search Fields for Individual Layers
- Creating a Map Database
- Creating Imagery Mosaics
- Segmenting Large Imagery Files
- Creating a Historical Imagery Project
Appendix A: Sample Data Files provides a list of all of the sample data files included when you install the tutorial data.


From the Earth to the Moon
A JBoss Data Grid Cross-Site Replication Demo
Widget Creator
Color:
Cancel
Add


| Class | Rails::Generator::Commands::Destroy |
| In: |
vendor/rails/railties/lib/rails_generator/commands.rb
|
| Parent: | RewindBase |
Undo the actions performed by a generator. Rewind the action manifest and attempt to completely erase the results of each action.
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 500 500: def complex_template(*args) 501: # nothing should be done here 502: end
Remove each directory in the given path from right to left. Remove each subdirectory if it exists and is a directory.
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 464 464: def directory(relative_path) 465: parts = relative_path.split('/') 466: until parts.empty? 467: partial = File.join(parts) 468: path = destination_path(partial) 469: if File.exist?(path) 470: if Dir[File.join(path, '*')].empty? 471: logger.rmdir partial 472: unless options[:pretend] 473: if options[:svn] 474: # If the directory has been marked to be added 475: # but has not yet been checked in, revert and delete 476: if options[:svn][relative_path] 477: system("svn revert #{path}") 478: FileUtils.rmdir(path) 479: else 480: # If the directory is not in the status list, it 481: # has no modifications so we can simply remove it 482: system("svn rm #{path}") 483: end 484: # I don't think git needs to remove directories?.. 485: # or maybe they have special consideration... 486: else 487: FileUtils.rmdir(path) 488: end 489: end 490: else 491: logger.notempty partial 492: end 493: else 494: logger.missing partial 495: end 496: parts.pop 497: end 498: end
Remove a file if it exists and is a file.
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 419 419: def file(relative_source, relative_destination, file_options = {}) 420: destination = destination_path(relative_destination) 421: if File.exist?(destination) 422: logger.rm relative_destination 423: unless options[:pretend] 424: if options[:svn] 425: # If the file has been marked to be added 426: # but has not yet been checked in, revert and delete 427: if options[:svn][relative_destination] 428: system("svn revert #{destination}") 429: FileUtils.rm(destination) 430: else 431: # If the directory is not in the status list, it 432: # has no modifications so we can simply remove it 433: system("svn rm #{destination}") 434: end 435: elsif options[:git] 436: if options[:git][:new][relative_destination] 437: # file has been added, but not committed 438: system("git reset HEAD #{relative_destination}") 439: FileUtils.rm(destination) 440: elsif options[:git][:modified][relative_destination] 441: # file is committed and modified 442: system("git rm -f #{relative_destination}") 443: else 444: # If the directory is not in the status list, it 445: # has no modifications so we can simply remove it 446: system("git rm #{relative_destination}") 447: end 448: else 449: FileUtils.rm(destination) 450: end 451: end 452: else 453: logger.missing relative_destination 454: return 455: end 456: end
When deleting a migration, it knows to delete every file named "[0-9]*_#{file_name}".
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 505 505: def migration_template(relative_source, relative_destination, template_options = {}) 506: migration_directory relative_destination 507: 508: migration_file_name = template_options[:migration_file_name] || file_name 509: unless migration_exists?(migration_file_name) 510: puts "There is no migration named #{migration_file_name}" 511: return 512: end 513: 514: 515: existing_migrations(migration_file_name).each do |file_path| 516: file(relative_source, file_path, template_options) 517: end 518: end
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 520 520: def route_resources(*resources) 521: resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 522: look_for = "\n map.resources #{resource_list}\n" 523: logger.route "map.resources #{resource_list}" 524: gsub_file 'config/routes.rb', /(#{look_for})/mi, '' 525: end


Spinning Awards | An improvisational visualization
A project by the informationinaction initiative | Northeastern University | College of Arts, Media and Design | Team Kristian Kloeckl (PI), Jeffrey Weng, Win Overholser
Spinning Awards | An improvisational visualization
A project by the informationinaction initiative | Northeastern University | College of Arts, Media and Design | Team Kristian Kloeckl (PI), Jeffrey Weng, Win Overholser


Improve this Doc
A Range is a control that allows you to selecet a range of values.
Basic Usage
Demo Source
```html
```
Note that in this example, you can setup data bindings using ngModel
You can also add tooltip which displays the current value by adding the property `pin`
```html
```
If you wanted to increment the value based on a certain value, you can add the `step` property.
```html
```
If you want to knobs, you can add the `dualKnobs` property
```
```


Mode: java, theme: github
Mode: javascript, theme: monokai
Reload NEW! Props
Mode: javascript, theme: monokai (using setOptions property)
Reload NEW! Props


JURASSIC PARK A film review by Ken Johnson Copyright 1993 Ken Johnson
2:10, PG-13, Science Fiction/Action, 1993 Director: Steven Spielberg Cast: Sam Neill, Laura Dern, Richard Attenborough, Jeff Goldblum, Samuel L. Jackson
Richard Attenborough makes living dinosaurs from their DNA and makes a theme park, Jurassic Park, of them on an island of Costa Rica. He invites scientists Sam Neill, Laura Dern, and Jeff Goldblum to comes see Jurassic Park.
JURASSIC PARK is one of the projected summer blockbusters and has been incredibly hyped up. This film is not as good as it was supposed to be. However, the film is still worth going to see. Definitely see this film on the big screen because of the big budget special effects that will definitely loose their impact on a television screen. On a scale of zero to five, I give JURASSIC PARK a four. JURASSIC PARK is rated PG-13 for violence and explicit language.
JURASSIC PARK is loosely based on the novel by Michael Crichton, who also co-wrote the film. The film doesn't follow the novel very faithfully and those that have read the novel may be disappointed with the film. The special effects for this film are great, especially the dinosaurs. They appear so life-like.
The film is well written and moves along smoothly. Some parts are quite predictable, but what can you expect. The film does have some surprises too. The characters are well done and are written so that the viewer can't help from hoping that they survive (or bite it depending on your frame of mind).
The acting in JURASSIC PARK is great. Sam Neill (MEMOIRS OF AN INVISIBLE MAN, DEAD CALM) does a great job as one of the paleontologists and Laura Dern (WILD AT HEART, RAMBLING ROSE) is excellent as the other paleontologist. Richard Attenborough (director of CHAPLIN and GANDHI) is one of my favorite actors in this film. His performance is perfect. Jeff Goldblum (THE FLY, INTO THE NIGHT) does a reasonably good job. His acting is not the best (but is much better than some of his old films -- TRANSYLVANIA 6-5000 comes to mind). Samuel L. Jackson (NATIONAL LAMPOON'S LOADED WEAPON 1, PATRIOT GAMES) is my other favorite actor in this film.
-------- Ken Johnson<EMAIL_ADDRESS>.
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


{% extends 'base.html' %}
{% load mvtester_tags %}
{% block title %}Register for AppCray-Z{% endblock %}
{% block css %}
{% endblock %}
{% block body %}
Instant Team
"I went from concept sketch to working with a team of volunteer developers within a week. We all really
feel like a team. It is a lot of fun." -- Jason Wilkins (Bartender by night - Entreprenuer by day)
Ideas Compete
"I have ideas all them time. This gives ma way to see what resonates with others." -- Sally Lenat (Receptionist and Entreprenuer)
Your turn
{% if form.errors %}
{% if form.errors %}
Oops, there were errors in the above fields.
{{ form.errors }}
If I was doing this for real, I'd use popovers for the messages.


Setting your profile location
1. Enter your location in the above field and hit the "Search" button
You can start with a zip code or city name, but need to provide a bit more information if the zip code or city are not unique on our planet.
ZIP Code examples
90010 / 90010, US / 80331, Germany / W1C, UK
City examples
Hanover / Hanover, US / Hannover, Germany Birmingham / Birmingham, US / Birmingham, UK
2. We will try to find the coordinates for your location
If successful you will see a marker on a map and you can move it with your mouse to your exact location, if you like to.
3. Verify your location (on the right)
In some instances region and city cannot be resolved properly from the previously found coordinates. You will need to enter them manually or try to relocate the marker on the map just a tiny bit. You can also add/change your neighborhood on the right side.
4. Submit your data (on the right)
If everything seems to look alright, submit your data, otherwise just cancel your request.


16 Jan 2021 - Abel Pena
As I look for jobs and begin really searching for what I would like to accomplish in my software dev career, I have taken upon myself the challenge to expose myself to many different frameworks and languages I have yet to develop in.
At this point, my ideas are ever changing and growing every day.
From my guesstimation of difficulty I would like to develop a slew of different utilities in Kotlin for android. From least to most difficult, these are the applications I would like to develop: *Car Maintenance Reminder Application/BillsToPay Reminder App *Workout Application utilizing different hypertrophy and strength training templates. *MovieMatch-tinder but for you and your SO to help choose movies yall would like to watch.
This should be a fun learning experience with many different aspects of android development to learn from.
-Abel


Learn more about the individuals connected to Catherine and the relationship between them. The information in these People Files is a culmination of my research based on Catherinian Scholarship. Some files have more information available than others, and some have more analysis attached to their page. Hopefully, these People Files will prove helpful to future scholars or the curious wanderer. These pages are linked from the Network Visualizations page. Feel free to explore them in your own order!
Banner Photo: Basilica Cateriniana di San Domenico in Siena, Italy. By Jessica Mills, 2014.


{% extends "layout.html" %} {% block title %}Zero-OS Hub{% endblock %} {% block content %}
With this tool, you can create a customized flist by merging multiple flist together.


Defines | |
| #define | BINARY_HEAP_NULL ((void *) 0) |
| A null BinaryHeapValue. | |
Typedefs | |
| typedef void * | BinaryHeapValue |
| A value stored in a BinaryHeap. | |
| typedef int(* | BinaryHeapCompareFunc )(BinaryHeapValue value1, BinaryHeapValue value2) |
| Type of function used to compare values in a binary heap. | |
| typedef struct _BinaryHeap | BinaryHeap |
| A binary heap data structure. | |
Enumerations | |
| enum | BinaryHeapType { BINARY_HEAP_TYPE_MIN, BINARY_HEAP_TYPE_MAX } |
| Heap type. More... | |
Functions | |
| BinaryHeap * | binary_heap_new (BinaryHeapType heap_type, BinaryHeapCompareFunc compare_func) |
| Create a new BinaryHeap. | |
| void | binary_heap_free (BinaryHeap *heap) |
| Destroy a binary heap. | |
| int | binary_heap_insert (BinaryHeap *heap, BinaryHeapValue value) |
| Insert a value into a binary heap. | |
| BinaryHeapValue | binary_heap_pop (BinaryHeap *heap) |
| Remove the first value from a binary heap. | |
| int | binary_heap_num_entries (BinaryHeap *heap) |
| Find the number of values stored in a binary heap. |
A binary heap is a heap data structure implemented using a binary tree. In a heap, values are ordered by priority.
To create a binary heap, use binary_heap_new. To destroy a binary heap, use binary_heap_free.
To insert a value into a binary heap, use binary_heap_insert.
To remove the first value from a binary heap, use binary_heap_pop.
| typedef int(* BinaryHeapCompareFunc)(BinaryHeapValue value1, BinaryHeapValue value2) |
Type of function used to compare values in a binary heap.
| value1 | The first value. | |
| value2 | The second value. |
| enum BinaryHeapType |
Heap type.
If a heap is a min heap (BINARY_HEAP_TYPE_MIN), the values with the lowest priority are stored at the top of the heap and will be the first returned. If a heap is a max heap (BINARY_HEAP_TYPE_MAX), the values with the greatest priority are stored at the top of the heap.
| void binary_heap_free | ( | BinaryHeap * | heap | ) |
Destroy a binary heap.
| heap | The heap to destroy. |
| int binary_heap_insert | ( | BinaryHeap * | heap, | |
| BinaryHeapValue | value | |||
| ) |
Insert a value into a binary heap.
| heap | The heap to insert into. | |
| value | The value to insert. |
| BinaryHeap* binary_heap_new | ( | BinaryHeapType | heap_type, | |
| BinaryHeapCompareFunc | compare_func | |||
| ) |
Create a new BinaryHeap.
| heap_type | The type of heap: min heap or max heap. | |
| compare_func | Pointer to a function used to compare the priority of values in the heap. |
| int binary_heap_num_entries | ( | BinaryHeap * | heap | ) |
Find the number of values stored in a binary heap.
| heap | The heap. |
| BinaryHeapValue binary_heap_pop | ( | BinaryHeap * | heap | ) |
Remove the first value from a binary heap.
| heap | The heap. |


Toggle navigation
HELIOS
Resting Mode
Walking Mode
Text Recognization
Describe Scene
Describe Above Scene


I was working on the Zen Garden sprint and realised that I had forked my repo incorrectly.
I spent a good few hours trying to figure out where I had gone wrong. It seemed like a very minor thing so I thought that it would be best that I try and troubleshoot the issue myself. A few hours later I reah4sed that I was going to have to admit defeat and seek assistance.
I felt really frustrated and dumb. I questioned myself and whether I was good enough for EDA. Very dramatic, I know.
Fortunately I was at EDA when this issue occurred. Don was able to walk me through where I had gone wrong I learned that I needed to switch branches on Command line in order to work on different versions of my repo. He also taught me a lot of basic but handy tips for using Command line.
Working through all the Sprint 5 Javascript exercises, especially towards the end, I found myself feeling very challenged.
I'm not sure if this is an 'elegant technique', but I find it really helpful to solve a lot of JS by writing all the components of a question down i.e. what are my functions, variables, do I need to use a loop, etc. When you have all the information written down in simple terms, or drawn in a diagram if you're a visual learner you can much more easily see exactly what a problem is asking you to solve.
I used this method to solve a few problems and felt like a champ. I have to admit, there were also a fair few I had to go googling or ask for a hint from Free Code Camp.
I learned that I needed to be patient with myself, and to not let my frustration get the best of me. I also learned that I need to find ways of learning that help me as a visual learner. Especially when learning JavaScript which can seem very abstract whereas HTML and CSS are very tangible.
8/10 I had no idea until I googled it that I already do a lot of this to write steps for my algorithms.
6/10 I don't feel confident enough to experiment yet. Sometimes I'll just write a function just to see what happens.
2/10 I had never even heard of this before researching but sounds like a cool idea as a rubber ducky can't laugh at me explaining code.
2/10 Most of the time I have no idea what they mean.
5/10 I understand what it does but not in a context of using it to solve problems.
9/10 There are a plethora of amazing and helpful resources out there to help solve pretty much any problem.
9/10 I haven't done a lot of this yet but have Code Help Desk on Slack to debug a few issues.
9/10 I haven't done a lot of this yet but Don was a huge help that one time I needed help.
7.5/10 I have been trying to keep track of learnings and challenges so that I can apply them to future problems.


Menu
Our Story
Community Response
Volunteering
Donate
Community Partners
Media Coverage
Awards and Grants
Contact
Our Story
Our Story
Community Response
Get Involved
Volunteering
Donate
Community Partners
Recognition
Media Coverage
Awards and Grants
Contact


Building a Critical Mass Sound System - Part 1
It's all in the name
I’ll be basing my build off the powerful ”Beastbox”, so it only makes sense this project is named:
Son of a Beast
I’ll be attempting to out-perform it by a few dB and make more use of the battery packs. We’ll see if I succeed or not. Part 2 is coming soon which will go through streaming sound to a remote system.


's Swimlains
Sign Out
Welcome to Swimlain!
Let's get started! What classes are you taking right now?
Add Class
's Classes
Done adding classes
Add Class
TODAY
Add Class
Name
Type
Task
Due Date
# of Days
Notes
Save
Delete Class
Notes:
test
Delete Task
×
Name of Class
Add Class


rotten > Library > Culture > Eternal Flames
Eternal Flames
|
TO ELVIS IN MEMORIUM
You gave yourself to each of us in
some manner. You were wrapped in
thoughtfulness and tied with love.
May this flame reflect our never
ending respect and love for you.
May it serve as a constant reminder
to each of us of your eternal presence.
We all went to Graceland and went to Elvis's grave and next to the grave there was a plastic box with rainwater in it. I asked a security guard what it was and he said it "was the eternal flame." We mentioned that it wasn't burning, and he said "It's a semi-eternal flame." The spirit of the song was inspired there. Blame it on Elvis.
-- Michael Steele of the Bangles
- German Chancellor Gerhard Schroder accidentally extinguishes the Yad V'Shem eternal flame at the Holocaust memorial in Israel. (November 1, 2000)
|
|
- Eternal flame at the Arc de Triomphe in Paris lit in 1921, extinguished in 1998 by soccer fan's urine stream
- Eternal flame of the Cherokee Nation at Red Clay Park, TN lit 1984, extinguished many, many times
- JFK flame in Arlington National Cemetery lit in 1963, doused with holy water from by Catholic school group
- Eternal flame in memory of Elvis Presley at his Circle-G ranch in Memphis, TN lit in 1981, burned out a few years later and never re-lit
- Eternal flame at the shrine of Brighid in Kildare, Ireland lit around 200 AD, extinguished in 1220 by order of a Catholic bishop; lit again and extinguished by Henry VIII; lit again in 1993
- Eternal flame in Manitowoc, Wisconsin lit on May 30, 1969, extinguished 1974
- Eternal flame in Troy, Alabama lit on May 6, 2000, extinguished Feb 21, 2001
- Eternal flame in Orchard Park, NY
- Eternal flame at the Napier War Memorial, Hawke's Bay NZ lit in 1956, extinguished prior to 1995
- Eternal flame in Cedar Rapids, IA extinguished in 1954 because of safety concerns
- Eternal flame in Ottawa extinguished in anticipation of G8 protests
- Eternal flame in Crestview, FL lit in 1994, extinguished 2002 and many other times previously
- Eternal flame dedicated to war veterans in Charlotte County, FL lit by Kiwanis July 4, 2003, extinguished less than a month later
- Eternal flame at the National Civil Rights Museum in Memphis, TN just under the balcony where Martin Luther King, Jr. was killed in 1968
- Eternal flame at the Tzitzernagaberd Memorial outside Yerevan, Armenia
- Eternal flame in Jacksonville, FL dedicated to fallen veterans
- Eternal flame in Lodi, CA dedicated to fallen veterans
- Eternal flame in Miami, FL dedicated to those who died trying to overthrow Castro's regime
- Eternal flame in Odessa, dedicated to the Unknown Seaman
- Eternal flame at the Peace and Justice Camp in Puerto Rico
- Eternal flame protesting violence against women Port Elgin, Ontario lit in 1989
- Centoaph flame in Japan, to be extinguished when the last nuclear weapon is destroyed [does detonation count?]
- Eternal flame in London, Ontario to be extinguished when a cure for diabetes is found
- Eternal flame in New Belgrade, Serbia commemorating end of NATO bombings lit on June 12, 2000, extinguished October 5, 2000.
- Eternal flame at ground zero, New York City
- Eternal flame in Honolulu, HI lit in 2001 in memorial to 9-11 victims
- Eternal flame in Shanksville, PA to honor those aboard flight 93 on 9-11
timeline
| Oct 1997 |
French police arrest an Australian man for using the eternal flame at the Arc de Triomphe in Paris to cook an egg. |
| 2 Jul 1998 |
The eternal flame at the Arc de Triomphe in Paris, which has burned continuously since 1921 to commemorate the dead of World War I, is extinguished by an intoxicated soccer fan with his beer-enriched urine. Mexican national Rodrigo Rafael Ortega is arrested and charged with public drunkenness and offending the dead. |
| 1 Nov 2000 |
German Chancellor Gerhard Schroder accidentally extinguishes the Yad V'Shem eternal flame during a ceremony at the Holocaust memorial in Israel. |
| 21 Feb 2001 |
Local officials extinguish the eternal flame in Troy, Alabama. It had been lit less than a year before, on May 6, 2000. |
| 27 May 2001 |
An unnamed man attempts to extinguish the eternal flame at the Arc de Triomphe in Paris, by sitting on it. He is promptly arrested and sent to Bichat hospital to treat his burns. |
| Jan 2002 |
An unnamed French soldier attempts to urinate on the perpetual flame at the Arc de Triomphe in Paris. He is promptly arrested and sent to a mental clinic. |
| 18 Mar 2004 |
The Birmingham city council extinguishes their eternal flame dedicated to world peace (lit 31-Dec-1999) after refusing to pay the gas bill. |
Pornopolis |
Rotten |
Faces of Death |
Famous Nudes
|


Enter the player name and score:
sort by name
sort by score
Name:
{{player.name}}
Score:
{{player.score}}
Edit Score


---
layout: post
title: 'Lorenzo''s Music Podcast #3'
date: '2005-08-11T12:23:00.000-05:00'
author: Tom Ray
tags:
modified_time: '2005-08-24T20:18:50.596-05:00'
blogger_id: tag:blogger.com,1999:blog-11319466.post-112378139479639346
blogger_orig_url: http://www.lorenzosmusic.com/2005/08/lorenzos-music-podcast-3.html
---
This podcast was recorded in my basement so the quality of the parts before and after the song are a bit sketchy. But the song was done live in Mark's studio so that part still sounds good. And that's really all that matters, isn't it?
This time we feature new/old song called "Indian Summer"
You can subscribe to the show here:


Three days ago a friend, which is a regular user, asked me about my opinion on the “new button-less phone that was just released”, he was talking about the Sony Xperia Z. First I explained him that those kinds of phones (button-less) existed for a long time before the Sony one, then I gave him a long explanation why I think the Android way of getting rid of buttons was just wrong.
If you really want to get rid of the physical buttons you shouldn’t replace them with virtual ones, since I still loose part of my screen to that piece of the past, so don’t get rid of them, I prefer to have something more “natural” than just an abstraction of it.
To get rid of the physical buttons in the right way you should first of all replace their place with pixels (shocking!), so I can see more content. After that you replace the button actions to be triggered by something that won’t take more screen space, for example gestures.
A clear example where a company made the transition perfectly is RIM, they came from a OS that was completely driven by physical buttons (BBOS) and went to a fully gesture driven OS (PlayBook OS and BB10). Another great example of how to use gestures is the awesome Ubuntu Phone which in my opinion is one of the best implementations I ever seen.
So, if you want to replace the buttons you shouldn’t just virtualize them, but really replace them with something different.


Enter your personal details and start journey with us.
To keep you connected with us please login with your personal info.


abstract class Granite::Adapter::Base
- Granite::Adapter::Base
- Reference
- Object
Overview
The Base Adapter specifies the interface that will be used by the model objects to perform actions against a specific database. Each adapter needs to implement these methods.
Direct Known Subclasses
Defined in:
adapter/base.crConstant Summary
-
DATABASE_YML =
"config/database.yml"
Constructors
Class Method Summary
-
.env(url)
class level method so we can test it
Instance Method Summary
-
#clear(table_name)
remove all rows from a table and reset the counter on the id.
- #database : DB::Database
- #database=(database : DB::Database)
-
#delete(table_name, primary_name, value)
This will delete a row from the database.
-
#import(table_name : String, primary_name : String, auto : String, fields, model_array, **options)
This will insert an array of models as one insert statement
-
#insert(table_name, fields, params, lastval) : Int64
This will insert a row in the database and return the id generated.
- #log(query : String, params = [] of String) : Nil
- #open(&block)
-
#select(table_name, fields, clause = "", params = nil, &block)
select performs a query against a table.
- #settings(adapter : String)
-
#update(table_name, primary_name, fields, params)
This will update a row in the database.
Constructor Detail
Class Method Detail
Instance Method Detail
This will insert an array of models as one insert statement
This will insert a row in the database and return the id generated.
select performs a query against a table. The table_name and fields are configured using the sql_mapping directive in your model. The clause and params is the query and params that is passed in via .all() method
This will update a row in the database.


{# needs requirement_partial for node content #} {# needs document_type for requirement_partial #} {%- if traceability_index.has_children_requirements(requirement) %}


@(name: String)(contact: Html)
We were not able to fetch your details at this time, please try again later. If you are unable to access your details, please contact us.


Module provides access to a base class to create other entities.
These methods of this class that are supposed to be overridden: - validate - get_value
Import classes:
import copy
from typing import Any, Dict, List, Optional
import attr
from dialogy import constants as const
from dialogy.types.entity.utils import traverse_dict, validate_type
from dialogy.types.plugin import PluginFn
@attr.s
class BaseEntity:
Base Entity Type.
This class is meant for subclassing. Its intended purpose is to define a base for all entity types.
range = attr.ib(type=Dict[str, int])
type = attr.ib(type=str, validator=attr.validators.instance_of(str))
body = attr.ib(type=str, validator=attr.validators.instance_of(str))
dim = attr.ib(type=Optional[str], default=None)
parsers
gives the trail of all the functions that have changed this entity in the sequence of application.
parsers = attr.ib(
type=List[str],
default=attr.Factory(list),
validator=attr.validators.instance_of(list),
)
score = attr.ib(type=Optional[float], default=None)
slot_names = attr.ib(type=List[str], default=attr.Factory(list))
alternative_index
is the index of transcript within the ASR output: List[Utterances]
from which this entity was picked up. This may be None.
alternative_index = attr.ib(type=Optional[int], default=None)
latent
Duckling influenced attribute, tells if there is less evidence for an entity if latent is True.
latent = attr.ib(type=bool, default=False)
values = attr.ib(
type=List[Dict[str, Any]],
default=attr.Factory(list),
validator=attr.validators.instance_of(List),
)
value: Any = attr.ib(default=None)
entity_type: Optional[str] = attr.ib(default=None)
__properties_map = const.BASE_ENTITY_PROPS
@classmethod
def validate(cls, dict_: Dict[str, Any]) -> None:
Check attributes of instance match expected types.
Args:
dict_ (Dict[str, Any]): A Dict
where each key is an attribute of the instance and value is the expected type.
for prop, prop_type in cls.__properties_map:
validate_type(traverse_dict(dict_, prop), prop_type)
@classmethod
def from_dict(cls, dict_: Dict[str, Any]) -> "BaseEntity":
Create an instance of a given class cls
from a dict
that complies
with attributes of cls
through its keys and values.
Compliance is verified using the __validate
method. It is expected that each subclass
will implement their own flavor of __validate
to check their respective inputs.
Returns: BaseEntity: Instance of class
cls.validate(dict_)
return cls(**dict_)
def add_parser(self, postprocessor: PluginFn) -> None:
Update parsers with the postprocessor function name
This helps us identify the progression in which the postprocessing functions were applied to an entity. This helps in debugging and has no production utility
Args: postprocessor (PluginFn): Plugin function applied to an entity
self.parsers.append(postprocessor.__name__)
def get_value(self) -> Any:
Get value of an entity.
The structure of an entity conceals the value in different data structures. This is sugar for access.
Raises:
IndexError: If values
is not a list
.
KeyError: If each element in values
is not a dict
.
Returns: Any: Arbitrary return value, subclasses should override and return specific types.
try:
return self.values[0]["value"]
except IndexError as index_error:
raise IndexError(
'entity value should be in values[0]["value"]'
) from index_error
except KeyError as key_error:
raise KeyError(
'entity value should be in values[0]["value"]'
) from key_error
def copy(self) -> "BaseEntity":
Create a deep copy of the instance and return.
This is needed to prevent mutation of an original entity.
return copy.deepcopy(self)
def json(
self, skip: Optional[List[str]] = None, add: Optional[List[str]] = None
) -> Dict[str, Any]:
Convert the object to a dictionary.
Applies some expected filters to prevent information bloat.
Args: skip (Optional[List[str]], optional): Names of attributes that should not be included while converting to a dict. Defaults to None.
add (Optional[List[str]], optional): Names of attributes that should be included while converting to a dict.
Defaults to None.
Returns: Dict[str, Any]: Dictionary representation of the object
skip_ = skip or const.SKIP_ENTITY_ATTRS
if add and isinstance(add, list):
skip_ = [name for name in const.SKIP_ENTITY_ATTRS if name not in add]
return attr.asdict(self, filter=lambda attr, _: attr.name not in skip_)
Set values and value attribute.
Args: value (Any): The parsed value of an entity token.
Returns: None
def set_value(self, value: Any = None) -> None:
if value is None and isinstance(self.values, list) and len(self.values) > 0:
self.value = self.values[0][const.VALUE]
else:
self.values = [{const.VALUE: value}]
self.value = value
def entity_synthesis(entity: BaseEntity, property_: str, value: Any) -> BaseEntity:
Update a property=property_
of a BaseEntity, with a given value=value
.
Args: entity (BaseEntity): The BaseEntity instance to update. property_ (str): The attribute of a given entity that should be updated. value (Any): The value that should updated.
Raises:
TypeError: If entity
is not a BaseEntity.
Returns: BaseEntity: modified instance of BaseEntity.
if not isinstance(entity, BaseEntity):
raise TypeError(f"{entity} has type {type(entity)} expected BaseEntity")
synthetic_entity = entity.copy()
setattr(synthetic_entity, property_, value)
return synthetic_entity


BeyondCloudOps
Menu
Home
About
Posts
Contact
How to launch a website with Github Pages and Google Domains
Posted by
on April 09, 2019 ·
3 mins read


Undoer test page
Press "Push" to generate a new programatic undo event.
Use your browser's undo behavior (Ctrl/Cmd-Z) to undo or redo (Ctrl/Cmd-Shift-Z).
Type into the text input to intersperse 'traditional' events with programatic events.
Push


This is a free multi-step form made with Bootstrap. Download it on AZMIND, customize and use it as you like!
Please complete the form below to get instant access to our application and all its features:
Radio Buttons 1:
Radio Buttons 2:
Checkboxes 1:
Checkboxes 2:
Select 1:
Select 2:


|
BitShares-Core
6.1.0
BitShares blockchain implementation and command-line interface software
|
Public Types | |
| typedef void | result_type |
Public Attributes | |
| const database & | db |
| const fc::time_point_sec | block_time |
| const fc::time_point_sec | next_maintenance_time |
Definition at line 59 of file proposal_evaluator.cpp.
Definition at line 61 of file proposal_evaluator.cpp.
|
inline |
Definition at line 66 of file proposal_evaluator.cpp.
|
inline |
Definition at line 70 of file proposal_evaluator.cpp.
|
inline |
Definition at line 72 of file proposal_evaluator.cpp.
|
inline |
Definition at line 98 of file proposal_evaluator.cpp.
|
inline |
Definition at line 120 of file proposal_evaluator.cpp.
|
inline |
Definition at line 128 of file proposal_evaluator.cpp.
|
inline |
Definition at line 132 of file proposal_evaluator.cpp.
|
inline |
Definition at line 138 of file proposal_evaluator.cpp.
|
inline |
Definition at line 209 of file proposal_evaluator.cpp.
|
inline |
Definition at line 222 of file proposal_evaluator.cpp.
|
inline |
Definition at line 225 of file proposal_evaluator.cpp.
|
inline |
Definition at line 228 of file proposal_evaluator.cpp.
|
inline |
Definition at line 231 of file proposal_evaluator.cpp.
|
inline |
Definition at line 234 of file proposal_evaluator.cpp.
|
inline |
Definition at line 237 of file proposal_evaluator.cpp.
|
inline |
Definition at line 240 of file proposal_evaluator.cpp.
|
inline |
Definition at line 243 of file proposal_evaluator.cpp.
|
inline |
Definition at line 246 of file proposal_evaluator.cpp.
|
inline |
Definition at line 249 of file proposal_evaluator.cpp.
|
inline |
Definition at line 252 of file proposal_evaluator.cpp.
|
inline |
Definition at line 255 of file proposal_evaluator.cpp.
|
inline |
Definition at line 258 of file proposal_evaluator.cpp.
|
inline |
Definition at line 261 of file proposal_evaluator.cpp.
|
inline |
Definition at line 264 of file proposal_evaluator.cpp.
|
inline |
Definition at line 267 of file proposal_evaluator.cpp.
|
inline |
Definition at line 270 of file proposal_evaluator.cpp.
|
inline |
Definition at line 273 of file proposal_evaluator.cpp.
|
inline |
Definition at line 276 of file proposal_evaluator.cpp.
|
inline |
Definition at line 279 of file proposal_evaluator.cpp.
|
inline |
Definition at line 282 of file proposal_evaluator.cpp.
|
inline |
Definition at line 285 of file proposal_evaluator.cpp.
|
inline |
Definition at line 291 of file proposal_evaluator.cpp.
| const fc::time_point_sec graphene::chain::proposal_operation_hardfork_visitor::block_time |
Definition at line 63 of file proposal_evaluator.cpp.
| const database& graphene::chain::proposal_operation_hardfork_visitor::db |
Definition at line 62 of file proposal_evaluator.cpp.
| const fc::time_point_sec graphene::chain::proposal_operation_hardfork_visitor::next_maintenance_time |
Definition at line 64 of file proposal_evaluator.cpp.


## SNON Templates
SNON templates are collections of SNON definitions that are packaged up for distribution to SNON systems. Once loaded into an SNON system, instances of devices described by the template can be instantiated.
For example, a simple device with two sensors, temperature and humidity, could have an SNON template as shown below in Example 1.1:
Example 1.1:
[
{
"messageID": "urn:uuid:1f60d164-dc60-4cd0-a152-e192072adfb9",
"messageTime": "2018-04-18T13:43:19.983Z",
"message": {
"entityType": { "*": "Temperature" },
"measureUnit": "°C",
"measureType": "numeric",
"measureAcquire": "sample",
"measureDisplayUnit": { "*": "Celsius" }
}
},
{
"messageID": "urn:uuid:eb459e51-cb34-44a4-98e9-d83575ce8e2e",
"messageTime": "2018-04-18T13:43:19.983Z",
"message": {
"entityType": { "*": "Humidity" },
"measureUnit": "%",
"measureType": "numeric",
"measureAcquire": "sample",
"measureDisplayLow": "0",
"measureDisplayHigh": "100",
"measureDisplayUnit": { "*": "Percent RH" }
}
},
{
"messageID": "urn:uuid:2bf4c131-ee7b-4b4f-ba09-0ccdc5bff3a7",
"messageTime": "2018-04-18T13:43:19.983Z",
"message": {
"entityID": "urn:uuid:8f3011df-3f36-47b1-9a1d-366be5404197",
"entityClass": "device-template",
"entityName": { "*": "ACME Temperature Sensor" },
"extensions": {
"tcpip": {
"ipprot" : "modbus",
"ipaddr" : "<IP_ADDRESS>",
"ipmask" : "<IP_ADDRESS>",
"ipgw" : "<IP_ADDRESS>",
"ipport" : "6000"
}
}
}
},
{
"messageID": "urn:uuid:72ada238-7a94-4c20-940f-6e41da629e98",
"messageTime": "2018-04-18T13:43:19.983Z",
"message": {
"precedentID": "urn:uuid:1f60d164-dc60-4cd0-a152-e192072adfb9",
"entityID": "urn:uuid:254dee83-813b-4ff2-870f-b9d608d7bb87",
"entityClass": "sensor-template",
"entityName": { "*": "Temperature" },
"entityRelations": { "child_of": [ "urn:uuid:8f3011df-3f36-47b1-9a1d-366be5404197" ] },
"extensions": {
"modbus": {
"unitID" : "1",
"address" : "30001",
"format" : "FIX2"
}
}
}
},
{
"messageID": "urn:uuid:e590e99c-c0b5-490d-a82a-5a01dd6d8977",
"messageTime": "2018-04-18T13:43:19.983Z",
"message": {
"precedentID": "urn:uuid:eec14169-6887-479f-99d1-105207a1ca15",
"entityID": "urn:uuid:3e93d878-aeec-4be4-8e50-e8e6f261110d",
"entityClass": "sensor-template",
"entityName": { "*": "Humidity" },
"entityRelations": { "child_of": [ "urn:uuid:8f3011df-3f36-47b1-9a1d-366be5404197" ] },
"extensions": {
"modbus": {
"unitID" : "1",
"address" : "30002",
"format" : "FIX1"
}
}
}
}
]
In this example, the first two SNON messages define the measurement types used by the template, the third SNON message defines the device, and the forth and fifth SNON messages define two sensors that are part of the device.
The relationship between the parts of the template is shown below in Figure 1.1:
![SNON Template](images/snon_template.png)
Figure 1 - SNON Template Structure
## Instantiating SNON Templates
To instantiate an instance of the device described by the instance, the following process is followed:
1. New device SNON fragments are created for each corresponding device-template fragment
2. New sensor SNON fragments are created for each corresponding sensor-template fragment
3. New IDs are allocated for each messageID and entityID
4. precedentID fields are added or updated to point to the corresponding template fragment entityID
5. entityRelations fields are updated to point to the newly allocated IDs
6. Inherited fields are removed
7. Instantiation-specific fields are added
Example 1.2 shows an example of an instantiated device, named "My Temperature Sensor":
Example 1.2:
[
{
"messageID": "urn:uuid:b69326ff-cb88-4de5-8e61-a383966fc279",
"messageTime": "2018-04-20T13:43:19.983Z",
"message": {
"precedentID": "urn:uuid:8f3011df-3f36-47b1-9a1d-366be5404197",
"entityID": "urn:uuid:362df750-32e0-4e5e-9481-256eae61af28",
"entityClass": "device",
"entityName": { "*": "My Temperature Sensor" },
"extensions": {
"tcpip": {
"ipprot" : "modbus",
"ipaddr" : "<IP_ADDRESS>",
"ipmask" : "<IP_ADDRESS>",
"ipgw" : "<IP_ADDRESS>",
"ipport" : "6000"
}
}
}
},
{
"messageID": "urn:uuid:c1a21675-abf0-49b1-a5b7-11cdfc629a50",
"messageTime": "2018-04-20T13:43:19.983Z",
"message": {
"precedentID": "urn:uuid:254dee83-813b-4ff2-870f-b9d608d7bb87",
"entityID": "urn:uuid:59db5624-e54f-43ad-91f4-b95ae2dea2c5",
"entityClass": "sensor",
"entityRelations": { "child_of": [ "urn:uuid:362df750-32e0-4e5e-9481-256eae61af28" ] }
}
},
{
"messageID": "urn:uuid:e7af84e8-b3cf-4be3-be5a-666f959103df",
"messageTime": "2018-04-20T13:43:19.983Z",
"message": {
"precedentID": "urn:uuid:3e93d878-aeec-4be4-8e50-e8e6f261110d",
"entityID": "urn:uuid:f1917e29-ea3f-4aab-b7d4-a1645d69ab8f",
"entityClass": "sensor",
"entityRelations": { "child_of": [ "urn:uuid:362df750-32e0-4e5e-9481-256eae61af28" ] }
}
}
]
Inheritance relationships between instantiated devices and template devices are shown below in Figure 1.2:
![SNON Template Inheritance](images/snon_template_inherit.png)
Figure 1.2 - SNON Template Inheritance
SNON templates can be updated over time, with both the original and updated SNON messages typically being retained. Updating the template does not update instantiated devices and sensors, since references are via precedentID (to specific messageIDs). This means that updating existing instantiated devices to use the new template requires each instantiated device and sensor to be explicitly updated with new precedentIDs.


FAQ
How to migrate from one server to another?
For example you have to move your current admin container to another server. Besides of pulling and installer
docker image from Dockerhub you need to migrate mongodb data (in case you want to save it). By default mongo
stores it's data in /var/lib/just/mongodb
folder on your server. So you just
need to stop an admin container on the new server, move mentioned folder to the new server and start the
container.