Setting up a sharded RethinkDB cluster on Ubuntu and Debian, NoSQL
Set up a sharded RethinkDB Cluster - Ubuntu, Debian
Difficulty: 3
Time: 30 minutes
RethinkDB belongs to NoSQL database. It is the first open-source, scalable JSON database built from ground up for the real-time web applications. It is designed specifically to push data to applications in real-time. This dramatically reduces the time and effort necessary to build scalable real-time apps. In this article, we will assist you to build a RethinkDB cluster, import database on it and make it secure.
Prerequisites
In this tutorial, we will need two server running Ubuntu 14.04 or Debian 7, named rethinkdb1 and rethinkdb2. You should setup a sudo user for each RethinkDB server as working with a sudo user is a good security practice.
Setup a RethinkDB Node
RethinkDB cluster is a type of peer-to-peer network. Primary step in building a RethinkDB cluster is to install RethinkDB on every server included in this cluster.
- On each server, add the RethinkDB key and repository to apt-get.
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt
$DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add –
- Update and install RethinkDB.
sudo apt-get update
sudo apt-get install rethinkdb
Now RethinkDB will be installed in the server.
- Make the necessary configuration to make it run on startup.
sudo cp /etc/rethinkdb/default.conf.sample
/etc/rethinkdb/instances.d/cluster_instance.conf
sudo vi /etc/rethinkdb/instances.d/cluster_instance.conf
- First you need to change the server name as follows:
Search for:
server-name=server
Change it to:
Server-name=rethinkdb1
- Next important change is setting up the bind address. By default it is accessible only on localhost (<IP_ADDRESS>). You need to change this so that it listens on all network interfaces:
Search for:
bind=<IP_ADDRESS>
Change it to:
Bind=all
- Save the configuration changes made and then start RethinkDB with new build configuration.
sudo service rethinkdb start
sudo netstat -tulnp | grep rethindb
tcp6 0 0 :::28016 :::* LISTEN 2181/rethinkdb
tcp6 0 0 :::8080 :::* LISTEN 2181/rethinkdb
tcp6 0 0 :::29015 :::* LISTEN 2181/rethinkdb
Secure the RethinkDB Cluster
In the configuration step, we have made RethinkDB to listen on all network interfaces (bind=all). This will make RethinkDB exposed to outside network and is a security threat. Therefore, in this section we will focus on making RethinkDB accessible only from authorized computers.
From the above given netstat
command result, you can see 3 different ports on which RethinkDB listens. Port 8080 is used for Web Management Console, 28015 is the driver port and 29015 is the cluster port.
We will secure cluster port through firewall. We will use SSH Tunnels to securely access the web management console and the driver port.
- First step is to block all outside connections. Perform below steps on all RethinkDB servers.
The Web Management Console
sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j DROP
sudo iptables -I INPUT -i eth0 -s <IP_ADDRESS> -p tcp --dport 8080 -j ACCEPT
The Driver Port
sudo iptables -A INPUT -i eth0 -p tcp --dport 28015 -j DROP
sudo iptables -I INPUT -i eth0 -s <IP_ADDRESS> -p tcp --dport 28015 -j ACCEPT
The Cluster Port
sudo iptables -A INPUT -i eth0 -p tcp --dport 29015 -j DROP
sudo iptables -I INPUT -i eth0 -s <IP_ADDRESS> -p tcp --dport 29015 -j ACCEPT
- Install "iptables-persistent" to save our rules.
sudo apt-get install iptables-persistent
<Screnshot: 18528-iptables_save>
You will see a prompt. There you need to select (yes) to save ipv4 and ipv6 rules.
Set up a Management User
- Setup the SSH tunnels to access RethinkDB's web management console and the driver interface securely. Then create a management user for SSH tunnel in rethinkdb1
sudo adduser sshuser
- Set up the authorized keys file for a new user.
sudo mkdir /home/sshuser/.ssh
sudo touch /home/sshuser/.ssh/authorized_keys
- Next step is to import public key from a local computer, from where you will be accessing RethinkDB web management console. You can either copy the public key directly from your computer or you can use
ssh-copy-id
command to perform the same.
- Copy the user public key and add it in
authorized_keys
sudo vi /home/sshuser/.ssh/authorized_keys
- Paste your user public key to this file. Once done, please repeat all of the above steps for creating other cluster nodes.
Import or create a database
If you already have a database on this server or in another server, then you need to import those databases into your cluster. If there is no database, then RethinkDB will create an empty database by default.
- You need to copy the database that you want to import on rethinkdb1, if not already present. For that, first you need to find the path of your current RethinkDB database. If you used the
rethinkdb
command to start your old database, then you will have a directory path rethinkdb_data.
Use scp
command to copy it to rethinkdb1
sudo scp -rpC From Server User@From Server IP:/RethinkDB Data Folder/*
/var/lib/rethinkdb/cluster_instance/data
- Then restart RethinkDB.
sudo service rethinkdb restart
- If you have an existing RethinkDB database on rethinkdb1, then first open the configuration file on rethinkdb1
sudo vi /etc/rethinkdb/instances.d/cluster_instance.conf
- Then, find the path of the RethinkDB database to import. If you used the
rethinkdb
command to start your old database, then you will have a directory rethinkdb_data
. Insert that path into the configuration file.
directory=/home/user/rethink/rethinkdb_data/
- Save the changes and then restart RethinkDB.
sudo service rethinkdb restart
Create a cluster
- To create a cluster, first allow all cluster machines to be accessed through each other’s firewall. Now on rethinkdb1 server, we will allow all other servers to connect to cluster port through firewall.
sudo iptables -I INPUT -i eth0 -s other_server_ip_address -p tcp --dport 29015 -j ACCEPT
- Repeat the same command for any other nodes you want to add. Replace
other_server_ip_address
with respective server IP addresses.
- Now save the firewall changes.
sudo sh -c "iptables-save > /etc/iptables/rules.v4"
- Repeat these steps for your other servers. Once ports are opened and servers can communicate to one another, you can connect other server to create a cluster. For that first access rethinkdb2 server and edit the following configuration file:
sudo vi /etc/rethinkdb/instances.d/cluster_instance.conf
- Here you need to join this server (rethinkdb2) to cluster. Find the
join
statement in file.
join=example.com:29015
Replace it with the following:
join=rethinkdb1_IP
- Save the configuration file and then restart RethinkDB.
sudo service rethinkdb restart
- Perform the same for other servers. In the first node, rethindb1 does not need a
join
statement as we are joining other server to rethinkdb1.
- After completing this step, you will have all servers joined to rethinkdb1 and at this point you have a fully functioning RethinkDB cluster.
Connect to the web management console
Management console can be used to give you an online platform to perform basic functions on RethinkDB.
- To enable security on web management console, use SSH tunnel to connect to RethinkDB web management console.
ssh -L 8080:localhost:8080 sshuser@rethinkdb1_IP
- Since we have already completed the SSH key transfer, you can directly execute the above command. If you find an error, like - address already in use, then change the port number and connect to rethinkdb1 with the same command
Eg: ssh -L 8081:localhost:8080 sshuser@rethinkdb1_IP
Connect to the cluster using Python driver
In this section we will be using an SSH Tunnel to establish a connection with the driver port. Since we already have secured the connection to the cluster nodes, no one from outside the network can access to cluster port.
Now we will create a SSH Tunnel from one of the servers (rethinkdb2), so that they can establish a secure connection to cluster port (29018).
- Perform following steps in rethinkdb2 to generate SSH key.
ssh-keygen -t rsa
- Copy public key (id_rsa.pub) to rethinkdb1 server (Cluster Node) and add in authorized_keys.
sudo vi /home/sshuser/.ssh/authorized_keys
- Use SSH tunneling to access driver port from the sever.
ssh -L 28015:localhost:28015 sshuser@cluster_node_ip -f -N
Note: If you get a bind: Address already in use error, you can change the port.
Eg: ssh -L 28016:localhost:28015 sshuser@cluster_node_ip -f –N
Install the Python Driver
- To install Python driver on the connecting server (rethinkdb2), install the Python virtual environment.
sudo apt-get install python-virtualenv
- Create a directory named rethink in user home directory.
mkdir rethink
cd rethink
- Now create the new virtual environment structure.
virtualenv venv
- Now activate the environment before starting Python.
source venv/bin/activate
- Install the RethinkDB module.
pip install rethinkdb
- Start Python from the connecting server.
Python
- Now connect to the cluster server database. Make sure you give the correct port, which you have used earlier to connect to SSH Tunnel.
import rethinkdb as r
r.connect("localhost", 28016).repl()
- Create a table test.
r.db("test").table_create("test").run()
- Insert data into the table test.
r.db("test").table("test").insert({"hello":"world"}).run()
r.db("test").table("test").insert({"This”:”Is”:”world”}).run()
Sharding
RethinkDB allows you to shard and replicate your cluster on a per-table basis. You can control the sharding settings through web management console.
When using the web management console, you can perform sharding simply by specify the number of shards you want and based on the data available, RethinkDB will determine the best split points to maintain balanced shards. To shard your data:
- Go to the table view (Tables → table name).
- Click on the Reconfigure button.
- Set the number of shards and replicas you want.
- Click on the Apply Configuration button.
In addition to the options in web management console, ReQL
commands for table configuration allow both scripting capability and replication, distributing replicas for individual tables across user-defined groups of servers using server tags. All these functionalities can be achieved through ReQL
command.
There are three primary commands for changing sharding and replication in ReQL:
table_create
: Specify initial values of shards and replicas.
reconfigure
: Change the values of shards and replicas.
rebalance
: Used to rebalance table shards.
Advance configuration
These include advanced configuration which cannot be performed through the web interface.
Server Tag
- All servers in a RethinkDB cluster may be given zero or more tags that can be used in table configurations. This is used to map replicas to servers specified by tags. We can set a tag through the below command:
rethinkdb --server-tag us --server-tag us_west
- If no tags are specified on startup, the server will be started with default tag (default). When servers are tagged, you can use the tags in the reconfigure command:
- If we want to assign three replicas of the user's table to us_1 and two to us_2, use the following command:
r.table('users').reconfigure(shards=2, replicas={'us_1':3,
'us_2':2}, primary_replica_tag='us_2').run(conn)
Write acknowledgements and durability
Write acknowledgements and write durability are two other settings which cannot be configured or managed through web management console or through reconfigure command. They can only be configured by editing table table_config
for each individual table.
The write acknowledgement setting for a table controls when the cluster acknowledges a write request as completed. There are two possible settings for the same:
majority:
The cluster sends the acknowledgement when the majority of replicas have acknowledged it. This is default.
single:
The cluster sends the acknowledgement when any replica has acknowledged it.
Below is an example showing the same:
r.db('rethinkdb').table('table_config').get(
'31c92680-f70c-4a4b-a49e-b238eb12c023').update(
{"write_acks": "single"}).run(conn)
The durability setting for a table controls when writes are committed. They include both hard and soft mode:
- In hard mode, writes are committed to disk before acknowledgements are sent
- In soft mode, writes are acknowledged immediately upon receipt. This is much faster.
Remove a Machine
Removing a server from the cluster needs to be performed carefully. When a document is divided over multiple servers, one server will always keep its primary index. If the server holding primary index of the document is taken offline, then the document will be lost. Therefore before removing a server, you need to migrate all its primary shards away from it.
Here we will migrate data off from the node rethinkdb2 to make rethinkdb1 as the sole node. So that we can remove rethindb2 node safely.
- Enter into the RethinkDB admin shell on rethinkdb1
rethinkdb admin
- List the shards (groups of documents) that rethinkdb2 holds.
ls rethinkdb2
- To move the shards from one server (rethinkdb2) to another(rethinkdb1)
pin shard TABLE SHARD-RANGE --master MACHINE-NAME
Eg : pin shard food.foodshards -inf-+inf --master rethinkdb1
- Next exit from the admin shell.
Exit
- Now you can safely stop RethinkDB on server (rethinkdb2). You can execute the below command in rethinkdb2.
sudo service rethinkdb stop
Once you remove this server (rethinkdb2), then you will get a warning message when accessing RethinkDB web management console. On the right side of the warning message, you will see a permanent remove button, you can use this button to remove this server (rethinkdb2) from the cluster.
In this way you can safely remove the server from RethinkDB cluster.
Conclusion
In this article, we discussed the steps involved in setting up a sharded RethinkDB cluster on Ubuntu and Debian servers.


Jeremy Corbyn: Trump-Farage-Johnson pact would threaten rights in UK - video
by ReutersJeremy Corbyn has said voters in the UK are at risk from a Trump-Farage-Johnson alliance that would threaten the NHS, workers' rights and safe food. The Labour leader was responding to Nigel Farage's announcement that his Brexit party would not stand in the 317 seats won by the Tories in 2017


Hi all, just joined the forum and looking for some information.
I've been looking through some of the threads on diverting excess power to immersion heaters and noticed some people are using an SSR controlled by an Arduino.
I'm wondering if these are the basic, cheaper SSRs or the more expensive proportional ones ?
Thanks in advance for any replies.
Scott
Re: Pv power diversion to immersion with SSR ?
The two documented methods of diverting surplus power (Mk2 and PLL) operate by cycling a resistive dump-load between its on and off states as required to balance consumption with generation. By this means, the energy state of the premises remains almost constant, and no charge or penalty is applied by the meter. These systems are reactive, with a rapid response time of around 30 ms.
Some commercially available alternatives offer proportional control which is predictive in nature. This method of control is more complex and can lead to difficulties when conditions change, such as when there is a sudden increase in the baseload.
My first attempts to divert surplus power used predictive logic to drive a proportional Carlo Gavazzi SSR . The perfomance was OK, but nothing like as good as the later "Mk2" version. A top quality "basic" Crydom SSR is less than half the cost of a proportional controller. The performance is more dependent on the sketch that is running on the associated processor than with the output stage.
Re: Pv power diversion to immersion with SSR ?
Thanks for the reply.
I already have an Arduino set up to monitor PV generation and household consumption so I'm half way there. Just need to decide how to send the excess PV power to the immersion without importing any power.
So it is possible to use either type of SSR to achieve proportional diversion ?
If so, are any other components required, apart from the Arduino ?
Re: Pv power diversion to immersion with SSR ?
Using any of my Mk2 PV Router sketches (see Summary Page for details), a 5V Arduino with the standard V and I sensors can divert all surplus energy using nothing more than a basic on/off SSR.
The "phase-angle control" version operates like a dimmer switch, so is effectively providing proportional diversion. This method of control has EMI implications.
Re: Pv power diversion to immersion with SSR ?
Thanks again.
I'm very new to Arduino coding and your sketches are way beyond my level but I'm hoping to try and incorporate some of your code into my own setup to get this working, albeit on a more basic level, before progressing to something more sophisticated.
Could you possibly explain (in layman's terms) how an SSR is used to vary the AC power output.
Is this perhaps done using PWM output on the Arduino ?
Re: Pv power diversion to immersion with SSR ?
Hi Scott,
I have a cheap SSR purchased from eBay switched by the PLL sketch to power my immersion heater. It's been running fine for over a year now and when the sun is shining my water gets nice and hot.
These sketches have the capability to switch the relay based on the power consumption in a cycle, so a 3kW immersion heater can be switched fast enough that it doesn't consume the full 3kW. As Robin said, this is much like how a dimmer switch works for reducing the light output of a bulb.
Well that's my take on it, it may now be completely accurate, but it allows me to understand enough to avoid exporting all the electricity I generate. I can genuinely say my gas bill has also dropped, along with my electricity bill.
Hope that helped.
Allen
Re: Pv power diversion to immersion with SSR ?
Thanks for that Allen.
I'm new on this forum and still trying to get my head round it all, there's a lot to take in.
I have a power reducer fitted to our immersion which cuts the power down to 1.5kw which helps but I'd like to get a power diverter set up to make better use of our spare PV output.
So basically, you're using the Arduino to switch the SSR on and off rapidly ?
Do you have a link to the PLL sketch you're using ?
Re: Pv power diversion to immersion with SSR ?
All the details can be found at this link http://openenergymonitor.org/emon/pvdiversion/pll.
The reason I preferred this sketch over Robin's was purely because I use a DS18B20 temperature sensor to cut off the diversion once my cylinder reaches temperature. I do this because the sketch will use the number of cycles diverted to estimate how much power has been transferred, so if you don't turn the immersion off (and not just rely on it's thermal cutout), the sketch thinks it is diverting 3kW, when actually the immersion has shutdown.
I'm also toying with the idea of another CT clamp to measure the diverted power. But I like to monitor how my cylinder temperature changes (when the kids are showering for example!)
Re: Pv power diversion to immersion with SSR ?
This is also an interesting thread http://openenergymonitor.org/emon/node/1535
Re: Pv power diversion to immersion with SSR ?
Thanks again.
Much of it is way over my head but I have an idea for a basic diverter until I can get to grips with the more advanced stuff.
Re: Pv power diversion to immersion with SSR ?
If you want to develop your own diverter, then that's fine and you'll find quite a lot of information here. If you want a proven design that's known to work well, then one of Robin's Mk2 variants or MartinR's PLL is your best bet. You won't need your 'reducer', these designs attempt to exactly balance the average immersion load against the surplus PV so that nothing is exported, only failing when the controlled load cannot accept any more energy (for whatever reason). I take it you've read the article "Choosing an Energy Diverter".
Hopefully, your supplier's energy meter is compatible. Most are, but there are a few about that will only play nicely with a phase-controlled load.
Re: Pv power diversion to immersion with SSR ?
Could you possibly explain (in layman's terms) how an SSR is used to vary the AC power output.
Hello Scott,
Here's an analogy that may help visualize how Robin's diverter works, and the part the SSR plays.
Let's say you have a bucket with a 10mm hole in the bottom. The bucket is getting filled with water from a 10mm (ID) hose.
If you put stopper in the hole, without shutting off the hose, the bucket eventually overflows. If the hole remains open, the bucket eventually goes dry, or the water falls to a very low level. However, if you used your finger to cover the hole till the bucket was half-full, then repeatedly covered and uncovered the hole (at at rate dependent on the bucket fill rate) you could: keep the bucket from overflowing, keep it from running dry, and, maintain the water level in the bucket between an upper and a lower level.
The hose filling the bucket represents your PV system production. The hole in the bucket represents the excess that would otherwise escape to the grid. Keeping the water level in the bucket between the two levels, represents a balance between energy imported from, and energy exported to, the grid. The water level in the bucket rising and falling is analogous to what happens with Robin's diverter. The difference between the upper and lower "water levels," or more correctly, energy levels, represents what often gets referred to as the "sweet zone," which is the upper and lower limits of energy that can pass through your utility meter, without causing the meter to tally, i.e. charge you for, the energy.
That is, essentially, the principle behind Robin's diverter. It uses the concept of an "energy bucket" and your meter's "sweet zone" to do the same thing with your excess PV energy, i.e "burn" some of it with a DHW cylinder immersion heating element (or other load, if so desired) rapidly and repeatedly, so that sufficient energy is consumed to prevent export, but not so much as to cause import.
The diverter uses the SSR as a switch to connect and disconnect the load (immersion element) to the mains, rapidly and repeatedly, such that your excess PV energy is consumed heating your water, very little or none of it slips away to the grid, nor do you import any energy from the grid. That happens only when excess energy is produced. When your energy demand exceeds your PV system output, the diverter stops connecting the immersion element to the mains, i.e. the SSR isn't triggered, and you import the needed energy from the grid. When demand falls below your PV system's production, the diverter senses the change, and the diversion process resumes.
I've generalized things to a large degree, there's quite a bit more to the diverter's internal workings, and hopefully, I've not confused you further.
Regards,
Bill
Re: Pv power diversion to immersion with SSR ?
Cheers guys, really appreciate your help with this.
I've knocked up some code which will divert power at staged intervals, i.e, 50%, 75% and 100% depending on the amount of excess power available.
A bit crude, admittedly, and no where near as efficient as the more advanced setups here but it'll do till I build up enough knowledge to attempt one of the devices on this excellent site.
Scott
Re: Pv power diversion to immersion with SSR ?
If the load is activated on alternate mains cycles, it will consume approximately 50% of its normal rating. That will be fine for when precisely that amount of surplus power (SP) is available, but there will generally be some degree of mis-match.
If the SP is slightly more than half the rating of your load, some SP will leak away to the grid. If it is slightly less, there will be a net import of power. Because of the way that a reciprocating flow of energy is recorded by the meter, this mis-match could become expensive.
The Mk2 and PLL diverter systems that are described on this website do not suffer from this effect because the energy state of the premises is actively maintained at a constant level.
There is a detailed description of the workings on the Mk2 Router in the final section of the online description document.
Re: Pv power diversion to immersion with SSR ?
I've been reading a few of the threads on here and the mist is slowly starting to clear.
I'm thinking of going for one of the slightly more expensive proportional SSRs . Think that might be a better route considering my limited knowledge of electronics.
Must say, there's some fantastic work been done here by some talented folk !
Re: Pv power diversion to immersion with SSR ?
I'm slightly worried that on your own admission you have limited knowledge and yet you're shying away from a tried and tested solution (which is how I'd describe both MartinR's PLL and Robin's designs). Between us here, we've had enough experience to be able to solve easily pretty much any problem you might have with Robin's or Martin's; but if you head out on a limb you might come up against something we haven't seen before and it will be that much harder to get you going.
Re: Pv power diversion to immersion with SSR ?
I'll second that as a user of Robin's Mk 2 "product." It works, works well and the support is unbeatable, as Robin is the software developer for said product.
Re: Pv power diversion to immersion with SSR ?
I appreciate your concern and offer of support. I'll no doubt be calling on it a good deal before I'm finished.
My intention is to start off with a basic device similar to ones I've seen mentioned in other threads then upgrade to one of the devices you refer to once my knowledge and understanding of them improves.
Don't get me wrong, I can now see the advantages these more advanced solutions offer.
Re: Pv power diversion to immersion with SSR ?
...well you have been warned!
You seem to be taking the more difficult route, but hey, good luck.
Paul
Re: Pv power diversion to immersion with SSR ?
I have to agree with the comments above. I am no technical wizard, but following the designs already tried an tested on here, was able to produce a working diverter that has served me well for over a year. I myself went out on a bit of a limb because I used an SSR, when most of the designs talk about using a triac.
This lead to some problems, but the guys on here helped me out, and I'm really happy with my solution. I have no idea how a proportional SSR would work to solve this issue, digital sounds so much easier to me.
Re: Pv power diversion to immersion with SSR ?
Hi guys, if anyone can devise a better way of diverting surplus power reliably using standard hardware, I would be most interested to hear about it ...
Re: Pv power diversion to immersion with SSR ?
The concept of "surplus power", as I have written about on many occasions, is not strictly accurate in this application. With the diverter systems that are described here (Mk2 and PLL), action is taken when there is a surplus of energy. This is done by switching a dump-load on and off as necessary so that the energy state of the premises is kept at a near-constant level.
While the diverter is operating in this way, some power will always flowing at the supply point, either import or export. The meter continuously monitors the reciprocating flow of energy, as does the diverter, so the two systems remain in step. Crucially, by keeping the energy fluctuations within a certain range (the meter's sweet zone), penalty charges can be avoided.
Any system that does not measure continuously is likely to give incorrect results in the presence of reciprocating energy flows.
Re: Pv power diversion to immersion with SSR ?
Hi all,
I am also at the point where I am looking for solutions to increase my self consumption after my 3.12 kWp array was installed on my roof.
I read through all (actually I don't think I managed ALL) the threads related to the power diversion devices but must be honest; I didn't understand more than 50%...;-)
Nevertheless; I need to divert power to my geyser (that's how immersion heaters are called in South Africa) to increase my self consumption.
I have a emontx v3 monitoring the grid power and house power. An emonglcd is happily displaying the data. As far as I understood correctly I just have to add the output board from you, Robin, to the mix or use a SSR only and then I would be up and running using the correct sketch.
As mentioned further above I am in sunny South Africa, so ordering the item from UK is possible but it's not practical.
Therefore I rather would like to get the parts locally and would prefer the SSR route which is hooked up to the emontx.
Is my basic understanding correct and what SSR is to be used. I understand a Crydom D2425 would be sufficient. My immersion element is a 2kW at the moment (originally 4kW which I exchanged to 2kW after installation of the 3.12 kWp array). Is it advisable to increase the element to 3kW to match the max output of the array; I believe so....?!
Your comments are highly welcome, thank you!
Re: Pv power diversion to immersion with SSR ?
"I read through all (actually I don't think I managed ALL) the threads related to the power diversion devices but must be honest; I didn't understand more than 50%...;-)"
But did you read the introductory articles: Choosing an Energy Diverter?
One possible fly in the ointment is your supplier's meter. Read the Resources article about energy meters. It's possible that yours might have a very small "energy packet", and in that case burst mode won't deliver the savings that you expect. You'll need to do phase control.
You could revert to your 4 kW heater. As it is controlled, it will only draw the exact power necessary to balance the house consumption to match the PV output. But a 3 kW heater will draw less current hence you will have less problems with harmonics or dip. If your house consumption is such that you're not exporting or only exporting a little when the heater is on, it's probably not worth changing the heater for a 3 kW one. If you're exporting a lot, the 3 kW will get the water hot in less time, but it won't accept any more energy. It's for you to make that decision based on how much excess PV you have and for how long (both summer and winter), and your cost/benefit analysis.
Any SSR that can be driven by a little under 3.3 V and can handle the load should be fine. But make sure you get the right sort, i.e. one that recognises and switches on the zero crossing if you're going to be using burst mode, or one that doesn't if you're going to be using phase control.
But make sure you get one from a reputable supplier - we've had horror stories about cheap ones.
Depending on how much it takes to drive the SSR, you might find that your emonTx V3 needs a 5 V power supply, as the internal one wasn't designed with external loads in mind.
Re: Pv power diversion to immersion with SSR ?
Hi Robert,
thank you for all the input and information; that makes things quite a bit more transparent.
yes, I read the article but I realize only now that it answers quite a few of my questions.
I have one of the "disc type" meters (3phase but my Elec reshuffled the main db that all circuits are on one phase incl PV) which doesn't spin backwards. Here in South Africa we don't get anything for electricity fed back to the grid; that is why I want to increase my self consumption as much as possible without battery back up. Having said that I believe I shouldn't have any problems with the "burst mode" and too small packets?
What would be a reputable brand for a proper SSR?
Thanks!
Re: Pv power diversion to immersion with SSR ?
You should have no trouble with that meter, provided that it does go backwards a little way before it hits the ratchet (until they change it!), I think Robin has posted a video showing one of those see-sawing backwards and forwards as the burst-mode system operates.
I'd go to a reputable supplier for your SSR, rather than just look for a reputable brand - there are cheap forgeries of reputable makes around, and a reputable trade supplier will have a lot to lose if they get it wrong.
Re: Pv power diversion to immersion with SSR ?
ajscheid, I'm not sure which sketch you are currently using, but these ones all support diversion of surplus power in an emonTx V3 setting (info from my Summary Page):
Using an emonTx V3.2 as a Mk2 PV Router This describes using the emonTx V3.2 rather than an Arduino to supply the processing power. Posted, on 14/2/2105, at http://openenergymonitor.org/emon/node/10171.
Using an emonTx V3.4 as a Mk2 PV Router This describes using the emonTx V3.4 rather than an Arduino to supply the processing power. Posted, on 20/2/2105, at http://openenergymonitor.org/emon/node/10203.
Using an Emontx V3.4 as a MK2 PV Router with phase angle control This describes using the emonTx V3.4 rather than an Arduino to supply the processing power. Posted, on 09/07/2015, at http://openenergymonitor.org/emon/node/10865
As Robert has mentioned, the Crydom 2425A relay may not work reliably when driven from a 3.3V system. A transistor stage could perhaps be added to boost this control voltage to ensure reliable operation. Inverting the sense of the output signal may be helpful in this case (by changing the order of LOAD_OFF and LOAD_ON in the enum definition).
In some parts of South Africa, I understand that there are penalties for exporting, hence there is a financial benefit of consuming any surplus power on-site.
Re: Pv power diversion to immersion with SSR ?
Thanks Robin!
Yes, you are right; generally speaking the feed back of generated power is not yet regulated here. Some say feed back at this stage is illegal. I have a grid-tied system which goes down as soon as the grid goes down. That is why I received a COC for my system.
Presently I am sending quite a big amount of power back to the grid (5.6 kWh during the last 24 hrs) and don't get anything for it (I doubt that NERSA get going anytime soon) . As my disk-type meter is not turning backwards (which obviously would be illegal anyway) I want to keep as much power on the premises as possible.
I am currently using the standard sketch on a emonTx V3.2. I read through the respective post you posted above and decided, in combination with the comments of Robert further up, that your output board with my existing emontx V3.2 is actually the way to go. The only thing I am worried about is the kW limitation on CT4; according to the specs the CT4 input is limited to 4.5 kW max. which is used to monitor the grid supply in the mentioned sketch. But it clearly could be possible that the grid supply is higher during a day without sunshine where you have to override and the maid has to wash and gives a sh** and starts the tumble dryer at the same time. I have seen spikes as high as 6kW during the past 15 days since my PV system is installed.
Wouldn't that kill the input leaving the emontx obsolete for diverting the surplus power? Which in return would mean that your full router would be the better solution for me....
Does that somehow make sence?
Cheers,
Antonius
Re: Pv power diversion to immersion with SSR ?
Hi Antonius,
I'm not sure what you mean by "the standard sketch". Is it a discrete sketch which uses the emonLib library, or one of my "continuous" versions?
The emonTx V3 has low-valued burden resistors for CT1-CT3 which are intended for whole-house monitoring. I believe these are 22R. For CT4, a higher value of burden is fitted which allows greater sensitivity albeit over a reduced range. The range of this channel could be increased by simply adding an extra resistor in parallel with the one that's already on the board.
With each of my "Mk2 Router for emonTx V3" sketches, CT4 is used solely for balancing purposes. The range of this channel only needs to exceed the ratings of the PV system and the dump-load, whichever is the greater. If whole-house monitoring at the supply point is also needed, that should be done using one of the other CT channels with its appropriately sized burden.
Even with its default resistor, I would not expect the CT4 channel to suffer any damage as a result of being overloaded. Like a cartoon character, it will spring back into life when the sunshine returns.
A triac-based output stage could be driven directly from your 3.3V emonTx. With a low-current trigger, this should be possible even when powering the unit from an AC/AC adapter. If you would like one of my output boards, just send me a PM; or there's a contact email address on my Shop page.
Re: Pv power diversion to immersion with SSR ?
Hi Robin,
I am using the single phase discrete sketch for the emontx v3.2.
That all sounds very good and seems to be the way to go. I send you an email to the Shop address.
Cheers,
Antonius


title here
description here ... text more
click
title here
description here ... text more
click
title here
description here ... text more
click
title here
description here ... text more
click
title here
description here ... text more
click


The following is a list of compile dependencies for this project. These dependencies are required to compile and run the application:
| GroupId | ArtifactId | Version | Type | License |
|---|---|---|---|---|
| au.gov.amsa.risky | risky-util | 0.5.25 | jar | The Apache License, Version 2.0 |
| com.github.davidmoten | grumpy-core | 0.2.3 | jar | The Apache Software License, Version 2.0 |
| com.github.davidmoten | rxjava-extras | <IP_ADDRESS> | jar | The Apache Software License, Version 2.0 |
| com.github.davidmoten | rxjava-slf4j | 0.6.12 | jar | The Apache Software License, Version 2.0 |
| com.google.guava | guava | 19.0 | jar | The Apache Software License, Version 2.0 |
| commons-io | commons-io | 1.3.2 | jar | The Apache Software License, Version 2.0 |
| edu.ucar | netcdf | 4.3.23 | jar | (MIT-style) netCDF C library license |
| io.reactivex | rxjava | 1.3.7 | jar | The Apache Software License, Version 2.0 |
| joda-time | joda-time | 2.7 | jar | Apache 2 |
| org.slf4j | slf4j-log4j12 | 1.7.12 | jar | MIT License |
The following is a list of test dependencies for this project. These dependencies are only required to compile and run unit tests for the application:
| GroupId | ArtifactId | Version | Type | License |
|---|---|---|---|---|
| junit | junit | 4.12 | jar | Eclipse Public License 1.0 |
The following is a list of transitive dependencies for this project. Transitive dependencies are the dependencies of the project dependencies.
The following is a list of compile dependencies for this project. These dependencies are required to compile and run the application:
| GroupId | ArtifactId | Version | Type | License |
|---|---|---|---|---|
| c3p0 | c3p0 | <IP_ADDRESS> | jar | GNU LESSER GENERAL PUBLIC LICENSE |
| com.google.protobuf | protobuf-java | 2.5.0 | jar | New BSD license |
| com.sleepycat | je | 4.0.92 | jar | Sleepycat License |
| com.sun.jna | jna | 3.0.9 | jar | null |
| commons-codec | commons-codec | 1.2 | jar | - |
| commons-httpclient | commons-httpclient | 3.1 | jar | Apache License |
| edu.ucar | udunits | 4.3.23 | jar | (MIT-style) netCDF C library license |
| log4j | log4j | 1.2.17 | jar | The Apache Software License, Version 2.0 |
| net.jcip | jcip-annotations | 1.0 | jar | - |
| net.sf.ehcache | ehcache-core | 2.6.2 | jar | src/assemble/EHCACHE-CORE-LICENSE.txt |
| org.apache.commons | commons-math3 | 3.2 | jar | The Apache Software License, Version 2.0 |
| org.jdom | jdom2 | 2.0.4 | jar | Similar to Apache License but with the acknowledgment clause removed |
| org.quartz-scheduler | quartz | 2.1.1 | jar | Apache 2.0 |
| org.slf4j | slf4j-api | 1.7.5 | jar | MIT License |
The following is a list of runtime dependencies for this project. These dependencies are required to run the application:
| GroupId | ArtifactId | Version | Type | License |
|---|---|---|---|---|
| org.slf4j | jcl-over-slf4j | 1.7.5 | jar | MIT License |
The following is a list of test dependencies for this project. These dependencies are only required to compile and run unit tests for the application:
| GroupId | ArtifactId | Version | Type | License |
|---|---|---|---|---|
| org.hamcrest | hamcrest-core | 1.3 | jar | New BSD License |
Unamed: JNA
(MIT-style) netCDF C library license: NetCDF-Java Library, udunits
GNU LESSER GENERAL PUBLIC LICENSE: c3p0:JDBC DataSources/Resource Pools
The Apache License, Version 2.0: formats, risky-util
Apache 2.0: Quartz Enterprise Job Scheduler
Eclipse Public License 1.0: JUnit
MIT License: JCL 1.1.1 implemented over SLF4J, SLF4J API Module, SLF4J LOG4J-12 Binding
Apache License: HttpClient
New BSD License: Hamcrest Core
Apache 2: Joda-Time
Similar to Apache License but with the acknowledgment clause removed: JDOM
Unknown: "Java Concurrency in Practice" book annotations, Codec
New BSD license: Protocol Buffer Java API
Sleepycat License: Berkeley DB Java Edition
The Apache Software License, Version 2.0: Apache Log4j, Commons IO, Commons Math, Ehcache Core, Guava: Google Core Libraries for Java, grumpy-core, rxjava, rxjava-extras, rxjava-slf4j


I took my love and I took it down
Climbed a mountain and I turned around
And I saw my reflection in the snow covered hills
Till the landslide brought me down
Oh, mirror in the sky, what is love?
Can the child within my heart rise above?
And can I sail through the changing ocean tides
Can I handle the seasons of my life?
Oh oh I don't know, oh I don't know
Well, I've been afraid of changing
'Cause I've built my life around you
But time makes you bolder
Even children get older
And I'm getting older too
Well, I've been afraid of changing
'Cause I've built my life around you
But time makes you bolder
Even children get older
I'm getting older too
Oh I'm getting older too
Oh, take my love, take it down
Climb a mountain and turn around
And if… Full lyrics on Google Play


Mariah Carey Shares Adorable Photo Of Son Wearing Deadpool Mask When Meeting Ryan Reynolds
by Brent FurdykMariah Carey has been in full-on mom mode on Instagram, and on Sunday she shared an adorable photo of herself, twins Moroccan and and Monroe (a.k.a. Roc and Roe), and a pair of celebrity guest stars.
In the photo, the “Glitter” star and her kids are posing with Ryan Reynolds and wife Blake Lively, while Roc strikes a heroic pose while wearing a Deadpool mask.
“Rocky snuck up on an unsuspecting couple wearing a Deadpool mask. Will they ever recover? 😉💖,” she wrote in the caption.
This isn’t the only celebrity encounter that Roc and Roe have experienced in recent days. On Thursday, their mom posted a photo of the kids with “Stranger Things” star Millie Bobby Brown, describing it as the “best day of their 8 year old lives!”
In a 2016 interview with Clash, Carey revealed that her kids — whom she shares with ex Nick Cannon — are definitely not homebodies.
“But they love traveling. They love flying,” she explained. “If I keep them home for like five days, they’re like, ‘When are we going on an airplane?’ They really love it.”
She added: “They love doing all these things and seeing places — they love the Eiffel Tower. It’s amazing, you know what I mean? I just have the best time with them.”


At my work this summer I've had the privilege to work on a code base that was very well-designed. As a result, I feel I have substantially grown as a developer. One of the neatest parts of the project I've been working on is that there are these magical things called delegates that glue the code together. These magical entities are what I want to talk about here.
Before we begin however, I want to define something called a
functor
. For our purposes, a functor is any kind of callable object: a function, class method, or even a class
with the
__call__()
magic method defined.
Suppose you have a piece of software that looks like the following:
Delegates are what handle the flow of data from one component to the next. All we do with the implementation here is set up each individual component and then choose who is subscribed to what. Then all we do is pipe data in and watch it come out the other side.
To be sure, delegates have other use cases, but this is what I was exposed to, and it was nifty enough that I wanted to take a crack at my own implementation. It was simple enough that, not including the substantial amount time I spent on a trivial misunderstanding, I only spent an hour on the implementation, plus another for some polish.
Before I show you the implementation, I want to show you how it's used. Here's a simple example that calculates the squares of the first ten even numbers. Delegates are overkill for such a simple task, but I wanted something easy to understand. Here's a diagram of what exactly is happening:
The end result is that of applying the function \(\displaystyle f(n) = \left(2(n + 1)\right)^2\).
Here's how it might be implemented:
#!/usr/bin/python3
from modifiers import Multiplier, Exponentiator, Incrementer
from observer import Observer
def main():
# Modifiers that act on numbers.
incrementer = Incrementer(1)
doubler = Multiplier(2)
squarer = Exponentiator(2)
# An observer to view intermediate and/or final values in the delegate chain.
observer = Observer()
# Subscribe the doubler modifier to the output of the incrementer.
incrementer.subscribe(doubler)
# Subscribe the squarer modifier to the output of the doubler.
doubler.subscribe(squarer)
# Subscribe the observer to the output of the squarer.
squarer.subscribe(observer)
for i in range(10):
# Call the first modifier in the chain, and let the delegates handle the rest
incrementer(i)
# Unsubscribe functors.
incrementer.unsubscribe(doubler)
doubler.unsubscribe(squarer)
squarer.unsubscribe(observer)
if __name__ == '__main__':
main()
I've included an
Observer
object in the chain because we need some way to view the result of our calculations, which are as
follows:
~ $ ./main-simple.py
Observed value(s): 4
Observed value(s): 16
Observed value(s): 36
Observed value(s): 64
Observed value(s): 100
Observed value(s): 144
Observed value(s): 196
Observed value(s): 256
Observed value(s): 324
Observed value(s): 400
Now, as it stands, each of the modifier classes are implemented as callable objects. This is not necessary, I chose to do so for the convenience. We could do something like the following:
#!/usr/bin/python3
from delegate import Delegated
from modifiers import Exponentiator, Incrementer
from observer import Observer
class Doubler(Delegated):
"""A delegated class to double numbers"""
def __init__(self):
super().__init__()
def double(self, val):
"""A method to double the given value"""
self.delegate(2 * val)
def main():
incrementer = Incrementer(1)
# Equivalent to Multiplier(2)
doubler = Doubler()
squarer = Exponentiator(2)
observer = Observer()
incrementer.subscribe(doubler.double)
doubler.subscribe(squarer)
squarer.subscribe(observer)
for i in range(10):
# Call the first modifier in the chain, and let the delegates handle the rest
incrementer(i)
incrementer.unsubscribe(doubler.double)
doubler.unsubscribe(squarer)
squarer.unsubscribe(observer)
if __name__ == '__main__':
main()
Now for the implementation. I think we'll start with the simplest object: the
Observer
class.
Observer
inherits from
Delegated
, which provides a base constructor,
subscribe()
, and
unsubscribe()
. We call the base class constructor, and then we define the
__call__()
method.
__call__()
takes in arbitrary arguments, prints them, and the passes them on unchanged to the delegate.
from delegate import Delegated
class Observer(Delegated):
"""An Observer callable object to observe values in a Delegate chain."""
def __init__(self):
super().__init__()
def __call__(self, *things):
"""Observes given values and passes them along with no changes."""
print('Observed value(s):', *things)
self.delegate(*things)
The next thing to look at is the modifier classes:
from delegate import Delegated
class Multiplier(Delegated):
"""A Multiplier modifier to multiply numbers"""
def __init__(self, multiplier=2):
"""Construct a Multiplier object with an optional multiplier. Defaults to 2."""
super().__init__()
self.multiplier = multiplier
def __call__(self, num):
"""Multiplies a given number by a predetermined multiplier"""
self.delegate(num * self.multiplier)
class Incrementer(Delegated):
"""An Incrementer modifier to increment numbers"""
def __init__(self, increment_value=1):
"""Construct an Incrementer object with an optional increment value. Defaults to 1."""
super().__init__()
self.increment_value = increment_value
def __call__(self, num):
"""Increment num by a predetermined value"""
self.delegate(num + self.increment_value)
class Exponentiator(Delegated):
"""An Exponentiator modifier to exponentiate numbers"""
def __init__(self, power=2):
"""Construct an Exponentiator object with an optional power. Defaults to 2."""
super().__init__()
self.power = power
def __call__(self, num):
"""Exponentiates a given number by a predetermine value"""
self.delegate(num ** self.power)
These are fairly self explanatory: instead of passing on what they are given unchanged, they modify their input somehow before calling their delegates on the values.
Now for the implementation of the
Delegated
base class. A
Delegated
class has two methods:
subscribe()
and
unsubscribe()
to, appropriately, subscribe and unsubscribe from its output.
class Delegate(object):
"""A class to implement delegates"""
def __init__(self):
self.functors = list()
def subscribe(self, functor):
"""Subscribe a given functor to this delegate."""
# Verify that functor is callable. If not, don't subscribe.
if callable(functor):
self.functors.append(functor)
return self
def unsubscribe(self, functor):
"""Unsubscribe a given functor to this delegate."""
try:
self.functors.remove(functor)
# Functor wasn't subscribed.
except ValueError:
pass
return self
def __call__(self, *args):
"""Call each of the subscribed functors with the given values"""
for functor in self.functors:
functor(*args)
class Delegated(object):
"""A base class for delegated classes"""
def __init__(self):
self.delegate = Delegate()
def subscribe(self, functor):
"""Subscribes the given functor to the output of self"""
self.delegate.subscribe(functor)
def unsubscribe(self, functor):
"""Unsubscribes the given functor from the output of self"""
self.delegate.unsubscribe(functor)
The
Delegate
class is where the magic happens. What I've defined a
Delegate
to be is a list of functors, all of which will be called on the given value(s) when the delegate is
called. This way a
Delegated
class has
one
delegate, but an
arbitrary
number of subscribers.
I've shown how delegates can be used in a very simple manner, but please realize, the magic between the input and the output could be extremely complex. Perhaps each component in a piece of software is in fact complex enough to require subcomponents glued together with delegates.
One of the neat things about delegates is it allows you to insert an arbitrary component in the middle of a complex system with minimal wrangling.


#include <string_ops.h>
Split elements of source
based on sep
into a SparseTensor
.
Let N be the size of source (typically N will be the batch size). Split each element of source
based on sep
and return a SparseTensor
containing the split tokens. Empty tokens are ignored.
For example, N = 2, source[0] is 'hello world' and source[1] is 'a b c', then the output will be
st.indices = [0, 0; 0, 1; 1, 0; 1, 1; 1, 2] st.shape = [2, 3] st.values = ['hello', 'world', 'a', 'b', 'c']
If sep
is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings. For example, source of "1\<\>2\<\>\<\>3"
and sep of "\<\>"
returns ["1", "2", "", "3"]
. If sep
is None or an empty string, consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the startor end if the string has leading or trailing whitespace.
Note that the above mentioned behavior matches python's str.split.
Arguments:
1-D
string Tensor
, the strings to split.0-D
string Tensor
, the delimiter character.Optional attributes (see Attrs
):
int
. If maxsplit > 0
, limit of the split of the result.Returns:
Constructors and Destructors |
|
|---|---|
StringSplitV2(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input sep)
|
|
StringSplitV2(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input sep, const StringSplitV2::Attrs & attrs)
|
Public attributes |
|
|---|---|
indices
|
|
operation
|
|
shape
|
|
values
|
Public static functions |
|
|---|---|
Maxsplit(int64 x)
|
Structs |
|
|---|---|
|
tensorflow:: |
Optional attribute setters for StringSplitV2. |
::tensorflow::Output indices
Operation operation
::tensorflow::Output shape
::tensorflow::Output values
StringSplitV2( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input sep )
StringSplitV2( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input sep, const StringSplitV2::Attrs & attrs )
Attrs Maxsplit( int64 x )


This tutorial is an introduction to the EnsEMBL Compara API. Knowledge of the EnsEMBL Core API and of the concepts and conventions in the EnsEMBL Core API tutorial is assumed. Documentation about the Compara database schema is available at http://cvsweb.sanger.ac.uk/cgi-bin/cvsweb.cgi/ensembl-compara/docs/ (or in ensembl-compara/docs/docs/schema_doc.html from the EnsEMBL CVS repository), and while is not necessary for this tutorial, an understanding of the database tables may help as many of the adaptor modules are table-specific.
API installation and updating is the same as per the core API.
For using the auto-configuration feature, you will first need to supply the connection parameters to the Registry loader. For instance, if you want to connect to the the public EnsEMBL databases you can use the following command in your scripts:
use strict; use warnings; use Bio::EnsEMBL::Registry; Bio::EnsEMBL::Registry->load_registry_from_multiple_dbs( { -HOST => 'mysql.ebi.ac.uk', -PORT => 4157, -USER => 'anonymous' }, { -HOST => 'ensembldb.ensembl.org', -PORT => 5306, -USER => 'anonymous' } );
This will initialize the Registry, from which you will be able to create object-specific adaptors later. Alternatively, you can use a shorter version based on a URL:
use strict; use warnings; use Bio::EnsEMBL::Registry; Bio::EnsEMBL::Registry->load_registry_from_url('mysql://anonymous@mysql.ebi.ac.uk:4157/');
You will need to have a registry configuration file set up. By default, it takes the file defined by the ENSEMBL_REGISTRY environment variable or the file named .ensembl_init in your home directory if the former is not found. Additionally, you can use a specific file (see perldoc Bio::EnsEMBL::Registry or later in this document for some examples on how to use a different file). Please, refer to the EnsEMBL registry documentation for details about this option.
EnsEMBL Compara data, like core data, is stored in a MySQL relational database.
If you want to access a Compara database, you will need to connect to it.
This is done in exactly the same way as to connect to an EnsEMBL core database,
but using a Compara-specific DBAdaptor. One parameter you have to supply
in addition to the ones needed by the Registry is the -dbname
,
which by convention contains the release number of Ensembl and Ensembl Genomes:
use strict; use warnings; use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor; my $host = 'mysql.ebi.ac.uk'; my $user = 'anonymous'; my $port = 4157; my $dbname = 'ensembl_compara_bacteria_6_59'; my $comparadb= new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor( -host => $host, -port => $port, -user => $user, -dbname => $dbname, );
As of release 3 of Ensembl Genomes there are 6 compara databases available; one for each division of Ensembl Genomes and one which contains pan-taxonomic compara. If you use the registry to configure your available adaptors you can access each using the following names:
EnsEMBL Compara adaptors are used to fetch data from the database. Data are returned as EnsEMBL objects. For instance, the GenomeDBAdaptor returns Bio::EnsEMBL::Compara::GenomeDB objects.
Below is a non-exhaustive list of EnsEMBL Compara adaptors that are most often used:
Only some of these adaptors will be used for illustration as part of this tutorial through commented perl scripts code.
You can get the adaptors from the Registry with the get_adaptor command. You need to specify three arguments: the species name, the type of database and the type of object. Therefore, in order to get the GenomeDBAdaptor for the Compara database, you will need the following command:
my $genome_db_adaptor = Bio::EnsEMBL::Registry->get_adaptor( 'pan_homology', 'compara', 'GenomeDB');
Or an alternative way to get adaptors from a single DBAdaptor:
my $dba = Bio::EnsEMBL::Registry->get_DBAdaptor(-species => 'pan_homology', -group => 'compara'); my $genome_db_adaptor = $dba->get_GenomeDBAdaptor();
NB: As the EnsEMBL Compara DB is a multi-species database resource, a possible name is 'pan_homology'. The type of the database is 'compara'. Other resources are available; see earlier on for more information of the types available.
Refer to the EnsEMBL core tutorial for a good description of the coding conventions normally used in EnsEMBL.
We can divide the fetching methods of the ObjectAdaptors into two categories: the fetch_by
and fetch_all_by
. The former return one single object while the latter return a reference to an array of objects.
my $this_genome_db = $genome_db_adaptor->fetch_by_name_assembly("Homo sapiens", "GRCh37"); my $another_genome_db = $genome_db_adaptor->fetch_by_name_assembly("E_coli_K12", "EB1");
my $all_genome_dbs = $genome_db_adaptor->fetch_all(); foreach my $this_genome_db (@{$all_genome_dbs}) { print $this_genome_db->name, "\n"; }
The GenomeDB object is a representation of a species within the compara database. It is uniqely defined in the database by a genome's name and its assembly. In order to retrieve a GenomeDB you must use the GenomeDBAdaptor object which has multiple methods available for finding them.
use strict; use warnings; my $dba = Bio::EnsEMBL::Registry->get_DBAdaptor(-species => 'pan_homology', -group => 'compara'); my $gdba = $dba->get_GenomeDBAdaptor(); my $core_dba = get_core_dba_from_somewhere(); $gdba->fetch_by_name_assembly('e_coli_k12', 'EB1'); #Requires you to use the exact name found in compara $gdba->fetch_by_name_assembly('e_coli_k12'); #Gets the default assembly $gdba->fetch_by_registry_name('Escherichia coli K12'); #Allows you to use any synonym a species is found under in the registry $gdba->fetch_by_core_DBAdaptor($core_dba); #Use a core DBAdaptor $gdba->fetch_by_taxon_id(9606); #Fetch human by taxon
The best methods to use when retrieving this data are fetch_by_registry_name and fetch_by_core_DBAdaptor since both of these methods do not assume what the name is actually known as in compara. This is of great importance to bacterial comparas where the full name is too long to be used in compara and contains characters which are detrimental to the running of the pipeline (e.g. strain information). In these situations the API is configured to use a meta item from the core database called species.compara_name. The current algorithm is:
This promotes a level of separation between what compara uses to refer to a species and what the ensembl code base requires a species to be known as.
Also be aware that using a taxon identifier can sometimes result in incorrect lookups if the compara database has species which share a taxon identifier. This happens in Ensembl Bacteria's compara database but is normally a safe operation in most other comparas.
These act as experimental declarations for compara. If anything has been analysed using a compara pipeline there should be a Method Link Species Set declaring what the algorithm/analysis used was and which species (one or many) were invovled in the procedure. To this end there are normally three classes of species sets:
In order to find a declaration you must first know what the type of method link you are searching for & find the GenomeDBs you expect to be found in the species set. For example:
use strict; use warnings; my $dba = Bio::EnsEMBL::Registry->get_DBAdaptor(-species => 'pan_homology', -group => 'compara'); my $gdba = $dba->get_GenomeDBAdaptor(); my $mlssa = $dba->get_MethodLinkSpeciesSetAdaptor(); my $mlss = $mlssa->fetch_by_method_link_type_registry_aliases('ENSEMBL_ORTHOLOGUES', ['human', 'Escherichia coli K12']); #Or my $ss = [$gdba->fetch_by_registry_name('e_coli_k12'), $gdba->fetch_by_registry_name('human')]; $mlss = $mlssa->fetch_by_method_link_type_GenomeDBs('ENSEMBL_ORTHOLOGUES', $ss);
The Compara database contains a number of different types of whole genome alignments. A listing about what are these different types can be found in the ensembl-compara/docs/schema_doc.html document in method_link section.
GenomicAlignBlocks are the preferred way to store and fetch genomic alignments. A GenomicAlignBlock contains several GenomicAlign objects. Every GenomicAlign object corresponds to a piece of genomic sequence aligned with the other GenomicAlign in the same GenomicAlignBlock. A GenomicAlign object is always in relation with other GenomicAlign objects and this relation is defined through the GenomicAlignBlock object. Therefore the usual way to fetch genomic alignments is by fetching GenomicAlignBlock objects. We have to start by getting the corresponding adaptor:
# Getting the GenomicAlignBlock adaptor: my $genomic_align_block_adaptor = Bio::EnsEMBL::Registry->get_adaptor( 'bacteria', 'compara', 'GenomicAlignBlock');
In order to fetch the right alignments we need to specify a couple of data: the type of alignment and the piece of genomic sequence in which we are looking for alignments. The type of alignment is a more tricky now: you need to specify both the alignment method and the set of genomes. In order to simply this task, you could use the new Bio::EnsEMBL::Compara::MethodLinkSpeciesSet object. The best way to use them is by fetching them from the database:
# Getting the GenomeDB adaptor: my $genome_db_adaptor = Bio::EnsEMBL::Registry->get_adaptor( 'fungi', 'compara', 'GenomeDB'); # Fetching GenomeDB objects my $cer_genome_db = $genome_db_adaptor->fetch_by_name_assembly('Saccharomyces cerevisiae'); my $pom_genome_db = $genome_db_adaptor->fetch_by_name_assembly('Schizosaccharomyces pombe'); # Getting the MethodLinkSpeciesSet adaptor: my $method_link_species_set_adaptor = Bio::EnsEMBL::Registry->get_adaptor( 'fungi', 'compara', 'MethodLinkSpeciesSet'); # Fetching the MethodLinkSpeciesSet object corresponding to TRANSLATED_BLAT alignments between cerevisiae and pombe genomic sequences: my $cer_pom_blastz_net_mlss = $method_link_species_set_adaptor->fetch_by_method_link_type_GenomeDBs( "TRANSLATED_BLAT", [$cer_genome_db, $pom_genome_db] );
There are two ways to fetch GenomicAlignBlocks. One uses Bio::EnsEMBL::Slice objects while the second one is based on Bio::EnsEMBL::Compara::DnaFrag objects for specifying the piece of genomic sequence in which we are looking for alignments.
my $query_species = 'Schizosaccharomyces pombe'; my $seq_region = 'I'; my $seq_region_start = 45000; my $seq_region_end = 47000; # Getting the Slice adaptor: my $slice_adaptor = Bio::EnsEMBL::Registry->get_adaptor( $query_species, 'core', 'Slice'); # Fetching a Slice object: my $query_slice = $slice_adaptor->fetch_by_region( 'toplevel', $seq_region, $seq_region_start, $seq_region_end); # Fetching all the GenomicAlignBlock corresponding to this Slice: my $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_Slice( $cer_pom_blastz_net_mlss, $query_slice);
Here is an example script with all of this:
use strict; use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::Utils::Exception qw(throw); use Bio::SimpleAlign; use Bio::AlignIO; use Bio::LocatableSeq; use Getopt::Long; my $usage = qq{ perl DumpMultiAlign.pl Getting help: [--help] For the query slice: [--species species] Query species. Default is "Schizosaccharomyces pombe" [--coord_system coordinates_name] Query coordinate system. Default is "chromosome" --seq_region region_name Query region name, i.e. the chromosome name --seq_region_start start --seq_region_end end For the alignments: [--alignment_type method_link_name] The type of alignment. Default is "TRANSLATED_BLAT" [--set_of_species species1:species2:species3:...] The list of species used to get those alignments. Default is "Saccharomyces cerevisiae:Schizosaccharomyces pombe". The names should correspond to the name of the core database in the registry_configuration_file or any of its aliases Ouput: [--output_format clustalw|fasta|...] The type of output you want. "clustalw" is the default. [--output_file filename] The name of the output file. By default the output is the standard output }; my $species = "Schizosaccharomyces pombe"; my $coord_system = "chromosome"; my $seq_region = "I"; my $seq_region_start = 45000; my $seq_region_end = 47000; my $alignment_type = "TRANSLATED_BLAT"; my $set_of_species = "Saccharomyces cerevisiae:Schizosaccharomyces pombe"; my $output_file = undef; my $output_format = "clustalw"; my $help; GetOptions( "help" => \$help, "species=s" => \$species, "coord_system=s" => \$coord_system, "seq_region=s" => \$seq_region, "seq_region_start=i" => \$seq_region_start, "seq_region_end=i" => \$seq_region_end, "alignment_type=s" => \$alignment_type, "set_of_species=s" => \$set_of_species, "output_format=s" => \$output_format, "output_file=s" => \$output_file); # Print Help and exit if ($help) { print $usage; exit(0); } if ($output_file) { open(STDOUT, ">$output_file") or die("Cannot open $output_file"); } my $compara = 'fungi'; Bio::EnsEMBL::Registry->load_registry_from_db( -host => 'mysql.ebi.ac.uk', -port => 4157, -user => 'anonymous'); # Getting all the Bio::EnsEMBL::Compara::GenomeDB objects my $genome_dbs; my $genome_db_adaptor = Bio::EnsEMBL::Registry->get_adaptor( $compara, "compara", "GenomeDB"); throw("Cannot connect to Compara") if (!$genome_db_adaptor); foreach my $this_species (split(":", $set_of_species)) { my $this_meta_container_adaptor = Bio::EnsEMBL::Registry->get_adaptor( $this_species, 'core', 'MetaContainer'); throw("Registry configuration file has no data for connecting to <$this_species&") if (!$this_meta_container_adaptor); # Fetch Bio::EnsEMBL::Compara::GenomeDB object my $name = $genome_db_adaptor->get_species_name_from_core_MetaContainer($this_meta_container_adaptor); my $genome_db = $genome_db_adaptor->fetch_by_name_assembly($name); # Add Bio::EnsEMBL::Compara::GenomeDB object to the list push(@$genome_dbs, $genome_db); } # Getting Bio::EnsEMBL::Compara::MethodLinkSpeciesSet object my $method_link_species_set_adaptor = Bio::EnsEMBL::Registry->get_adaptor( $compara, "compara", "MethodLinkSpeciesSet"); my $method_link_species_set = $method_link_species_set_adaptor->fetch_by_method_link_type_GenomeDBs( $alignment_type, $genome_dbs); throw("The database do not contain any $alignment_type data for $set_of_species!") if (!$method_link_species_set); # Fetching the query Slice: my $slice_adaptor = Bio::EnsEMBL::Registry->get_adaptor($species, "core", "Slice"); throw("Registry configuration file has no data for connecting to <$species>") if (!$slice_adaptor); my $query_slice = $slice_adaptor->fetch_by_region('toplevel', $seq_region, $seq_region_start, $seq_region_end); throw("No Slice can be created with coordinates $seq_region:$seq_region_start-". "$seq_region_end") if (!$query_slice); # Fetching all the GenomicAlignBlock corresponding to this Slice: my $genomic_align_block_adaptor = Bio::EnsEMBL::Registry->get_adaptor( $compara, "compara", "GenomicAlignBlock" ); my $genomic_align_blocks = $genomic_align_block_adaptor->fetch_all_by_MethodLinkSpeciesSet_Slice( $method_link_species_set, $query_slice); my $all_aligns; # Get a Bio::SimpleAlign object from every GenomicAlignBlock foreach my $this_genomic_align_block (@$genomic_align_blocks) { my $simple_align = $this_genomic_align_block->get_SimpleAlign; push(@$all_aligns, $simple_align); } # print all the genomic alignments using a Bio::AlignIO object my $alignIO = Bio::AlignIO->newFh( -interleaved => 0, -fh => \*STDOUT, -format => $output_format, -idlength => 10 ); foreach my $this_align (@$all_aligns) { print $alignIO $this_align; } exit;
All the homologies refer to Members. Homology objects store orthologous and paralogous relationships between Members.
A Member represent either a gene or a protein. Most of them are defined in the corresponding EnsEMBL core database. For instance, the sequence for the human gene ENSG00000004059 is stored in the human core database.
The fetch_by_source_stable_id method of the MemberAdaptor takes two arguments. The first one is the source of the Member and can be:
The second argument is the identifier for the Member. Here is a simple example:
# get the MemberAdaptor my $member_adaptor = Bio::EnsEMBL::Registry->get_adaptor( "pan_homology","compara","Member"); # fetch a Member my $member = $member_adaptor->fetch_by_source_stable_id( "ENSEMBLGENE","ENSG00000004059"); # print out some information about the Member print $member->chr_name, " ( ", $member->chr_start, " - ", $member->chr_end, " ): ", $member->description, "\n";
The Member object has several attributes:
source_name
and stable_id
define this Member.chr_name
, chr_start
, chr_end
, chr_strand
locate this Member on the genome but
are only available for ENSEMBLGENE and ENSEMBLPEP.taxon_id
corresponds to the NCBI taxonomy identifier (see
http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/
for more details).taxon
returns a Bio::EnsEMBL::Compara::NCBITaxon object.
From this object you can get additional information about the species.my $taxon = $member->taxon; print "common_name ", $taxon->common_name,"\n"; print "genus ", $taxon->genus,"\n"; print "species ", $taxon->species,"\n"; print "binomial ", $taxon->binomial,"\n"; print "classification ", $taxon->classification,"\n";
In our example the species is human, so the output will look like this:
common_name: human genus: Homo species: sapiens binomial: Homo sapiens classification: sapiens Homo Hominidae Catarrhini Haplorrhini Primates Euarchontoglires Eutheria Mammalia Euteleostomi Vertebrata Craniata Chordata Metazoa Eukaryota
A Homology object represents either an orthologous or paralogous relationships between two or more Members.
Typically you want to get homologies for a given gene. The HomologyAdaptor has a fetching method called fetch_all_by_Member(). You will need the Member object for your query gene, therefore you will fetch the Member first like in this example:
# first you have to get a Member object. In case of homology, it is a gene my $member_adaptor = Bio::EnsEMBL::Registry->get_adaptor("pan_homology", "compara", "Member"); my $member = $member_adaptor->fetch_by_source_stable_id("ENSEMBLGENE","ENSG00000004059"); # then you get the homologies where the member is involved my $homology_adaptor = Bio::EnsEMBL::Registry->get_adaptor("pan_homology", "compara", "Homology"); my $homologies = $homology_adaptor->fetch_all_by_Member($member); # That will return a reference to an array with all homologies (orthologues in # other species and paralogues in the same one) # Then for each homology, you can get all the Members implicated foreach my $homology (@{$homologies}) { # You will find different kind of description # UBRH, MBRH, RHS, YoungParalogues # see ensembl-compara/docs/docs/schema_doc.html for more details print $homology->description," ", $homology->subtype,"\n"; # And if they are defined dN and dS related values print " dn ", $homology->dn,"\n"; print " ds ", $homology->ds,"\n"; print " dnds_ratio ", $homology->dnds_ratio,"\n"; }
Each homology relation has 2 or more members, you should find there the initial member used as a query. The get_all_MemberAttribute method returns an array of pairs of Member and Attributes. The Member corresponds to the gene or protein and the Attribute object contains information about how this Member has been aligned.
my $homology = $homologies->[0]; # take one of the homologies and look into it foreach my $member_attribute (@{$homology->get_all_Member_Attribute}) { # for each Member, you get information on the Member specifically and in # relation to the homology relation via Attribute object my ($member, $attribute) = @{$member_attribute}; print (join " ", map { $member->$_ } qw(stable_id taxon_id))."\n"; print (join " ", map { $attribute->$_ } qw(perc_id perc_pos perc_cov))."\n"; }
You can get the original alignment used to define an homology:
use Bio::AlignIO; my $simple_align = $homology->get_SimpleAlign(); my $alignIO = Bio::AlignIO->newFh( -interleaved => 0, -fh => \*STDOUT, -format => "clustalw", -idlength => 20); print $alignIO $simple_align;
For additional information or help mail the ensembl-dev mailing list. You will need to subscribe to this mailing list to use it.


Wilder Blows Away Ortiz to Retain WBC Heavyweight Title
by Olugbenga IgeUnbeaten Deontay Wilder landed a devastating right hand to knock out Luis Ortiz in the seventh round and retain his World Boxing Council heavyweight title.
The 34-year-old Wilder remains on course to achieve his goal of unifying all four heavyweight belts despite being largely outboxed by Ortiz before the explosive one-punch finish at the MGM Grand Hotel in Las Vegas late Saturday night.
“When I see the right shot, it is baby good night,” Wilder said.
Unbeaten in 43 fights, Wilder showed why he is widely regarded as the most destructive puncher in the resurgent heavyweight division.
The “Bronze Bomber” recorded his 10th straight title defence to equal Muhammad Ali who achieved the feat between 1974 and 1978. Only four heavyweights in the history of boxing have made more than 10 consecutive title defences.
Wilder waited patiently for his big moment and when it came, with just nine seconds left in the round, it was stunning.
He followed a pawing jab with a crushing straight right that sent Ortiz’s head snapping back and his body crashing into the ropes before landing on the canvas.
“That was a punch intended to hurt for sure,” said the American. “I got him at the right angle, my feet were planted perfectly and I felt the torque.”
Ortiz tried to get up but he clearly could not continue. The fight was officially stopped at 2:51 of the seventh.


Using video as a Picture entity source, and as a pattern
Extensions: images, animation, wheel, filters
Notes:
Videos will not autoplay in mobile or tablet devices - some form of user interaction is required to trigger video play
The video-as-pattern (in the wheel) displays differently in IE compared to other browsers
Video won't display in Safari(Windows) browser
Filter
Additional notes:
Scrawl assumes that video files are hosted on the same server as the web page and does nothing to help prevent cross-origin restrictions
Youtube - it is against the YouTube terms of service to use anything other than the YouTube player to play content originating from the YouTube website.
Third party video player libraries are not (currently) supported by Scrawl. Libraries such as Video For Everybody, Video.js, JWPlayer and
MediaElement.jsinclude fallbacks to play Flash videos in legacy environments. Scrawl will only use <video> elements as a source for displaying video on the <canvas> element.


--- layout: post status: publish published: true title: A1 of my space! author: Leask author_login: leask author_email<EMAIL_ADDRESS>author_url: https://leaskh.com wordpress_id: 715 wordpress_url: http://leaskh.wordpress.com/2005/08/02/a1-of-my-space date: '2005-08-02 09:16:59 +0800' date_gmt: '2005-08-02 09:16:59 +0800' categories: - Snowman.S tags: [] comments: - id: 82 author: "啦啦" author_email: '' author_url: '' date: '2005-08-07 10:32:52 +0800' date_gmt: '2005-08-07 10:32:52 +0800' content: "想想。俺汗。。想想不愧是俺朋友。可爱又迷糊。和lala完全1样。<EMAIL_ADDRESS>- id: 83 author: "小呆" author_email: '' author_url: '' date: '2005-08-06 02:34:31 +0800' date_gmt: '2005-08-06 02:34:31 +0800' content: lala 真棒 支持你 - id: 84 author: Xiang author_email: '' author_url: '' date: '2005-08-02 10:10:39 +0800' date_gmt: '2005-08-02 10:10:39 +0800' content: Congratulations!I am downloading it now,can't wait to put it into use since it seems to be cooler than Realone Player. ---


{% load static i18n %}
{% blocktrans %} After you log in to the Dr. Down website, you will be redirected to the profile editing page, where you will need to fill in your details so that your registration is completed in the system, after inserting them, click the "Update" button. {% endblocktrans %}
{% blocktrans %} Once you have filled in your data and updated your profile, you will be redirected to the "My Profile" page, you will be able to view your data, edit your profile, change the registered email and delete your account. {% endblocktrans %}
{% blocktrans %} Nas próximas vezes que fizer o login, explicado aqui, você verá a Página de Notificações. Essa página te avisará quando houver novos eventos, novos pedidos de consulta a serem respondidos e te atualizará sobre o fórum. {% endblocktrans %}
{% blocktrans %} By clicking on Orders in the sidebar you will be redirected to the page that lists the requests for consultations, the orders will be ordered according to the risk of the specialty required by the patient and should be marked according to the priority. {% endblocktrans %}
{% blocktrans %} To mark an appointment you must click on the "Accept" button and you will be redirected to the appointment marking page. {% endblocktrans %}
{% blocktrans %} If the query is denied, you should write a justification for having this query refused. {% endblocktrans %}
{% blocktrans %} When you accept a query request or select the New Query option in the marked queries tab, you will be redirected to this page. {% endblocktrans %}
{% blocktrans %} When you are redirected to create a query through an order, the Specialty, Health Professional and Patient fields are already marked. The patient will have chosen a shift and a desired day of the week, you will have to look for this availability, if it is not possible, it is not mandatory that it be as desired by the patient. {% endblocktrans %}
{% blocktrans %} When you click Marked on the Queries tab, you will be redirected to the list of marked queries. You can edit or cancel a query, if necessary. {% endblocktrans %}
{% blocktrans %} By clicking on "Patients" you will have access to a list of Cris Down patients and clicking on a patient you will be redirected to the patient's chart. {% endblocktrans %}
{% blocktrans %} When you access a patient's chart, you can view the information of the chosen patient and the data filled by the Cris Down health team: evolutions, postnatal data, medical exams, prescriptions, complaints and curves of height, weight, cephalic perimeter. {% endblocktrans %}
{% blocktrans %} You can also go to the Care Line or print / save your medical records in PDF. {% endblocktrans %}
{% blocktrans %} In the "evolution" tab, you can see the entire medical history about your patient routine in Cris Down. {% endblocktrans %}
{% blocktrans %} In "exams", you can see all your patient exams and observations about him. {% endblocktrans %}
{% blocktrans %} The tab "prescription" shows the medicines prescribed by a health team member, and information like: the dosage and how often your patient must take it. {% endblocktrans %}
{% blocktrans %} This tab shows the complaints made by your patient. {% endblocktrans %}
{% blocktrans %} The 'curves' tab displays data about your patient like: BMI, height, weight and encephalic perimeter. With all of this data charts are generated to show your patient's developmental state. {% endblocktrans %}
{% blocktrans %} By accessing the Forum, you will be redirected to the Forum Categories page, clicking on any category you will go to the forum posts. {% endblocktrans %}
{% blocktrans %} You will have access to the posts of the selected category, you can also insert a new post for the category. {% endblocktrans %}
{% blocktrans %} In the comments page, you will have access to the comments of the selected post and you will also be able to make new comments in the post. {% endblocktrans %}
{% blocktrans %} In "Events", the list of events promoted by Cris Down will appear, clicking on "New Event" will be redirected to the event creation page and you can create an event to be placed on the list. {% endblocktrans %}
{% blocktrans %} In the page of new event it is mandatory to fill in the information in order that the users are well informed about the event. {% endblocktrans %}
{% blocktrans %} By clicking on an event you will have access to the event information. {% endblocktrans %}


--- layout: documentation title: PlatformSpecificationType ---
PlatformSpecificationType is a modularized data type intended for providing a consistent approach to uniquely specifying the identity of a specific platform. In addition to capturing basic information, this type is intended to be extended to enable the structured description of a platform instance using the XML Schema extension feature. The CybOX default extension uses the Common Platform Enumeration (CPE) Applicability Language schema to do so. The extension that defines this is captured in the CPE23PlatformSpecificationType in the http://cybox.mitre.org/extensions/platform#CPE2.3-1 namespace. This type is defined in the extensions/platform/cpe2.3.xsd file.
| Field Name | Type | Description |
|---|---|---|
| Description0..1 | StructuredTextType |
A prose description of the indicated platform. |
| Identifier0..n | PlatformIdentifierType |
Indicates a pre-defined name for the given platform using some naming scheme. For example, one could provide a CPE (Common Platform Enumeration) name using the CPE naming format. |


{% extends "base.html" %} {% set active_page = "charity" %} {% set page_title = "Charity - Mine Doge directly to charitible causes" %} {% block body %}
SimpleDoge allows you to easily contribute your hashing power directly to charities by connecting to our stratum servers with an aliased username. For example, to donate to the Dogecoin Foundation General Fund you would use the following connection settings with your miner:
Username: dogefoundation Password: [anything you want] URL: http://stratum.simpledoge.com:3333
| Name | Alias | Address | Last 10 min hashrate | Dogecoin donated |
|---|---|---|---|---|
| {{ charity.name }} | {{ charity.alias }} | {{ charity.address }} [stats] | {{ (charity.hashes_per_min / 1000) | round(2) }} KH/s | {{ (charity.total_paid / 100000000) | round(2) }} |


abstract fun withPreferredSerializationVersion(magic: SerializationMagic): SerializationContext
Helper method to return a new context based on this context but with serialization using the format this header sequence represents.


请参阅: 说明
| 接口 | 说明 |
|---|---|
| HandlerMethodArgumentResolver |
Strategy to resolve the argument value for a method parameter in the context
of the current HTTP request.
|
| RequestMappingInfo.Builder |
Defines a builder for creating a RequestMappingInfo.
|
| SyncHandlerMethodArgumentResolver |
An extension of
HandlerMethodArgumentResolver for implementations
that are synchronous in nature and do not block to resolve values. |
| 类 | 说明 |
|---|---|
| AbstractHandlerMethodMapping<T> |
Abstract base class for
HandlerMapping implementations that define
a mapping between a request and a HandlerMethod . |
| HandlerMethodArgumentResolverSupport |
Base class for
HandlerMethodArgumentResolver implementations with access to a
ReactiveAdapterRegistry and methods to check for method parameter support. |
| InvocableHandlerMethod |
Extension of
HandlerMethod that invokes the underlying method with
argument values resolved from the current HTTP request through a list of
HandlerMethodArgumentResolver . |
| RequestMappingInfo |
Request mapping information.
|
| RequestMappingInfo.BuilderConfiguration |
Container for configuration options used for request mapping purposes.
|
| RequestMappingInfoHandlerMapping |
Abstract base class for classes for which
RequestMappingInfo defines
the mapping between a request and a handler method. |
| SyncInvocableHandlerMethod |
Extension of
HandlerMethod that invokes the underlying method via
InvocableHandlerMethod but uses sync argument resolvers only and
thus can return directly a HandlerResult with no async wrappers. |


C.O.G.S.
The Rutgers University Creation Of Games Society
Featured Game by Andrew Marrero: ⇡
When: Wednesday 6:00pm-8:00pmWhere: Hill Center Room 248Who: Anyone, no experience required!
MISSION:
To make games we want to play and help others make games too
We are "platform agnostic" but we're not strangers to GameMaker, py-game, blender, Unity and browser based games.
Some of us participated Global Game Jam 2014 and loved it, our game was called:
Focal Points:
Download
Original Video Game Music!
RESOURCES:
Helpful IRC Chatrooms:
#ludumdare on irc.afternet.org
#bbg on irc.freenode.net
#whitedit-gamedev on irc.freenode.net
16-bit Sound Generator! drpetter.se/project_sfxr
Tile Generator autotilegen.com
Other resources are listed on SAKAIEmail<EMAIL_ADDRESS>To join and get on the mailing list
sia.github.io


Volumetric Satisfaction Interval Utility
Utility to create Interval List AWB component containing intervals for when any part of a Volumetric is satisfied by a spatial conditions used in a constrained spatial grid.
This utility takes the name of the Volumetric object to be used, a name for the AWB Interval component and a time step that determines the absolute accuracy of the intervals.
The Interval List component will be nested under the Scenario object in AWB.


--- sort_order: 3 tei_id: rdx_b6zxc.p.idm141643824 annotation_count: 0 images: small-thumbnail: https://readux.ecds.emory.edu/books/emory:b6zxc/pages/emory:h6sg7/mini-thumbnail/ json: https://readux.ecds.emory.edu/books/emory:b6zxc/pages/emory:h6sg7/info/ full: https://readux.ecds.emory.edu/books/emory:b6zxc/pages/emory:h6sg7/fs/ page: https://readux.ecds.emory.edu/books/emory:b6zxc/pages/emory:h6sg7/single-page/ thumbnail: https://readux.ecds.emory.edu/books/emory:b6zxc/pages/emory:h6sg7/thumbnail/ title: Front 3 number: 3 short_label: f. permalink: "/pages/front-3/" ---


Phonics Verb-Object Analysis
Anything in here will be replaced on browsers that support the canvas element


{% extends 'base.html' %}
{% block contents %}
This page is created with Material Design for Bootstrap (
MDB ) framework. Read details below to learn more about ALSET.
400+ material UI elements,
600+ material icons,
74 CSS animations, SASS files, templates, tutorials and many more.
Free for personal and commercial use.
ALSET
{{ contract_address }}
Our source codes are open sourced.
ALSET.sol
pragma solidity ^0.4.22;
contract ALSET {
struct Customer {
address customer_address;
uint coins;
uint coinsInsuranceContributed;
uint coinsInsuranceClaimed;
}
uint public max_ALSETcoins = 1000000;
uint public insurance_pool_coins = 500000;
uint public max_claim_coins = 200;
uint public coins_to_wei_rate = 1000;
uint public total_ALSETcoins_bought = 0;
function equity_in_ALSETcoins() public view returns(uint) {
return customers[msg.sender].coins;
}
function buyCoins(uint coins) public payable returns(uint) {
require(coins <= max_ALSETcoins - total_ALSETcoins_bought, "Not enough coins available.");
uint cost = coins * coins_to_wei_rate;
require(msg.value >= cost, "Not enough wei.");
customers[msg.sender].coins += coins;
total_ALSETcoins_bought += coins;
return coins;
}
function sellCoins(uint coins) public returns(uint) {
require(customers[msg.sender].coins >= coins, "Not enough coins available.");
customers[msg.sender].coins -= coins;
total_ALSETcoins_bought -= coins;
msg.sender.transfer(coins * coins_to_wei_rate);
return coins;
}
enum State {
Created,
Picked,
Delivered,
Completed,
Cancelled
}
struct Job {
uint id;
string name;
address poster;
address dispatcher;
uint coinsReward;
uint coinsCollateral;
uint pickuplong;
uint pickuplat;
uint dropofflong;
uint dropofflat;
uint timeAdded;
uint timeDelivered;
State state;
}
mapping(address => Customer) public customers;
mapping(uint => Job) public jobs;
uint public jobsCount = 0;
modifier onlyJobOfType(uint jobId, State state) {
require(jobs[jobId].state == state, "Incorrect job type.");
_;
}
modifier onlyIfAfford(uint coins) {
require(customers[msg.sender].coins >= coins, "Don't have enough coins.");
_;
}
modifier onlyByJobOwner(uint jobId) {
require(jobs[jobId].poster == msg.sender, "Not job owner.");
_;
}
modifier onlyByJobDispatcher(uint jobId) {
require(jobs[jobId].dispatcher == msg.sender, "Not job dispatcher.");
_;
}
modifier onlyIfDispatchedAtLeastOnce(address sender) {
uint dispatchCount = 0;
for (uint i = 0; i < jobsCount; i++) {
if (jobs[i].dispatcher == sender) {
dispatchCount++;
}
}
require(dispatchCount > 0, "Not entitled for claim.");
_;
}
function addJob(string jobName, uint coinsReward, uint coinsCollateral, uint pickuplong, uint pickuplat, uint dropofflong, uint dropofflat) public onlyIfAfford(coinsReward) {
jobs[jobsCount] = Job(
jobsCount,
jobName,
msg.sender,
0,
coinsReward,
coinsCollateral,
pickuplong,
pickuplat,
dropofflong,
dropofflat,
now,
0,
State.Created
);
jobsCount++;
customers[msg.sender].coins -= coinsReward;
}
function cancelJob(uint jobId) public onlyJobOfType(jobId, State.Created) onlyByJobOwner(jobId) {
jobs[jobId].state = State.Cancelled;
customers[jobs[jobId].poster].coins += jobs[jobId].coinsReward;
}
function pickJob(uint jobId) public onlyJobOfType(jobId, State.Created) onlyIfAfford(jobs[jobId].coinsCollateral) {
for (uint i = 0; i < jobsCount; i++) {
if (jobs[i].id == jobId) {
customers[msg.sender].coins -= jobs[jobId].coinsCollateral;
jobs[i].state = State.Picked;
jobs[i].dispatcher = msg.sender;
break;
}
}
}
function deliveredJob(uint jobId) public onlyByJobDispatcher(jobId) {
jobs[jobId].timeDelivered = now;
jobs[jobId].state = State.Delivered;
}
function acknowledgeDelivery(uint jobId) public onlyByJobOwner(jobId) {
require(
jobs[jobId].state == State.Picked || jobs[jobId].state == State.Delivered,
"Invalid job state."
);
customers[jobs[jobId].dispatcher].coins += jobs[jobId].coinsCollateral;
customers[jobs[jobId].dispatcher].coins += jobs[jobId].coinsReward;
jobs[jobId].state = State.Completed;
customers[jobs[jobId].dispatcher].coins -= jobs[jobId].coinsReward / 10;
insurance_pool_coins += jobs[jobId].coinsReward / 10;
}
function autoClearPaymentForDeliveredJob() private {
uint timeNow = now;
for (uint i = 0; i < jobsCount; i++) {
if (jobs[i].state == State.Delivered &&
jobs[i].timeDelivered - timeNow >= 3 days) {
customers[jobs[i].dispatcher].coins += jobs[i].coinsCollateral;
customers[jobs[i].dispatcher].coins += jobs[i].coinsReward;
jobs[i].state == State.Completed;
}
}
}
function getTransactionsCountRewardsAndCollaterals(State state) public view returns(uint, uint, uint) {
uint count = 0;
uint coinsReward = 0;
uint coinsCollateral = 0;
for (uint i = 0; i < jobsCount; i++) {
if (jobs[i].state == state) {
count++;
coinsReward += jobs[i].coinsReward;
coinsCollateral += jobs[i].coinsCollateral;
}
}
return (count, coinsReward, coinsCollateral);
}
function getDispatcherRoleCountAndRewards(address sender) public view returns(uint, uint) {
uint count = 0;
uint coinsReward = 0;
for (uint i = 0; i < jobsCount; i++) {
if (jobs[i].dispatcher == sender) {
count++;
coinsReward += jobs[i].coinsReward;
}
}
return (count, coinsReward);
}
function getJobPosterRoleCountAndRewards(address sender) public view returns(uint, uint) {
uint count = 0;
uint coinsReward = 0;
for (uint i = 0; i < jobsCount; i++) {
if (jobs[i].poster == sender) {
count++;
coinsReward += jobs[i].coinsReward;
}
}
return (count, coinsReward);
}
function submitClaim(uint claimTokens) public onlyIfDispatchedAtLeastOnce(msg.sender) returns(uint) {
require(claimTokens <= insurance_pool_coins, "Not enough coins in the insurance pool.");
require(claimTokens <= max_claim_coins, "Maximum claim tokens exceeded.");
for (uint i = 0; i < jobsCount; i++) {
if (jobs[i].dispatcher == msg.sender) {
// Deduct from the pool...
insurance_pool_coins -= claimTokens;
// ...and add to customer
customers[msg.sender].coins += claimTokens;
return claimTokens;
}
}
return 0;
}
}
By running on the latest blockchain technologies, be safe assured that the market rules and your investment will not be tempered with.
Leverages on the power of the masses to get your parcel delivered.
Fully utilizing all gathered data to optimize operations.
Utilizing the latest and greatest machine learning techniques to ensure that your parcel reaches its destination quickly and safely.


The Drunk Jailer
问题描述 :
A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is locked.
One night, the jailer gets bored and decides to play a game. For round 1 of the game, he takes a drink of whiskey, and then runs down the hall unlocking each cell. For round 2, he takes a drink of whiskey, and then runs down the hall locking every other cell (cells 2, 4, 6, …). For round 3, he takes a drink of whiskey, and then runs down the hall. He visits every third cell (cells 3, 6, 9, …). If the cell is locked, he unlocks it; if it is unlocked, he locks it. He repeats this for n rounds, takes a final drink, and passes out.
One night, the jailer gets bored and decides to play a game. For round 1 of the game, he takes a drink of whiskey, and then runs down the hall unlocking each cell. For round 2, he takes a drink of whiskey, and then runs down the hall locking every other cell (cells 2, 4, 6, …). For round 3, he takes a drink of whiskey, and then runs down the hall. He visits every third cell (cells 3, 6, 9, …). If the cell is locked, he unlocks it; if it is unlocked, he locks it. He repeats this for n rounds, takes a final drink, and passes out.
Some number of prisoners, possibly zero, realizes that their cells are unlocked and the jailer is incapacitated. They immediately escape.
Given the number of cells, determine how many prisoners escape jail.
输入:
The first line of input contains a single positive integer. This is the number of lines that follow. Each of the following lines contains a single integer between 5 and 100, inclusive, which is the number of cells n.
输出:
For each line, you must print out the number of prisoners that escape when the prison has n cells.
样例输入:
2 5 100
样例输出:
2 10
地址：http://acm.hdu.edu.cn/showproblem.php?pid=1337
题意：狱警玩游戏，第一次转换1，2，……，n的锁的开关状态，第二次转换2，4，……，第三次3，6，……依次类推到第n次。求最后有多少锁是开着的。
mark：模拟就ok了。
代码：
#include <stdio.h> #include <string.h> int main() { int t,n,a[110]; int i,j,sum; scanf("%d", &t); while(t-- && scanf("%d", &n)) { memset(a, 0, sizeof(a)); for(i = 2; i <= n; i++) for(j = 1; j*i <= n; j++) a[j*i]++; for(sum = 0, i = 1; i <= n; i++) if(!(a[i]%2)) sum++; printf("%d\n", sum); } return 0; }
解题报告转自：http://www.cnblogs.com/andre0506/archive/2012/07/03/2574059.html
(adsbygoogle = window.adsbygoogle || []).push({});
什么破题，题意好难懂啊
楼主 为什么输入的形式都不对 题目是不是弄错了？
这个问题别太纠结了，不同的编译器结果不一样
算法是程序的灵魂，算法分简单和复杂，如果不搞大数据类，程序员了解一下简单点的算法也是可以的，但是会算法的一定要会编程才行，程序员不一定要会算法，利于自己项目需要的可以简单了解。
#!/usr/bin/env python
def cou(n):
arr =
i = 1
while(i<n):
arr.append(arr[i-1]+selfcount(i))
i+=1
return arr[n-1]
def selfcount(n):
count = 0
while(n):
if n%10 == 1:
count += 1
n /= 10
return count
很好，注释很详细啊
.net中char类型不是两个字节么
很好！！
27行 minStack.push(minValue); 去掉就对了
递归还真是一门学问，学习了
好厉害～
<EMAIL_ADDRESS>后面的是python代码啊
神奇的网站


{% extends "layout_picker.html" %} {% set serviceName = "Apply for an older person's bus pass" %} {% set pageTitle = "You'll need to get a digital photo from a shop" %} {% block content %}
Ask for a digital passport style photo from a photo shop.
You'll need to start your application again, but you won't need to sign up for GOV.UK Verify again.
If you need help doing this, you can contact the council.


About My name is Chris van den Berg. I’m a Data Scientist who loves to build stuff. This blog is created to share some of the ideas and side projects I’ve worked on. linkedin git / gist


#include <largeobject.h>
Inheritance diagram for pqxx::largeobject:
Public Types | |
| typedef long | size_type |
Public Member Functions | |
| largeobject () | |
| Refer to a nonexistent large object (similar to what a null pointer does). | |
| largeobject (dbtransaction &T) | |
| Create new large object. | |
| largeobject (oid O) | |
| Wrap object with given oid. | |
| largeobject (dbtransaction &T, const PGSTD::string &File) | |
| Import large object from a local file. | |
| largeobject (const largeobjectaccess &O) | |
| Take identity of an opened large object. | |
| oid | id () const throw () |
| Object identifier. | |
| bool | operator== (const largeobject &other) const |
| Comparison is only valid between large objects in the same database. | |
| bool | operator!= (const largeobject &other) const |
| Comparison is only valid between large objects in the same database. | |
| bool | operator<= (const largeobject &other) const |
| Comparison is only valid between large objects in the same database. | |
| bool | operator>= (const largeobject &other) const |
| Comparison is only valid between large objects in the same database. | |
| bool | operator< (const largeobject &other) const |
| Comparison is only valid between large objects in the same database. | |
| bool | operator> (const largeobject &other) const |
| Comparison is only valid between large objects in the same database. | |
| void | to_file (dbtransaction &T, const PGSTD::string &File) const |
| Export large object's contents to a local file. | |
| void | remove (dbtransaction &T) const |
| Delete large object from database. | |
Protected Member Functions | |
| PGSTD::string | Reason () const |
Static Protected Member Functions | |
| PGconn * | RawConnection (const dbtransaction &T) |
This class encapsulates the identity of a large object. To access the contents of the object, create a largeobjectaccess, a largeobject_streambuf, or an ilostream, an olostream or a lostream around the largeobject.
A largeobject must be accessed only from within a backend transaction, but the object's identity remains valid as long as the object exists.
|
|
|
|
|
Refer to a nonexistent large object (similar to what a null pointer does).
|
|
|
Create new large object.
|
|
|
Wrap object with given oid. Convert combination of a transaction and object identifier into a large object identity. Does not affect the database.
|
|
|
Import large object from a local file. Creates a large object containing the data found in the given file.
|
|
|
Take identity of an opened large object. Copy identity of already opened large object. Note that this may be done as an implicit conversion.
|
|
|
Object identifier. The number returned by this function identifies the large object in the database we're connected to (or oid_none is returned if we refer to the null object). |
|
|
Comparison is only valid between large objects in the same database.
|
|
|
Comparison is only valid between large objects in the same database.
|
|
|
Comparison is only valid between large objects in the same database.
|
|
|
Comparison is only valid between large objects in the same database.
|
|
|
Comparison is only valid between large objects in the same database.
|
|
|
Comparison is only valid between large objects in the same database.
|
|
|
|
|
|
|
|
|
Delete large object from database. Unlike its low-level equivalent cunlink, this will throw an exception if deletion fails.
|
|
|
Export large object's contents to a local file. Writes the data stored in the large object to the given file.
|