rules

Limit number of files in a firebase storage path

蓝咒 提交于 2019-12-01 08:48:31
I want to limit the number of files that a user can upload to a firebase storage path. Here is my firebase storage rule: service firebase.storage { match /b/jobsdbn.appspot.com/o { match /images/Business/{userId}/{imageId} { allow read allow write: if request.auth.uid == userId && (request.resource == null || ( (list(/images/Business/$(username)).size() <= 5) && imageId.size() < 50 && request.resource.size < 10 * 1024 * 1024 && request.resource.contentType.matches('image/.*'))) } } } I have added list(/images/Business/$(username)).size() <= 5 from this article: https://groups.google.com/forum/

Using Rule to Insert Into Secondary Table Auto-Increments Sequence

夙愿已清 提交于 2019-12-01 03:38:18
问题 To automatically add a column in a second table to tie it to the first table via a unique index, I have a rule such as follows: CREATE OR REPLACE RULE auto_insert AS ON INSERT TO user DO ALSO INSERT INTO lastlogin (id) VALUES (NEW.userid); This works fine if user.userid is an integer. However, if it is a sequence (e.g., type serial or bigserial ), what is inserted into table lastlogin is the next sequence id. So this command: INSERT INTO user (username) VALUES ('john'); would insert column [1

Working with multiple source file extensions in a makefile

牧云@^-^@ 提交于 2019-12-01 01:14:15
问题 I have a c++ project with various extensions for the source files (.cpp, .c, .cc) and various extensions for the header files (.hpp, .h, .hh). The source files are located in a directory called SRC, and the header files are predictably in a directory called INC. I would like to compile the source with a rule like vpath %.c $(SRC) %.o: %.c $(COMPILER) $(FLAGS) $< $(INCFLAG)$(INC) This of course works if I know the source file will be of the form %.c, but in the case of multiple possible file

Postgresql - Clean way to insert records if they don't exist, update if they do

◇◆丶佛笑我妖孽 提交于 2019-11-30 22:33:41
Here's my situation. I have a table with a bunch of URLs and crawl dates associated with them. When my program processes a URL, I want to INSERT a new row with a crawl date. If the URL already exists, I want to update the crawl date to the current datetime. With MS SQL or Oracle I'd probably use a MERGE command for this. With mySQL I'd probably use the ON DUPLICATE KEY UPDATE syntax. I could do multiple queries in my program, which may or may not be thread safe. I could write a SQL function which has various IF...ELSE logic. However, for the sake of trying out Postgres features I've never used

Java date iterator factory, with rules specifying how to calculate the intervals

夙愿已清 提交于 2019-11-30 14:12:51
问题 I am looking for a Java class where I can specify a set of date rules, such as "every 3rd sunday" and "the first occurrence of a monday every second month". I want to be able to get something like an infinite iterator out of it (.next() would return the next date matching the rules set). I think I'd be able to build it myself - but calendars are a hassle, and it feels like something similar should exist already. I hate being the one to reinvent a crappier wheel. Is anyone aware of something

C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

纵然是瞬间 提交于 2019-11-30 07:45:00
问题 Not found it in StyleCop Help Manual, on SO and Google so here it is ;) During StyleCop use I have a warning: SA1121 - UseBuiltInTypeAlias - Readability Rules The code uses one of the basic C# types, but does not use the built-in alias for the type. Rather than using the type name or the fully-qualified type name, the built-in aliases for these types should always be used: bool, byte, char, decimal, double, short, int, long, object, sbyte, float, string, ushort, uint, ulong. so String.Empty

Rules engine for .NET

荒凉一梦 提交于 2019-11-29 21:29:11
We have a business requirement to let power users edit rules for insurance rates and enrollments. We need a web ui that lets them say "this product is only for people <55 unless they are from Texas and own a poodle" or whatever. Edit for clarification: Insurance is insane. The rules differ from product to product, state to state and change constantly. We looked at a couple of rules engines but the commercial ones are 100K+ and the open source ones don't seem um, finished. Windows Workflow works if we create the rules ahead of time, but building them at runtime seems to require bypassing code

prevent “delete and update” a child in firebase

我与影子孤独终老i 提交于 2019-11-29 17:30:40
I see that there is no way to set security rules as preventing "delete and update" for a child. ".write": "!data.exists() && newData.exists() && !newData.exists()" thats not make sense. For future reference, the Firebase console lets you test database security rules, so you can find out what works right there before you publish those rules. That being said, if I'm understanding your question correctly, you want to allow users to add to the node, but not delete or update. You'd be looking for something along the lines of: { "rules": { ... "childNodeName": { ".write": "!data.exists()" } } } You

Capitalization of Person names in programming [closed]

我是研究僧i 提交于 2019-11-29 09:13:21
Is anyone aware of some code/rules on how to capitalize the names of people correctly? John Smith Johan van Rensburg Derrick von Gogh Ruby de La Fuente Peter Maclaurin Garry McDonald (these may not be correct, just some sample names and how the capitalization could be/work) This seems like a losing battle... If anyone has some code or rules on when and how to capitalize names, let me know :) Cheers, Albert The only sensible way to handle it, in my opinion, is to let the users tell you how their name should be capitalized. Any automatic scheme is going to annoy someone. Just tell them you're

C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

早过忘川 提交于 2019-11-29 05:24:50
Not found it in StyleCop Help Manual, on SO and Google so here it is ;) During StyleCop use I have a warning: SA1121 - UseBuiltInTypeAlias - Readability Rules The code uses one of the basic C# types, but does not use the built-in alias for the type. Rather than using the type name or the fully-qualified type name, the built-in aliases for these types should always be used: bool, byte, char, decimal, double, short, int, long, object, sbyte, float, string, ushort, uint, ulong. so String.Empty is wrong (depend on above rules) and string.Empty is good. Why using built-in aliases is better? Can