This write-up describes a sudoku program developed to solve 2x2, 3x3 and 4x4 sudoku puzzles. Source code for the same can be found in github.
The backtracking algorithm that solves sudoku puzzle has exponential complexity, and suffers from pathological combinations that can throw the algorithm into a for-ever-loop.
The algorithm works on an unsolved sudoku puzzle, with N elements pre-populated - which is the measure of difficulty. That is, say for a 9x9 table of numbers, may be just 10 can be pre-populated. The algorithm uses a double recursive backtracking logic to find the right combination of numbers satisfying the game rules. So, for a 9x9 table with 10 pre-populated elements, the program must fill the remaining 71 slots and for each slot there are 9 choices ([1,2,3,4,5,6,7,8,9]).
The first recursion logic moves from one slot to the next, column-wise and then row-wise. At every step, it tries to reduce the available choices for an unfilled slot. There are 6 intelligent functors that applies primitive human logic to reduce the choices. It then detects whether it has taken the right path by checking with the game rules. If it detects that it has taken a bad path it backtracks.
The second recursion logic kicks in when the first recursive function detects that it has taken the right path (so far), and finds that the current slot has more than one choice left irreducible. The logic will recur over remaining choices, and calling back to first recursion logic. So on and so forth ...
pathological case
A pathological case is an input combinations that can make the puzzle solver to keep executing bad paths for a long time before finding the right path.
Any backtracking algorithm, while executing, will have to make several choices before finding the right solution. We will take our Sudoku puzzle solver as an example and expound further -
For a 9x9 puzzle, with 10 elements pre-populated, should leave 71 slots unfilled. And for each slot there are 9 choices to make [1,2,3,4,5,6,7,8,9]. If we are using a brute force backtracking algorithm, it will have to pass 71 steps (to fill each slot) and for each step it will have to make nine choices, making the number of possible paths to
56392087339601733413306017749077372989860250021295987473736382457209L,
(do not try to interpret, it is way beyond trillions)
This is the worst case for a brute force backtracking algorithm before it succeeds or fails. But our implementation is not brute force ! It uses intelligent functors to reduce the choices for each slot.
For the sake of argument, let us say that the functors are able to reduce the number of choices to 2 - all the time. Then our algorithm will have to pass 71 steps and for each step it will have to make 2 choices. This will reduce the number of possible paths to (in worst case)
2361183241434822606848L.
It will still take light years to exhaust all possible paths.
concurrent sudoku puzzle solver
To explain how the concurrent algorithm works we are going to use the following combination as the example
{{0,0,2,0,0,4,0,0,9}, {0,0,0,0,0,9,0,0,0}, {0,6,0,0,0,0,0,4,8}, {0,3,5,0,0,0,0,0,0}, {0,0,6,0,0,0,1,0,0}, {0,9,0,0,0,5,0,0,4}, {4,0,0,0,5,0,0,0,0}, {6,0,0,0,0,2,0,0,0}, {9,0,0,0,4,6,0,0,0}}.
In above case, first slot is unfilled and our functors can reduce the choices to [1,3,5,7,8]. Once the algorithm knows that those are irreducible choices, it will spawn 5 processes, picking a unique choice for each one of them. Each of those process will continue from the second slot and repeat the same logic all over again.
Soon our algorithm is going to spawn millions and millions of processes only to find that it has taken a bad path. So we will add a cap on the maximum number of processes it can spawn, say 100 !
All I did was to change couple of lines in existing code and add another 40 lines to implement the concurrent logic. If you have cloned my repository, github, you can check this out under src/sudoku_slv.erl file. There are two application parameters worth noting here,
- concurrent,
- boolean(), false to use sequential algorithm and true to a concurrent backtracking algorithm.
- procs,
- Integer(), while executing in concurrent mode, limits the number of spawn-able process.


