exists

How do I prove the simplified Chinese Remainder Theorem?

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've managed to prove Theorem modulo_inv : forall m n : Z, rel_prime m n -> exists x : Z, (m * x == 1 [n]). Admitted. My question is how to finish the following proof (maybe using the modulo_inv theorem?): Variables m n : Z. Hypothesis co_prime : rel_prime m n. Theorem SimpleChineseRemainder : forall a b : Z, exists x : Z, (x == a [m]) /\ (x == b [n]). Here is what I tried, but I don't know whether it is correct or not. Proof. intros a b. exists ((a * n) * (n ^ (-1) mod m) + (b * m) * (m ^ (-1) mod n)). refine (conj _ _). (* case : ((a * n)

What does the /private prefix on an iOS file path indicate?

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a bug when my app runs on the iPhone but not when it runs on the simulator. I was using the length of the home directory path to extract the relative path of a file in /Documents. Unfortunately this doesn't always work correctly on the iPhone because the prefix "/private" is being added to the home path. However, with or without the prefix, the same file is referenced ok. The following code demonstrates this inconsistency. What is the purpose of "/private" and when is it supplied by iOS? - (IBAction)testHomepath:(id)sender {

Create Django model or update if exists

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to create a model object, like Person, if person's id doesn't not exist, or I will get that person object. The code to create a new person as following: class Person(models.Model): identifier = models.CharField(max_length = 10) name = models.CharField(max_length = 20) objects = PersonManager() class PersonManager(models.Manager): def create_person(self, identifier): person = self.create(identifier = identifier) return person But I don't know where to check and get the existing person object. 回答1: If you're looking for "update if

Oracle: If Table Exists

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm writing some migration scripts for an Oracle database, and was hoping Oracle had something similar to MySQL's IF EXISTS construct. Specifically, whenever I want to drop a table in MySQL, I do something like DROP TABLE IF EXISTS `table_name`; This way, if the table doesn't exist, the DROP doesn't produce an error, and the script can continue. Does Oracle have a similar mechanism? I realize I could use the following query to check if a table exists or not SELECT * FROM dba_tables where table_name = 'table_name'; but the syntax for tying

boost::filesystem::exists crashs

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using boost 1.52, when i'm trying to get a file from a network drive that i don't have permissions to read from. I get an exception, after using boost::filesystem::exists(fileName) Is there a work around nicer than just doing try, catch at every place? I have switched back for my old code for now: bool FileExists(const char* fileName) { struct stat my_stat; return (stat(fileName, &my_stat) == 0); } //boost Exists throws exception if there are no permissions for share folder bool FileExists(const std::string& fileName) { return FileExists

How to know if DB exists from within Rake task

匿名 (未验证) 提交于 2019-12-03 01:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do i find out if the database exists from within a rake task? that is, i'd like to do something like: task :drop_and_create => :environment do Rails.env = "development" if (db_exists?) Rake::Task["db:drop"].invoke end Rake::Task["db:create"].invoke #more stuff... end how do i write the db_exists? condition? 回答1: How about instead doing a begin/rescue: task :drop_and_create => :environment do Rails.env = "development" if (db_exists?) begin Rake::Task["db:drop"].invoke rescue Exception => e logger.debug("Error:#{e}") Rake::Task["db:create"

SQL Server to VB.Net IF EXISTS needs to return anything, but doesn't

匿名 (未验证) 提交于 2019-12-03 01:01:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have this: IF EXISTS ( SELECT 1 FROM User_Passwords WHERE up_Password = @CurrentPassword ) PRINT 'Bad Password' -- RETURN TRUE ELSE From what I'm running into, I need my SP to return something, a 1 or 0, or a string/varchar, so I can do some work on the VB side. But as of right now, it's not returning anything, unless I'm not calling it correctly. This is the VB code: Public Function UpdatePasswords () Dim objCommand As New SqlCommand ( "Update_Passwords" , DatabaseInterface_ . Connection ) objCommand . CommandType = CommandType

SQLAlchemy, array_agg, and matching an input list

匿名 (未验证) 提交于 2019-12-03 01:01:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am attempting to use SQLAlchemy more fully, rather than just falling back to pure SQL at the first sign of distress. In this case, I have a table in a Postgres database (9.5) which stores a set of integers as a group by associating individual items atom_id with a group identifier group_id . Given a list of atom_ids , I'd like to be able to figure out which group_id , if any, that set of atom_ids belong to. Solving this with just the group_id and atom_id columns was straightforward. Now I'm trying to generalize such that a 'group' is made

regex to grab text if code exists

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I m trying to build a regex to add the code value if codename exists say an example: {( en56 ), ( sc45 ), ( da77 ), ( cd29 )} {( en56 ), ( sc45 ), ( cd29 )} i will write a regex like {[(]en(?<en>\d{2}).*[(]sc(?<sc>\d{2}).*[(]da(?<da>\d{2}).*[(]cd(?<cd>\d{2}).* i will grab the first line anyway as it matches and the results of marks will be extracted. how to keep da as optional if the input comes without it. when i tried with ? , it basically eliminates the values from first result {[(]en(?<en>\d{2}).*[(]sc(?<sc>\d{2}).*([(]da(?<da>

Ansible - Check if string exists in file

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm very new to Ansible Is it possible to check if a string exists in a file using Ansible. I want to check is a user has access to a server. this can be done on the server using cat /etc/passwd | grep username but I want Ansible to stop if the user is not there. I have tried to use the lineinfile but can't seem to get it to return. code - name: find lineinfile: dest=/etc/passwd regexp=[user] state=present line="user" The code above adds user to the file if he is not there. All i want to do is check. I don't want to modify the file in any