ruleset module¶
A module to hold rules for the analysis of a module.
-
class
ruleset.
Ruleset
(module: str)¶ Bases:
object
Holds all rules for a module.
Methods
add_sanitizer
(method, sink, sink_method_idx, …)Add a new sanitizer to a sink. add_sink
(method, sink)Add a new sink to the list. add_source
(method, source)Add a new source to the list. notify_observers
(method, changed_sanitizer, …)Notify observers about changes in sinks or sanitizers. register_observer
(observer)Register an observer for sources and sinks. -
_Ruleset__load_sinks
()¶ Load sinks for this ruleset.
-
_Ruleset__load_sources
()¶ Load sources for this ruleset.
-
add_sanitizer
(method: method.Method, sink: sink.Sink, sink_method_idx: int, sanitizer: dict, level: int = 0)¶ Add a new sanitizer to a sink. New sanitizers are only relevant if a method’s parameters are used in a sanitizer.
Parameters: - method : Method
The method where the sanitizer was added
- sink : Sink
The sink to add the sanitizer to
- sink_method_idx : int
The index of the method for which to add the new sanitizer
- sanitizer : dict
A dictionary definition of the sanitizer as defined in the ruleset
- level : int, optional
The depth of the nesting before the sanitizer is reached (sanitizers defined in the rules get a level of 0, sanitizers that call those get a level of 1, sanitizers that call those get a level of 2 and so on)
-
add_sink
(method: method.Method, sink: dict)¶ Add a new sink to the list. New sinks are only relevant if a method’s parameters are used in a sink. The same sanitizers are used from the original sink.
Parameters: - method : Method
The method where the sink was added
- sink : dict
A dictionary definition of the sink as defined in the ruleset
-
add_source
(method: method.Method, source: dict)¶ Add a new source to the list. New sources are only relevant if either a method’s parameters are used in a source or their results are returned.
Parameters: - method : Method
The method where the source was added
- source : dict
A dictionary definition of the source as defined in the ruleset
-
logger
= <Logger taintalyzing (WARNING)>¶
-
notify_observers
(method: method.Method, changed_sanitizer: Optional[bool] = None, new_source: bool = False)¶ Notify observers about changes in sinks or sanitizers.
Parameters: - method : Method
The method that was updated
- changed_sanitizer : bool, optional
A sanitizer was changed
- new_source : bool, optional
A new source was added
-
register_observer
(observer)¶ Register an observer for sources and sinks.
Parameters: - observer
Object that wants to be notified about changes in sources, sinks or sanitizers
-


[§261-15.6] Annual registration fee. The department shall assess and collect an annual registration fee of $10 from each operator of aircraft required to be registered under section 261-15.5. [L 1985, c 299, pt of §1]


About Me
Fresher FrontEnd Developer from Hanoi. As an energetic young person, I'm not afraid to face challenges to develop myself.
My Hobbies
Watching football
Listening Music
Play eSports
Research about IT
Resume
Have learnt Advanced Diploma In Multimedia course at FPT Arena Multimedia.
Graphic Designer.
Graphic Designer and Printer.
My Skills
Other Skills
I also can use English in basic reading, writing and communication.
My Production
Website Theme
Flyer
Halloween Festival
Festival
Get in Touch


Things aren't good. They are going to break. Deal with it.
I can weep. I can complain. I can hold your hand while you weep and complain.  I am the Carole King of software. Or, like, click here also.


'Fraudulent Votes' Not Acceptable: Abdullah’s Team
Abdullah’s team urged the Independent Election Commission (IEC) to “clean the votes.”
by TOLOnew.comAbdullah Abdullah’s campaign team held a press conference on Friday, with member Asadullah Sadati saying: “We will not, under any conditions, accept fraudulent votes.”
“In the 2014 election, we knew there was fraud, but we didn’t know where it came from. But now we know where these votes come from,” Sadati told reporters.
He referenced the IEC-acknowledged “missing” biometric devices:
"Still no news over the missing biometric devices, and the IEC will not even take action against those who were responsible for the devices," said Sadati, adding that "maybe the missing biometric devices have been used in someone’s interest."
Referring to the vulnerability of the biometric devices to allow for the manipulation of the time stamp, Sadati said:
“We have clear evidence that votes even came in at night, while the voting process had been finished for hours. How is that acceptable?”
Abdullah’s team, Sadadti said, has a copy of the agreement between the IEC and Dermalog company that is very clear about what time the voting process started and ended.
“Even votes came in hours before and after the voting hours,” he said. "300,000 votes are fraudulent votes and they are still on the server.”
"We want the votes in the database to be clean,” Sadati said, adding that "repeated votes, and votes coming from outside the polling center, are a crime and action must be taken."
"It doesn’t matter which candidate the redundant votes are for—we must think about the standard," Sadati said, continuing: "We want all fraudulent votes to be separated out.”
“The IEC doesn’t have the authority to decide who will become president, and they must respect the people’s vote and do their job,” he added.
Abdullah’s team has previously mentioned categories of “invalid” votes:
• 137,630 votes that are under server quarantine.
• 102,012 votes that were cast before or after election day.
• Votes validated by duplicate photos or photos of photos.
• Votes from 700 devices and memory cards that were lost.
On Wednesday, the IEC said the announcement of the preliminary presidential polling results would once again be postponed because of complaints about invalid votes.
Aurangzib, an IEC commissioner, said the announcement originally scheduled for Thursday, November 14, must be pushed farther out due to “tensions” hindering the vote recounting process at “8,000 polling stations.”
IEC spokesman Aziz Ahmad Ibrahimi said the vote recount was halted across Afghanistan to address the complaints of the candidates, and that “the recounting process has temporarily stopped across the country until next guidance.”
A number of presidential candidates have urged the IEC to purge the “invalid” votes from the database and start the recounting process.
Earlier, presidential candidate Rahmatullah Nabil called out a “certain election campaign team” multiple times, saying it had committed “large-scale fraud” and is trying to gain power through “rigging and fraud,” saying that everyone has a responsibility to stand against such acts.
Also on Monday, presidential candidate and Hizb-e-Islami, leader Gulbuddin Hekmatyar at a press conference in Kabul claimed that 44 percent of the presidential election votes are not valid.


#include <string_ops.h>
Joins a string Tensor across the given dimensions.
Computes the string join across dimensions in the given string Tensor of shape [\\(d_0, d_1, ..., d_{n-1}\\)]
. Returns a new Tensor created by joining the input strings with the given separator (default: empty string). Negative indices are counted backwards from the end, with -1
being equivalent to n - 1
. If indices are not specified, joins across all dimensions beginning from n - 1
through 0
.
For example:
# tensor `a` is [["a", "b"], ["c", "d"]] tf.reduce_join(a, 0) ==> ["ac", "bd"] tf.reduce_join(a, 1) ==> ["ab", "cd"] tf.reduce_join(a, -2) = tf.reduce_join(a, 0) ==> ["ac", "bd"] tf.reduce_join(a, -1) = tf.reduce_join(a, 1) ==> ["ab", "cd"] tf.reduce_join(a, 0, keep_dims=True) ==> [["ac", "bd"]] tf.reduce_join(a, 1, keep_dims=True) ==> [["ab"], ["cd"]] tf.reduce_join(a, 0, separator=".") ==> ["a.c", "b.d"] tf.reduce_join(a, [0, 1]) ==> "acbd" tf.reduce_join(a, [1, 0]) ==> "abcd" tf.reduce_join(a, []) ==> [["a", "b"], ["c", "d"]] tf.reduce_join(a) = tf.reduce_join(a, [1, 0]) ==> "abcd"
Arguments:
reduction_indices
is equivalent to passing [n-1, n-2, ..., 0]
. Negative indices from -n
to -1
are supported.Optional attributes (see Attrs
):
True
, retain reduced dimensions with length 1
.Returns:
Output
: Has shape equal to that of the input with reduced dimensions removed or set to 1
depending on keep_dims
.
Constructors and Destructors |
|
|---|---|
ReduceJoin(const ::tensorflow::Scope & scope, ::tensorflow::Input inputs, ::tensorflow::Input reduction_indices)
|
|
ReduceJoin(const ::tensorflow::Scope & scope, ::tensorflow::Input inputs, ::tensorflow::Input reduction_indices, const ReduceJoin::Attrs & attrs)
|
Public attributes |
|
|---|---|
operation
|
|
output
|
Public functions |
|
|---|---|
node() const
|
::tensorflow::Node *
|
operator::tensorflow::Input() const
|
|
operator::tensorflow::Output() const
|
|
Public static functions |
|
|---|---|
KeepDims(bool x)
|
|
Separator(StringPiece x)
|
Structs |
|
|---|---|
|
tensorflow:: |
Optional attribute setters for ReduceJoin. |
Operation operation
::tensorflow::Output output
ReduceJoin( const ::tensorflow::Scope & scope, ::tensorflow::Input inputs, ::tensorflow::Input reduction_indices )
ReduceJoin( const ::tensorflow::Scope & scope, ::tensorflow::Input inputs, ::tensorflow::Input reduction_indices, const ReduceJoin::Attrs & attrs )
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output() const
Attrs KeepDims( bool x )
Attrs Separator( StringPiece x )


Enter zip-code where the unit will be installed:
Is your heat source a:
Square footage of the home:
Tonnage of the existing system:
Do you need a full system installed or are you looking for replacement parts?


Input CoNLL format
show settings
Select which column carries which feature
text:
id:
pos-tag:
type of dependency:
target of dependency (id):
aligned tokens (id's):
language:
y-spacing:
x-spacing:
x-offset:
sentence 1
sentence 2
all
sentence 1:
visualize!
Show all dependencies
Show all alignments
Show all POS tags


/rest.php
variable Script rest get Script from `/resources/ecs/main.ecs?v=` cat now run Script
My name is Graham Trott and I’m the author of EasyCoder.
If you are reading this it’s for one of a couple of reasons. You may be curious to see what the page source code looks like, or you may want to build something similar, perhaps long after I’m no longer available.
Almost all software becomes harder and harder to read the more time passes since it was written. After a few years, even the original author will have some difficulty in figuring out what was done, and anyone coming new to a project will have major trouble in all but the simplest of cases. So these notes are intended to provide a starting point.
EasyCoder is a custom high-level scripting language that is itself written in JavaScript. So you can say quite correctly that any site using it is powered by JavaScript. At the time of writing it’s de rigeur to use a framework such as Angular or React, but after a few years these will become obsolete as newer technologies arrive. In any case, frameworks are not designed to make it easy to pick up a project; they’re intended to benefit developers who are writing new code. As such they are an implicit admission that the language itself (JavaScript) is not up to the job and requires extra features not provided by its authors.
My preference is to use a better language, one that is designed to do the job without requiring a host of bolt-on extras. Since none were available I wrote my own and it’s called EasyCoder and this website is the kicking-off point for all the information you need. The most significant part of it is our Codex, which is a combination of tutorial and programmer's playground designed to get you familiar with EasyCoder.
To create your own EasyCoder website, see the Introduction. EasyCoder itself is brought in from CDN; the only local resource is the script itself, which is embedded in a <pre>...</pre> tag.
The entire EasyCoder source code repository is at https://github.com/easycoder.
And that’s all I have to say. I hope to be around for a few years yet, so do contact me if you would like to know anything. After that it’ll be out of my hands.


{{$index==0?'Start':('Checkpoint ' + ($index))}} to {{!$last?('Checkpoint ' + ($index+1)):'Evacuation zone'}}
【LIVE Victims】Number： {{30 + (evacuationLevel-1)*10}} points /victim
【DEAD Victims】Number： {{15 + (evacuationLevel-1)*5}} points /victim
Robot exited the evacuation zone after touching at least one victim: 20 points
If you have any comments about the run, please write in the box below.
By wiritng a sign below, you accept that the [Score：{{score}}] [Time：{{minutes}} min {{seconds}} sec] are correct. Your team also further undertakes to not appeal the score at a later stage.
By wiritng a sign below, you accept that the [Score：{{score}}] [Time：Retire] are correct. Your team also further undertakes to not appeal the score at a later stage.


{% load staticfiles %}
Dashboard
Admin Login
Plant Analytics
Water Tank Details
Plant Locations
This page shows all the plants you have


Hmm, not much here is there. Want to try your hand at building a site related to the Figure Photography Community on Google+? Let's see what you can do:


“…went to the most best museum this side of the Pitt Rivers (a woven pram next to an altar, proudly displayed old soap, a beehive cooler, an array of shoe moulds, two copies of ‘Veneering And Its Possibilities')…” — Ric Morris and John Gower, in a letter from Australia to Jonathan Coleclough


San Francisco Railway Administration
Current Train Schedule
Train Name
Destination
Frequency(min)
Next Arrival
Minutes Away
Add Train
Train Name
Destination
First Train Time (HH:mm - military time)
Frequency (min)


Toggle navigation
Productions
2015

2014

2013
ANOMALY
Download the program!
See the event!
FESTIVAL DIONYSUS
Download the program!
See the event!
FOURPLAY
Download the program!
See the event!


About Me
With a passion for all things engineering, Alex enjoys finding that ideal solution that considers the whole. From studying the original system of the environment to the languages behind the digital world, Alex uses a variety of skills and experiences to engineer that solution. With an entrepreneurial spirit, he looks to build upon these diverse skills and find areas that can continue to challenge him.
A Lancaster, PA, native, Alex went from saxophone player to rower at Lehigh University, when he joined the class of 2013. When not rowing, Alex studied for a major in Environmental Engineering and also found a minor in science and environmental reporting. Staying at Lehigh for another two years, Alex continued studying environmental engineering to achieve a Master’s degree and researched novel waste to energy processes. This work led to a stint consulting with an energy startup and even travelling to Turkey to set up a R&D lab there. Pivoting from the excitement of a startup, Alex joined the Army Public Health Command in 2015. Serving as an Army civilian, Alex consulted and led a wide variety of environmental projects with a focus on field water and water reuse technologies. In December of 2018, Alex became a professional engineer in the state of Maryland.
Currently, Alex is expanding his knowledge in a newfound passion for coding. Still rowing, but now with Baltimore Community Rowing and the men’s competitive team, he aslso tried to find time to hike, ski, play games, or just relax by the river. His vice is older BMWs of which at any given time may or may not be running. Given the time, he will also make custom vinyl stickers as a creative outlet. Alex currently resides in Baltimore City with his fiance, Alyssa, and mini Irish-doodle, Moose.


Jokepo Python - Web Client
try paper
try rock
try scissor
Stats
Score
Results
timestamp
Player
CPU
Result


| Module | ActiveRecord::ConnectionAdapters::DatabaseStatements |
| In: |
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb
|
Appends LIMIT and OFFSET options to an SQL statement, or some SQL fragment that has the same semantics as LIMIT and OFFSET.
options must be a Hash which contains a +:limit+ option and an +:offset+ option.
This method modifies the sql parameter.
add_limit_offset!('SELECT * FROM suppliers', {:limit => 10, :offset => 50})
generates
SELECT * FROM suppliers LIMIT 10 OFFSET 50
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 217 217: def add_limit_offset!(sql, options) 218: if limit = options[:limit] 219: sql << " LIMIT #{sanitize_limit(limit)}" 220: end 221: if offset = options[:offset] 222: sql << " OFFSET #{offset.to_i}" 223: end 224: sql 225: end
Register a record with the current transaction so that its after_commit and after_rollback callbacks can be called.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 189 189: def add_transaction_record(record) 190: last_batch = @_current_transaction_records.last 191: last_batch << record if last_batch 192: end
Begins the transaction (and turns off auto-committing).
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 195 195: def begin_db_transaction() end
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 246 246: def case_sensitive_equality_operator 247: "=" 248: end
Commits the transaction (and turns on auto-committing).
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 198 198: def commit_db_transaction() end
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 227 227: def default_sequence_name(table, column) 228: nil 229: end
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 242 242: def empty_insert_statement_value 243: "VALUES(DEFAULT)" 244: end
Executes the SQL statement in the context of this connection.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 38 38: def execute(sql, name = nil, skip_logging = false) 39: end
Returns the last auto-generated ID from the affected table.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 43 43: def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) 44: insert_sql(sql, name, pk, id_value, sequence_name) 45: end
Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 238 238: def insert_fixture(fixture, table_name) 239: execute "INSERT INTO #{quote_table_name(table_name)} (#{fixture.key_list}) VALUES (#{fixture.value_list})", 'Fixture Insert' 240: end
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 250 250: def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key) 251: "WHERE #{quoted_primary_key} IN (SELECT #{quoted_primary_key} FROM #{quoted_table_name} #{where_sql})" 252: end
Checks whether there is currently no transaction active. This is done by querying the database driver, and does not use the transaction house-keeping information recorded by increment_open_transactions and friends.
Returns true if there is no transaction active, false if there is a transaction active, and nil if this information is unknown.
Not all adapters supports transaction state introspection. Currently, only the PostgreSQL adapter supports this.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 67 67: def outside_transaction? 68: nil 69: end
Set the sequence to the max value of the table‘s column.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 232 232: def reset_sequence!(table, column, sequence = nil) 233: # Do nothing by default. Implement for PostgreSQL, Oracle, ... 234: end
Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 202 202: def rollback_db_transaction() end
Returns an array of record hashes with the column names as keys and column values as values.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 6 6: def select_all(sql, name = nil) 7: select(sql, name) 8: end
Returns a record hash with the column names as keys and column values as values.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 12 12: def select_one(sql, name = nil) 13: result = select_all(sql, name) 14: result.first if result 15: end
Returns an array of arrays containing the field values. Order is the same as that returned by columns.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 33 33: def select_rows(sql, name = nil) 34: end
Returns a single value from a record
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 18 18: def select_value(sql, name = nil) 19: if result = select_one(sql, name) 20: result.values.first 21: end 22: end
Returns an array of the values of the first column in a select:
select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 26 26: def select_values(sql, name = nil) 27: result = select_rows(sql, name) 28: result.map { |v| v[0] } 29: end
Runs the given block in a database transaction, and returns the result of the block.
Most databases don‘t support true nested transactions. At the time of writing, the only database that supports true nested transactions that we‘re aware of, is MS-SQL.
In order to get around this problem, transaction will emulate the effect of nested transactions, by using savepoints: dev.mysql.com/doc/refman/5.0/en/savepoints.html Savepoints are supported by MySQL and PostgreSQL, but not SQLite3.
It is safe to call this method if a database transaction is already open, i.e. if transaction is called within another transaction block. In case of a nested call, transaction will behave as follows:
MySQL doesn‘t support DDL transactions. If you perform a DDL operation, then any created savepoints will be automatically released. For example, if you‘ve created a savepoint, then you execute a CREATE TABLE statement, then the savepoint that was created will be automatically released.
This means that, on MySQL, you shouldn‘t execute DDL operations inside a transaction call that you know might create a savepoint. Otherwise, transaction will raise exceptions when it tries to release the already-automatically-released savepoints:
Model.connection.transaction do # BEGIN Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1 Model.connection.create_table(...) # active_record_1 now automatically released end # RELEASE SAVEPOINT active_record_1 <--- BOOM! database error! end
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 113 113: def transaction(options = {}) 114: options.assert_valid_keys :requires_new, :joinable 115: 116: last_transaction_joinable = defined?(@transaction_joinable) ? @transaction_joinable : nil 117: if options.has_key?(:joinable) 118: @transaction_joinable = options[:joinable] 119: else 120: @transaction_joinable = true 121: end 122: requires_new = options[:requires_new] || !last_transaction_joinable 123: 124: transaction_open = false 125: @_current_transaction_records ||= [] 126: 127: begin 128: if block_given? 129: if requires_new || open_transactions == 0 130: if open_transactions == 0 131: begin_db_transaction 132: elsif requires_new 133: create_savepoint 134: end 135: increment_open_transactions 136: transaction_open = true 137: @_current_transaction_records.push([]) 138: end 139: yield 140: end 141: rescue Exception => database_transaction_rollback 142: if transaction_open && !outside_transaction? 143: transaction_open = false 144: decrement_open_transactions 145: if open_transactions == 0 146: rollback_db_transaction 147: rollback_transaction_records(true) 148: else 149: rollback_to_savepoint 150: rollback_transaction_records(false) 151: end 152: end 153: raise unless database_transaction_rollback.is_a?(ActiveRecord::Rollback) 154: end 155: ensure 156: @transaction_joinable = last_transaction_joinable 157: 158: if outside_transaction? 159: @open_transactions = 0 160: elsif transaction_open 161: decrement_open_transactions 162: begin 163: if open_transactions == 0 164: commit_db_transaction 165: commit_transaction_records 166: else 167: release_savepoint 168: save_point_records = @_current_transaction_records.pop 169: unless save_point_records.blank? 170: @_current_transaction_records.push([]) if @_current_transaction_records.empty? 171: @_current_transaction_records.last.concat(save_point_records) 172: end 173: end 174: rescue Exception => database_transaction_rollback 175: if open_transactions == 0 176: rollback_db_transaction 177: rollback_transaction_records(true) 178: else 179: rollback_to_savepoint 180: rollback_transaction_records(false) 181: end 182: raise 183: end 184: end 185: end
Send a commit message to all records after they have been committed.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 314 314: def commit_transaction_records #:nodoc 315: records = @_current_transaction_records.flatten 316: @_current_transaction_records.clear 317: unless records.blank? 318: records.uniq.each do |record| 319: begin 320: record.committed! 321: rescue Exception => e 322: record.logger.error(e) if record.respond_to?(:logger) 323: end 324: end 325: end 326: end
Returns the last auto-generated ID from the affected table.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 262 262: def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) 263: execute(sql, name) 264: id_value 265: end
Send a rollback message to all records after they have been rolled back. If rollback is false, only rollback records since the last save point.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 294 294: def rollback_transaction_records(rollback) #:nodoc 295: if rollback 296: records = @_current_transaction_records.flatten 297: @_current_transaction_records.clear 298: else 299: records = @_current_transaction_records.pop 300: end 301: 302: unless records.blank? 303: records.uniq.each do |record| 304: begin 305: record.rolledback!(rollback) 306: rescue Exception => e 307: record.logger.error(e) if record.respond_to?(:logger) 308: end 309: end 310: end 311: end
Sanitizes the given LIMIT parameter in order to prevent SQL injection.
limit may be anything that can evaluate to a string via to_s. It should look like an integer, or a comma-delimited list of integers.
Returns the sanitized limit parameter, either as an integer, or as a string which contains a comma-delimited list of integers.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 284 284: def sanitize_limit(limit) 285: if limit.to_s =~ /,/ 286: limit.to_s.split(',').map{ |i| i.to_i }.join(',') 287: else 288: limit.to_i 289: end 290: end
Returns an array of record hashes with the column names as keys and column values as values.
# File /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb, line 257 257: def select(sql, name = nil) 258: end


Solvers and test set for stiff and non-stiff differential equations, and differential algebraic equations.
| Version: | 1.1.5 |
| Depends: | R (≥ 2.01), deSolve |
| Imports: | graphics, grDevices, stats |
| Published: | 2017-01-19 |
| Author: | Karline Soetaert [aut, cre], Jeff Cash [aut], Francesca Mazzia [aut], LAPACK authors [cph] |
| Maintainer: | Karline Soetaert <karline.soetaert at nioz.nl> |
| License: | GPL-2 | GPL-3 [expanded from: GPL] |
| Copyright: | inst/COPYRIGHTS deTestSet copyright details |
| NeedsCompilation: | yes |
| In views: | DifferentialEquations |
| CRAN checks: | deTestSet results |
| Reference manual: | deTestSet.pdf |
| Vignettes: |
Test Set Problems in R |
| Package source: | deTestSet_1.1.5.tar.gz |
| Windows binaries: | r-devel: deTestSet_1.1.5.zip, r-release: deTestSet_1.1.5.zip, r-oldrel: deTestSet_1.1.5.zip |
| OS X binaries: | r-release: deTestSet_1.1.5.tgz, r-oldrel: deTestSet_1.1.5.tgz |
| Old sources: | deTestSet archive |
| Reverse depends: | diffEq |
Please use the canonical form https://CRAN.R-project.org/package=deTestSet to link to this page.