qid
int64
1
74.6M
question
stringlengths
45
24.2k
date
stringlengths
10
10
metadata
stringlengths
101
178
response_j
stringlengths
32
23.2k
response_k
stringlengths
21
13.2k
230,343
I asked a question here [how can i see if my data are coming from two different population?](https://stats.stackexchange.com/questions/230255/how-can-i-see-if-my-data-are-coming-from-two-different-population) and seems like I cannot correctly communicate and the person who is writing to me is making me confused. So I try to explain what I want , if you know any method, please just tell me the method, I will try to do it myself. I have two groups **Group A** with **n** number of **samples** **Group B** with **m** number of **samples** The measurements have replicate I want to see if the Group A is different from Group B. for example by the mean, or whatever else which makes statistically different or not different. Is there someone who can really guide me what to do? Many thanks Nik
2016/08/17
['https://stats.stackexchange.com/questions/230343', 'https://stats.stackexchange.com', 'https://stats.stackexchange.com/users/127951/']
From reading your previous post, I see that you have two groups with 15 subjects, each with multiple observations (3 each). Each subject appears in each group, except subject 15 who has 0 observation in group 1. So, basically, you have a paired design. A way to test whether Group 1 and Group 2 are different is by using a paired wilcoxon signed rank sum test. In R, this can be done using the following code: ``` df<- structure(list(Group = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Subject = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 11L, 11L, 11L, 12L, 12L, 12L, 13L, 13L, 13L, 14L, 14L, 14L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 11L, 11L, 11L, 12L, 12L, 12L, 13L, 13L, 13L, 14L, 14L, 14L, 15L, 15L, 15L), Value = c(29.89577946, 29.51885854, 29.77429604, 33.20695108, 32.09027292, 31.90909894, 30.88358173, 30.67547731, 30.82494595, 31.70128247, 31.57217504, 31.61359752, 30.51371055, 30.42241945, 30.44913954, 26.90850496, 0, 0, 0, 0, 0, 28.94047335, 29.27188604, 29.78511206, 28.18475423, 27.54266717, 26.99873401, 29.26941344, 28.50457189, 28.78050443, 31.39038527, 31.19237052, 30.74053275, 28.68618888, 28.42109545, 28.58222544, 28.99337177, 29.31797, 28.4541501, 28.18475423, 27.54266717, 26.99873401, 28.07576794, 28.96344894, 28.48358437, 27.02527663, 27.1308483, 26.96091103, 27.04019758, 27.51900858, 28.14559621, 26.83569136, 26.90724462, 26.82675, 0, 0, 0, 27.62449786, 26.82335228, 26.66925534, 0, 25.81254792, 26.61666776, 26.12545858, 0, 0, 0, 0, 0, 28.84580419, 29.11003424, 29.24723895, 28.72919768, 29.70673437, 29.31274377, 30.73133587, 30.44805655, 30.61561583, 27.06896964, 27.04249553, 27.15990629, 31.54738209, 31.51643714, 31.8055509, 31.291867, 31.89146186, 31.65812735)), .Names = c("Group", "Subject", "Value"), class = "data.frame", row.names = c(NA, -87L)) df$Value[df$Value == 0] <- NA df[is.na(df$Value),] ## missing data table(df$Group, df$Subject) ## check to see if all groups have equal obs ## perform wilcoxon signed rank sum test wilcox.test(formula = Value ~ Group, data = df[!df$Subject == 15,]) ## omit the 15th patient Wilcoxon rank sum test with continuity correction data: Value by Group W = 900, p-value = 0.0006732 alternative hypothesis: true location shift is not equal to 0 Warning message: In wilcox.test.default(x = c(29.89577946, 29.51885854, 29.77429604, : cannot compute exact p-value with ties ## we can reject the null hypothesis that both groups are equal ``` From the R documentation, > > If exact p-values are available, an exact confidence interval is obtained by the algorithm described in Bauer (1972), and the Hodges-Lehmann estimator is employed. Otherwise, the returned confidence interval and point estimate are based on normal approximations. These are continuity-corrected for the interval but not the estimate (as the correction depends on the alternative). > > >
For comparing means of populations with different samples, the standard practice is applying a two-sample location test. Depending on the size of your data, you could implement either a t-test or a z-test (t-test is recommended for smaller sample sizes). In any case, since you want to find out if the groups are *different*, a two-sided test would be ideal for the purpose. Since the data has different sizes, it is generally accepted that a Welch's test is the best way of performing such comparison. The Welch's test assumes unequal variances, an assumption you could test yourself. In case you have reasons to believe that the variances are equal instead, it is recommended that you use a *paired* t-test. In R, assuming your data is stored un vectors `x` and `y` ``` #Welch's t-test t.test(x,y) #paired sample test t.test(x,y, paired = TRUE) #test for equality of variances var.test(x,y) ```
230,343
I asked a question here [how can i see if my data are coming from two different population?](https://stats.stackexchange.com/questions/230255/how-can-i-see-if-my-data-are-coming-from-two-different-population) and seems like I cannot correctly communicate and the person who is writing to me is making me confused. So I try to explain what I want , if you know any method, please just tell me the method, I will try to do it myself. I have two groups **Group A** with **n** number of **samples** **Group B** with **m** number of **samples** The measurements have replicate I want to see if the Group A is different from Group B. for example by the mean, or whatever else which makes statistically different or not different. Is there someone who can really guide me what to do? Many thanks Nik
2016/08/17
['https://stats.stackexchange.com/questions/230343', 'https://stats.stackexchange.com', 'https://stats.stackexchange.com/users/127951/']
When thinking about a statistical problem, you should ask yourself what experiment you have. You have two groups, with different sample size. You can calculate arithmetic mean over all your replicates. You will be able to use the means for comparison. 1:) Check if you can assume normality. Because your data is simple, you can just do a simple QQ plot or histogram. 2:) If you can assume normality, you should use paired t-test. 3:) If you can't assume normality, you should Wilcox signed-rank test
For comparing means of populations with different samples, the standard practice is applying a two-sample location test. Depending on the size of your data, you could implement either a t-test or a z-test (t-test is recommended for smaller sample sizes). In any case, since you want to find out if the groups are *different*, a two-sided test would be ideal for the purpose. Since the data has different sizes, it is generally accepted that a Welch's test is the best way of performing such comparison. The Welch's test assumes unequal variances, an assumption you could test yourself. In case you have reasons to believe that the variances are equal instead, it is recommended that you use a *paired* t-test. In R, assuming your data is stored un vectors `x` and `y` ``` #Welch's t-test t.test(x,y) #paired sample test t.test(x,y, paired = TRUE) #test for equality of variances var.test(x,y) ```
4,490,227
Does anyone know how to build automatic tagging (blog post/document) algorithm? Any example will be appreciated.
2010/12/20
['https://Stackoverflow.com/questions/4490227', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/548690/']
Heroku creates a database for each application deployed to it (no need to run `heroku rake db:create`. Here are the commands you should be using to deploy a Rails application to Heroku: ``` git init git add . git commit -m "initial import" heroku create git push heroku master heroku rake db:migrate heroku open ```
I believe Heroku creates a new database.yml for you on deploy if you have no production according to the [Docs](http://groups.google.com/group/heroku/browse_thread/thread/cfa3ad5263a9e967?pli=1).
4,490,227
Does anyone know how to build automatic tagging (blog post/document) algorithm? Any example will be appreciated.
2010/12/20
['https://Stackoverflow.com/questions/4490227', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/548690/']
It's not telling you that you have no Database. It's telling you that it can't find a specific record ``` (Couldn't find Drummer with ID=1): ``` It's likely that you have code that's doing `Drummer.find(1)` and that doesn't exist on your production environment. Recommend you either: * create a seeds file (heroku rake db:seed) [rails cast](http://railscasts.com/episodes/179-seed-data) * push your entire database to heroku (heroku db:push) [make sure you understand this will wipe out your production database]
Heroku creates a database for each application deployed to it (no need to run `heroku rake db:create`. Here are the commands you should be using to deploy a Rails application to Heroku: ``` git init git add . git commit -m "initial import" heroku create git push heroku master heroku rake db:migrate heroku open ```
4,490,227
Does anyone know how to build automatic tagging (blog post/document) algorithm? Any example will be appreciated.
2010/12/20
['https://Stackoverflow.com/questions/4490227', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/548690/']
It's not telling you that you have no Database. It's telling you that it can't find a specific record ``` (Couldn't find Drummer with ID=1): ``` It's likely that you have code that's doing `Drummer.find(1)` and that doesn't exist on your production environment. Recommend you either: * create a seeds file (heroku rake db:seed) [rails cast](http://railscasts.com/episodes/179-seed-data) * push your entire database to heroku (heroku db:push) [make sure you understand this will wipe out your production database]
I believe Heroku creates a new database.yml for you on deploy if you have no production according to the [Docs](http://groups.google.com/group/heroku/browse_thread/thread/cfa3ad5263a9e967?pli=1).
36,534,043
Given day in week (let's say Monday), I need to find closest date (in future) to given date (for example 9-4-2016) which is this day in week (for these examples, it should be 11-4-2016).
2016/04/10
['https://Stackoverflow.com/questions/36534043', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1767332/']
This is a pure Ruby solution. ``` require 'date' d = Date.strptime('9-4-2016', '%d-%m-%Y') #=> #<Date: 2016-04-09 ((2457488j,0s,0n),+0s,2299161j)> d + (1 - d.wday) % 7 #=> #<Date: 2016-04-11 ((2457490j,0s,0n),+0s,2299161j)> ``` `1` is Monday's offset. `d.wday #=> 6`. I have assumed that if the date falls on a Monday, the "closest" Monday is the same day. If it is to be the following Monday, use: ``` d + (d.wday == 1) ? 7 : (1 - d.wday) % 7 ```
You can find this date in the nearest week of your `date`: ``` date = Date.parse('9-4-2016') (date..date + 6).find {|d| d.strftime("%A") == "Monday"} #=> Mon, 11 Apr 2016 ```
4,030,546
I'm developing a football manager website, but I can't figure out how to use properly the background-thread plugin and Quartz plugin (there is no much docs). My problem is.. I have a Controller of a Match class, with a function that I need to start at some time. With quartz I have tried to create a job but then I cannot call directly the function (and how many job should I create if I have more match to start?) or I don't know how to do it, and with background-thread I create the service class but then I have no idea how to implement it. Someone Can help me with this? Thanks **EDIT:** **Solution in this post:** [grails thread -> hibernateException: No Hibernate session bound to thread](https://stackoverflow.com/questions/4088259/grails-thread-hibernateexception-no-hibernate-session-bound-to-thread)
2010/10/27
['https://Stackoverflow.com/questions/4030546', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/488413/']
(March 2012) It looks like this is finally going to be possible soon -- git 1.7.10 is going to support this syntax in `.gitconfig`: ``` [include] path = /path/to/file ``` See [here](https://github.com/gitster/git/commit/9b25a0b52e09400719366f0a33d0d0da98bbf7b0) for a detailed description of the git change and its edge cases. By the way, a couple of subtleties worth pointing out: 1. Path expansion, e.g. `~` or `$HOME`, does not appear to be supported. 2. If a relative path is specified, then it is relative to the .gitconfig file that has the `[include]` statement. This works correctly even across chained includes -- e.g. `~/.gitconfig` can have: ``` [include] path = subdir/gitconfig ``` and `subdir/gitconfig` can have: ``` [include] path = nested_subdir/gitconfig ``` ... which will cause `subdir/nested_subdir/gitconfig` to be loaded. 3. If git can't find the target file, it silently ignores the error. This appears to be by design.
(March 2012): As mentioned in [Mike Morearty](https://stackoverflow.com/users/179675/mike-morearty)'s [answer](https://stackoverflow.com/a/9733336/6309) (which I upvoted), git 1.7.10+ will support this feature. --- Original answer (October 2010): Currently, no. As I mentioned in [Is it possible to include a file in your `.gitconfig`](https://stackoverflow.com/questions/1557183/is-it-possible-to-include-a-file-in-your-gitconfig), you already have 3 separate gitconfig for you to get your settings organized: ``` $GIT_DIR/config ``` > > Repository specific configuration file. (The filename is of course relative to the repository root, not the working directory.) > > > ``` ~/.gitconfig ``` > > User-specific configuration file. Also called "global" configuration file. > > > ``` $(prefix)/etc/gitconfig ``` > > System-wide configuration file > > > Config File inclusion was discussed in May 2010, and a [first patch was written](http://kerneltrap.org/mailarchive/git/2010/5/6/29891) by Ævar Arnfjörð Bjarmason, but I don't see this patch in one of the latest "[what's cooking in Git](http://permalink.gmane.org/gmane.comp.version-control.git/159023)".
71,266,586
I try to see when I click navbar then I want to see the topic, but it is showing the topic under navbar. I try to give margin, but it doesn't work. Is someone help me with how can I solve this problem. [Web site showing like that](https://i.stack.imgur.com/g4vki.png) [But I want to see like that](https://i.stack.imgur.com/WcN46.png) ``` there is code: https://codepen.io/rero34/pen/mdqGyVo ```
2022/02/25
['https://Stackoverflow.com/questions/71266586', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14349341/']
Here is a generator which meets your requirements: ``` def dict_generator(dictionary, previous=None): previous = previous[:] if previous else [] if isinstance(dictionary, dict): for key, value in dictionary.items(): if isinstance(value, dict): for d in dict_generator(value, previous + [key]): yield d elif isinstance(value, list) or isinstance(value, tuple): for k,v in enumerate(value): for d in dict_generator(v, previous + [key] + [[k]]): yield d else: yield previous + [key, value] else: yield previous + [dictionary] mydict ={'foo': {'foo1': [1,2,3], 'foo2': 1}} print(list(dict_generator(mydict))) ``` Will produce output like this: ``` [['foo', 'foo1', [0], 1], ['foo', 'foo1', [1], 2], ['foo', 'foo1', [2], 3], ['foo', 'foo2', 1]] ```
Preparation: ------------ [`jsonpath-ng`](https://github.com/h2non/jsonpath-ng) can parse even such a nested json object very easily. It can be installed by the following command: ```sh pip install --upgrade jsonpath-ng ``` Code: ----- ```py import jsonpath_ng as jp # Create the sample json data = {"Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder":{ "CoopRoomDifficultySetups": [ { "RoomDifficulties": [ { "Id" : 510, "IsEnabled" : 1, "AvailableRegions" : [ ], "Weight" : 1, "MinLevel" : 60, "MaxLevel" : 69, "MinFriendsLevel" : 50, "MaxFriendsLevel" : 99, "MinPunishLevel" : 0, "MaxPunishLevel" : 0, "MinHardCP" : "0", "MinCP" : "0", "MaxCP" : "0", "MaxHardCP" : "0", "LowPowerBonus" : 0.5, "LowPowerCp" : "0", "LowPowerLevel" : 90, "Maps" : [ { "MapId" : 4, "NpcPreset" : "NPCPresetMap5Coop3", "TypesLimit" : 1000, "TierSpawnProbabilities" : [ { "Tier" : 0, "SpawnProbability" : 0.6 }, { "Tier" : 1, "SpawnProbability" : 0.75 }, { "Tier" : 2, "SpawnProbability" : 0.52 }, { "Tier" : 3, "SpawnProbability" : 0.6 } ], "ChampionProbabilityTier2" : 0.1, "ChampionProbabilityTier3" : 0.08, "PlayersWhenMaxProbabilityTier2" : 3, "PlayersWhenMaxProbabilityTier3" : 6, "NpcLevelMultiplier" : 1.15, "MapWeight" : 1, "PointsNpcMultiplier" : 0.85, "XpNpcMultiplier" : 0.85, "ScoreNpcMultiplier" : 0.85, "NpcMinLevel" : 63, "NpcMaxLevel" : 77 } ], "TimeOfDayMode_Parsable" : 0 }]},[{"foo":"foo"}]]}} # Define a dictionary d = {} # Define an expression to parse the json object expr = jp.parse('$..*') for m in expr.find(data): # Show a json path print(str(m.full_path)) # Update the dictionary d[str(m.full_path)] = m.value # Show an example value in the dictionary key = 'Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].NpcMaxLevel' print(d[key]) ``` Output: ------- ``` Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Id Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].IsEnabled Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].AvailableRegions Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Weight Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MinLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MaxLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MinFriendsLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MaxFriendsLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MinPunishLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MaxPunishLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MinHardCP Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MinCP Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MaxCP Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].MaxHardCP Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].LowPowerBonus Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].LowPowerCp Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].LowPowerLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].TimeOfDayMode_Parsable Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].MapId Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].NpcPreset Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TypesLimit Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].ChampionProbabilityTier2 Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].ChampionProbabilityTier3 Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].PlayersWhenMaxProbabilityTier2 Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].PlayersWhenMaxProbabilityTier3 Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].NpcLevelMultiplier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].MapWeight Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].PointsNpcMultiplier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].XpNpcMultiplier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].ScoreNpcMultiplier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].NpcMinLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].NpcMaxLevel Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[0].Tier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[0].SpawnProbability Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[1].Tier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[1].SpawnProbability Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[2].Tier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[2].SpawnProbability Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[3].Tier Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[0].RoomDifficulties.[0].Maps.[0].TierSpawnProbabilities.[3].SpawnProbability Assets/CustomGameData/Resources/Configs/RoomDifficulty/RoomDifficultySetupHolder.CoopRoomDifficultySetups.[1].[0].foo ``` and ``` 77 ```
71,266,586
I try to see when I click navbar then I want to see the topic, but it is showing the topic under navbar. I try to give margin, but it doesn't work. Is someone help me with how can I solve this problem. [Web site showing like that](https://i.stack.imgur.com/g4vki.png) [But I want to see like that](https://i.stack.imgur.com/WcN46.png) ``` there is code: https://codepen.io/rero34/pen/mdqGyVo ```
2022/02/25
['https://Stackoverflow.com/questions/71266586', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14349341/']
Here is a generator which meets your requirements: ``` def dict_generator(dictionary, previous=None): previous = previous[:] if previous else [] if isinstance(dictionary, dict): for key, value in dictionary.items(): if isinstance(value, dict): for d in dict_generator(value, previous + [key]): yield d elif isinstance(value, list) or isinstance(value, tuple): for k,v in enumerate(value): for d in dict_generator(v, previous + [key] + [[k]]): yield d else: yield previous + [key, value] else: yield previous + [dictionary] mydict ={'foo': {'foo1': [1,2,3], 'foo2': 1}} print(list(dict_generator(mydict))) ``` Will produce output like this: ``` [['foo', 'foo1', [0], 1], ['foo', 'foo1', [1], 2], ['foo', 'foo1', [2], 3], ['foo', 'foo2', 1]] ```
What almost helped me completely is that piece of code <https://stackoverflow.com/a/59186999/18018783> ``` def dict_generator(indict, pre=None): pre = pre[:] if pre else [] if isinstance(indict, dict): for key, value in indict.items(): if isinstance(value, dict): for d in dict_generator(value, pre + [key]): yield d elif isinstance(value, list) or isinstance(value, tuple): for k,v in enumerate(value): for d in dict_generator(v, pre + [key] + [k]): yield d else: yield pre + [key, value] else: yield indict ``` However still there is one exception when it doesn't work as I wish for example when this structure is given ``` { "foo":{ "foo1": [1,2,3], "foo2": 1 } ``` } the output of `dict_generator` will be ``` [1, 2, 3, ['foo', 'foo2', 1]] ``` so it doesn't give me a path to the key that has a list as an value since my desired output should look that way: ``` [['foo', 'foo1', [0], 1], ['foo', 'foo2', [1], 2], ['foo', 'foo2, [2], 3], ['foo', 'foo2', 1]]] ```
38,659,730
We have an extremely large nvarchar(max) field that contains html. Within this html is an img tag. Example: ``` <img style="float:right" src="data:image/png;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/7gAOQW.... ``` The length of this column is 1645151, although what is being replace is a bit less than this, but not a lot. What we are trying to do, is a replace in SQL on the column: ``` declare @url varchar(50) = 'myimageurl'; UPDATE table SET field = CAST(REPLACE(CAST(field as NVARCHAR(MAX)),@source,'@url') AS NVARCHAR(MAX)) ``` Where @source, is the above image bytes as string, which are assigned to an nvarchar(max) variable before running the replace. and dest is the url of an image, rather than the images bytes as string. Although I still get the message string or binary data would be truncated. Does anyone know if this is possible in SQL to replace strings as large as this.
2016/07/29
['https://Stackoverflow.com/questions/38659730', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1192535/']
I had the same error, but on a different function. The fault was that my pattern has longer than my expression, which means that your search pattern will be truncated. I hope this helps someone. Also, make sure you put pattern and expression in the right location of your function.
Instead of doing the replace, can you rebuilt the entire field by parsing out the rest of the img tag? Something like: ``` declare @Field nvarchar(max) = '<img style="float:right" src="data:image/png;base64,/9j/4AAQSkZJRgA....BAQEBLAEsAAD/7gAOQW" />' declare @Source nvarchar(max) = 'data:image/png;base64,/9j/4AAQSkZJRgA....BAQEBLAEsAAD/7gAOQW' declare @URL nvarchar(max) = 'www.img.img/img.png' declare @Chars int = 20 select left(@Field,patindex('%' + left(@Source,@Chars) + '%', @Field) - 1) as HTMLStart ,@URL as ImgURL ,right(@Field,len(@Field) - patindex('%' + right(@Source,@Chars) + '%', @Field) - @Chars + 1) as HTMLEnd ``` If you were wanting to run this on a whole dataset at once, you would simply need to look for the `src="data:image/png;base64,` element and work backwards from there using a similar methodology to the above. Depends on how you are identifying which binary data to replace and what to replace it with.
13,630,967
I found two bubble algorithms but I not sure which one is right... First example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1 - i; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` Second example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` [**Wikipedia Example**](http://en.wikipedia.org/wiki/Bubble_sort) ----------------------------------------------------------------- For input: 5 1 4 2 8 First example: 6 comparisons Second example: 12 comparisons > > **First Pass:** > > > ( **5 1** 4 2 8 ) --> ( **1 5** 4 2 8 ), Swap since 5 > 1 > > > ( 1 **5 4** 2 8 ) --> ( 1 **4 5** 2 8 ), Swap since 5 > 4 > > > ( 1 4 **5 2** 8 ) --> ( 1 4 **2 5** 8 ), Swap since 5 > 2 > > > ( 1 4 2 **5 8** ) --> ( 1 4 2 **5 8** ) > > > **Second Pass:** > > > ( **1 4** 2 5 8 ) --> ( **1 4** 2 5 8 ) > > > ( 1 **4 2** 5 8 ) --> ( 1 **2 4** 5 8 ), Swap since 4 > 2 **<-- Example 1 stop here** > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) > > > **Third Pass** > > > ( **1 2** 4 5 8 ) --> ( **1 2** 4 5 8 ) > > > ( 1 **2 4** 5 8 ) --> ( 1 **2 4** 5 8 ) > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) **<-- Example 2 stop here** > > > Edit: when I say which one is right I mean which one is the original bubble sort
2012/11/29
['https://Stackoverflow.com/questions/13630967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1424127/']
First algorithm is incorrect. It will fail if last element in the array is not the greatest. Specifically, iteration on 'j': ``` for (int j = 0; j < input.Length - 1 - i; j++) ``` seems to skip last element. If your input is {0, 2, 2, 1} Then your input.Length = 4 for loop above will have condition j < 4 - 1 - i, where i = 1 so j < 4 - 1 - 1, so j < 2 so last j used will be j = 1, last comparison will be input[1] > input[2] -> input[3] is never compared. you can fix it by changing for loop to j <= input.Length - 1 - i
*I found two bubble algorithms but I not sure which one is right..* I'm sure they're both right. The only difference is your second code has to loop through the sorted array one last time.
13,630,967
I found two bubble algorithms but I not sure which one is right... First example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1 - i; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` Second example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` [**Wikipedia Example**](http://en.wikipedia.org/wiki/Bubble_sort) ----------------------------------------------------------------- For input: 5 1 4 2 8 First example: 6 comparisons Second example: 12 comparisons > > **First Pass:** > > > ( **5 1** 4 2 8 ) --> ( **1 5** 4 2 8 ), Swap since 5 > 1 > > > ( 1 **5 4** 2 8 ) --> ( 1 **4 5** 2 8 ), Swap since 5 > 4 > > > ( 1 4 **5 2** 8 ) --> ( 1 4 **2 5** 8 ), Swap since 5 > 2 > > > ( 1 4 2 **5 8** ) --> ( 1 4 2 **5 8** ) > > > **Second Pass:** > > > ( **1 4** 2 5 8 ) --> ( **1 4** 2 5 8 ) > > > ( 1 **4 2** 5 8 ) --> ( 1 **2 4** 5 8 ), Swap since 4 > 2 **<-- Example 1 stop here** > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) > > > **Third Pass** > > > ( **1 2** 4 5 8 ) --> ( **1 2** 4 5 8 ) > > > ( 1 **2 4** 5 8 ) --> ( 1 **2 4** 5 8 ) > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) **<-- Example 2 stop here** > > > Edit: when I say which one is right I mean which one is the original bubble sort
2012/11/29
['https://Stackoverflow.com/questions/13630967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1424127/']
First algorithm is incorrect. It will fail if last element in the array is not the greatest. Specifically, iteration on 'j': ``` for (int j = 0; j < input.Length - 1 - i; j++) ``` seems to skip last element. If your input is {0, 2, 2, 1} Then your input.Length = 4 for loop above will have condition j < 4 - 1 - i, where i = 1 so j < 4 - 1 - 1, so j < 2 so last j used will be j = 1, last comparison will be input[1] > input[2] -> input[3] is never compared. you can fix it by changing for loop to j <= input.Length - 1 - i
Both are right. First one is comparatively more efficient.
13,630,967
I found two bubble algorithms but I not sure which one is right... First example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1 - i; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` Second example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` [**Wikipedia Example**](http://en.wikipedia.org/wiki/Bubble_sort) ----------------------------------------------------------------- For input: 5 1 4 2 8 First example: 6 comparisons Second example: 12 comparisons > > **First Pass:** > > > ( **5 1** 4 2 8 ) --> ( **1 5** 4 2 8 ), Swap since 5 > 1 > > > ( 1 **5 4** 2 8 ) --> ( 1 **4 5** 2 8 ), Swap since 5 > 4 > > > ( 1 4 **5 2** 8 ) --> ( 1 4 **2 5** 8 ), Swap since 5 > 2 > > > ( 1 4 2 **5 8** ) --> ( 1 4 2 **5 8** ) > > > **Second Pass:** > > > ( **1 4** 2 5 8 ) --> ( **1 4** 2 5 8 ) > > > ( 1 **4 2** 5 8 ) --> ( 1 **2 4** 5 8 ), Swap since 4 > 2 **<-- Example 1 stop here** > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) > > > **Third Pass** > > > ( **1 2** 4 5 8 ) --> ( **1 2** 4 5 8 ) > > > ( 1 **2 4** 5 8 ) --> ( 1 **2 4** 5 8 ) > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) **<-- Example 2 stop here** > > > Edit: when I say which one is right I mean which one is the original bubble sort
2012/11/29
['https://Stackoverflow.com/questions/13630967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1424127/']
First algorithm is incorrect. It will fail if last element in the array is not the greatest. Specifically, iteration on 'j': ``` for (int j = 0; j < input.Length - 1 - i; j++) ``` seems to skip last element. If your input is {0, 2, 2, 1} Then your input.Length = 4 for loop above will have condition j < 4 - 1 - i, where i = 1 so j < 4 - 1 - 1, so j < 2 so last j used will be j = 1, last comparison will be input[1] > input[2] -> input[3] is never compared. you can fix it by changing for loop to j <= input.Length - 1 - i
without doing too much thinking, It looks like they're both correct, but the first one seems to do less redundant operations, and therefore takes less time to execute The first seems to depend on the fact that your last i blocks are correct, therefore it doesn't even bother with them.
13,630,967
I found two bubble algorithms but I not sure which one is right... First example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1 - i; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` Second example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` [**Wikipedia Example**](http://en.wikipedia.org/wiki/Bubble_sort) ----------------------------------------------------------------- For input: 5 1 4 2 8 First example: 6 comparisons Second example: 12 comparisons > > **First Pass:** > > > ( **5 1** 4 2 8 ) --> ( **1 5** 4 2 8 ), Swap since 5 > 1 > > > ( 1 **5 4** 2 8 ) --> ( 1 **4 5** 2 8 ), Swap since 5 > 4 > > > ( 1 4 **5 2** 8 ) --> ( 1 4 **2 5** 8 ), Swap since 5 > 2 > > > ( 1 4 2 **5 8** ) --> ( 1 4 2 **5 8** ) > > > **Second Pass:** > > > ( **1 4** 2 5 8 ) --> ( **1 4** 2 5 8 ) > > > ( 1 **4 2** 5 8 ) --> ( 1 **2 4** 5 8 ), Swap since 4 > 2 **<-- Example 1 stop here** > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) > > > **Third Pass** > > > ( **1 2** 4 5 8 ) --> ( **1 2** 4 5 8 ) > > > ( 1 **2 4** 5 8 ) --> ( 1 **2 4** 5 8 ) > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) **<-- Example 2 stop here** > > > Edit: when I say which one is right I mean which one is the original bubble sort
2012/11/29
['https://Stackoverflow.com/questions/13630967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1424127/']
First algorithm is incorrect. It will fail if last element in the array is not the greatest. Specifically, iteration on 'j': ``` for (int j = 0; j < input.Length - 1 - i; j++) ``` seems to skip last element. If your input is {0, 2, 2, 1} Then your input.Length = 4 for loop above will have condition j < 4 - 1 - i, where i = 1 so j < 4 - 1 - 1, so j < 2 so last j used will be j = 1, last comparison will be input[1] > input[2] -> input[3] is never compared. you can fix it by changing for loop to j <= input.Length - 1 - i
In a bubble sort, after the first pass, you are guaranteed that the largest value will occupy the last position in the array. This is because by definition, the bubble sort swaps the highest value toward the end of the array. This means that on the second pass, you do not need to compare the last value again, because it is guaranteed to be larger or equal to the element in the next lower index. Likewise, after pass 2, the top two elements will be the highest values and sorted relative to one another. By extension, after `i` passes, the `i` top elements will be in their correct positions. The first example takes this into account, by subtracting `i` from the maximum `j` iterator value. The second example unnecessarily compares the upper elements in subsequent passes. It doesn't hurt, but it is redundant, i.e. not *optimized*. It is still a bubble sort, because it is swapping adjacent values, moving the higher valued element toward the end of the array. Does that make sense?
13,630,967
I found two bubble algorithms but I not sure which one is right... First example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1 - i; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` Second example: ``` for (int i = 1; i < input.Length-1; i++) for (int j = 0; j < input.Length - 1; j++) if (input[j] > input[j + 1]) swap(input, j, j + 1); ``` [**Wikipedia Example**](http://en.wikipedia.org/wiki/Bubble_sort) ----------------------------------------------------------------- For input: 5 1 4 2 8 First example: 6 comparisons Second example: 12 comparisons > > **First Pass:** > > > ( **5 1** 4 2 8 ) --> ( **1 5** 4 2 8 ), Swap since 5 > 1 > > > ( 1 **5 4** 2 8 ) --> ( 1 **4 5** 2 8 ), Swap since 5 > 4 > > > ( 1 4 **5 2** 8 ) --> ( 1 4 **2 5** 8 ), Swap since 5 > 2 > > > ( 1 4 2 **5 8** ) --> ( 1 4 2 **5 8** ) > > > **Second Pass:** > > > ( **1 4** 2 5 8 ) --> ( **1 4** 2 5 8 ) > > > ( 1 **4 2** 5 8 ) --> ( 1 **2 4** 5 8 ), Swap since 4 > 2 **<-- Example 1 stop here** > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) > > > **Third Pass** > > > ( **1 2** 4 5 8 ) --> ( **1 2** 4 5 8 ) > > > ( 1 **2 4** 5 8 ) --> ( 1 **2 4** 5 8 ) > > > ( 1 2 **4 5** 8 ) --> ( 1 2 **4 5** 8 ) > > > ( 1 2 4 **5 8** ) --> ( 1 2 4 **5 8** ) **<-- Example 2 stop here** > > > Edit: when I say which one is right I mean which one is the original bubble sort
2012/11/29
['https://Stackoverflow.com/questions/13630967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1424127/']
First algorithm is incorrect. It will fail if last element in the array is not the greatest. Specifically, iteration on 'j': ``` for (int j = 0; j < input.Length - 1 - i; j++) ``` seems to skip last element. If your input is {0, 2, 2, 1} Then your input.Length = 4 for loop above will have condition j < 4 - 1 - i, where i = 1 so j < 4 - 1 - 1, so j < 2 so last j used will be j = 1, last comparison will be input[1] > input[2] -> input[3] is never compared. you can fix it by changing for loop to j <= input.Length - 1 - i
The first one is what's called optimized bubble sort <http://en.wikipedia.org/wiki/Bubble_sort#Optimizing_bubble_sort> the second one is the "classic" bubble sort.
171,510
I have developed an app that will live at `xyzdomain.com/app` on our dedicated hosting setup. My client wants the app to be accessible at `clientdomain.com/app`. What options exist for transparently proxying or redirecting requests for `clientdomain.com/app/whatever` to `xyzdomain.com/app/whatever` such that the original URL is preserved for SEO purposes? In other words, the client doesn't want `xyzdomain.com/app/whatever` appearing on Google, but would rather it show up as `clientdomain.com/app/whatever`. An ordinary frame page at the client domain is not acceptable here, as links within the frame pages would still reference `xyzdomain.com`. Edit: It sounds like I want a reverse proxy setup, but is it common or even reasonable to setup a reverse proxy that forwards requests to another server not on the same network as the proxy server? Wouldn't that cause twice the latency and double the bandwidth usage? Edit: Guys, I'm aware of the benefits of using a subdomain. That isn't possible here because the client only wants www.clientdomain.com to show up in search results. So yeah, no subdomain recommendations - it's not an option.
2010/08/17
['https://serverfault.com/questions/171510', 'https://serverfault.com', 'https://serverfault.com/users/11577/']
I only see two ways of doing this. One is to use a reverse proxy setup like you say... However, according to your description I would advise against it. The other solution is to have a server on your client reply to every request with with a HTTP 302 for the corresponding URL on the other side but again I would advise against this setup too because it would require 2 GETs for each page request and would also change the URL visible to the end user (on the address bar). How does your client feel about a subdomain like `app.clientdomain.com` instead of `clientdomain.com/app`? My recommendation is that you try to reason with your client about using a subdomain. Hope this helps.
You will need a virtual server for clientdomain.com on the dedicated hosting setup. Then the issue becomed transperently proxying the request from clientdomain.com to the dedicated server (by IP address). If clientdomain.com is not dedicated to the application, using a subdomain would be simpler. This also would need a host (virtual or otherwise) on the dedicated hosting setup.
171,510
I have developed an app that will live at `xyzdomain.com/app` on our dedicated hosting setup. My client wants the app to be accessible at `clientdomain.com/app`. What options exist for transparently proxying or redirecting requests for `clientdomain.com/app/whatever` to `xyzdomain.com/app/whatever` such that the original URL is preserved for SEO purposes? In other words, the client doesn't want `xyzdomain.com/app/whatever` appearing on Google, but would rather it show up as `clientdomain.com/app/whatever`. An ordinary frame page at the client domain is not acceptable here, as links within the frame pages would still reference `xyzdomain.com`. Edit: It sounds like I want a reverse proxy setup, but is it common or even reasonable to setup a reverse proxy that forwards requests to another server not on the same network as the proxy server? Wouldn't that cause twice the latency and double the bandwidth usage? Edit: Guys, I'm aware of the benefits of using a subdomain. That isn't possible here because the client only wants www.clientdomain.com to show up in search results. So yeah, no subdomain recommendations - it's not an option.
2010/08/17
['https://serverfault.com/questions/171510', 'https://serverfault.com', 'https://serverfault.com/users/11577/']
I only see two ways of doing this. One is to use a reverse proxy setup like you say... However, according to your description I would advise against it. The other solution is to have a server on your client reply to every request with with a HTTP 302 for the corresponding URL on the other side but again I would advise against this setup too because it would require 2 GETs for each page request and would also change the URL visible to the end user (on the address bar). How does your client feel about a subdomain like `app.clientdomain.com` instead of `clientdomain.com/app`? My recommendation is that you try to reason with your client about using a subdomain. Hope this helps.
The easiest solution is to define an domain alias within the webserver. This is much the same method that www.blah.com is the same site as blah.com. This can be configured in most major web servers (e.g. IIS and Apache). If you specify your web server technology, I might be able to supply some instructions ;)
206,311
I am trying to do an export of approx 30,000 attachments in our Salesforce Org, Would anyone have been through a similar exercise and can advise best practice or the best way / tool to do this? Kind Regards matt
2018/01/30
['https://salesforce.stackexchange.com/questions/206311', 'https://salesforce.stackexchange.com', 'https://salesforce.stackexchange.com/users/34616/']
The first thing I would try is the (relatively) new [SFDX](https://developer.salesforce.com/tools/sfdxcli) tooling. See the SFDX documentation [Example: Export and Import Data Between Orgs](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_test_data_example.htm). The export would follow this pattern (example from the above link): ``` sfdx force:data:tree:export --query \ "SELECT Id, Name, Title__c, Phone__c, Mobile_Phone__c, \ Email__c, Picture__c, \ (SELECT Name, Address__c, City__c, State__c, Zip__c, \ Price__c, Title__c, Beds__c, Baths__c, Picture__c, \ Thumbnail__c, Description__c \ FROM Properties__r) \ FROM Broker__c" \ --prefix export-demo --outputdir sfdx-out --plan ``` but with the SOQL querying the `Attachment` object. (Not sure about governor limits: may be necessary to use many requests with a `where` clause to break the data up into groups.)
If you don’t want to perform a manual entry and save time, check out Data2CRM - an automated migration tool that can transfer your attachments.
59,944,235
In my react component I have added video tag like: ``` <video controls ref="video"> <source src="VIDEO SOURCE" type="video/mp4" /> </video> ``` And I have added play button like: ``` <button onClick={() => {this.refs.video.play()}}>Play Button</button> ``` This code is working for single video when using `ref` But i have multiple video in one page so How to use multiple ref in loop?
2020/01/28
['https://Stackoverflow.com/questions/59944235', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4316024/']
The file is serializable in theory (base64 for example) but it would probably make using the devtools harder or cause other unexpected side effects with that much data. I agree that it's valid to not store the actual file content in action payloads. You could save a hash of the file (or simply the name and a timestamp) and use this as a key to access the file in another type of storage if it becomes necessary to have the content. This would make time travel work again, but only if the actions are replayed in the same environment where the file content can be accessed.
I faced the same issue. This is how had configured my store. ``` export default configureStore({ reducer: { vehicles: vehicleReducer, }, middleware: [...getDefaultMiddleware(), apiMiddleware], }); ``` Once I got rid of `getDefaultMiddleware`, the error was gone for me.
59,944,235
In my react component I have added video tag like: ``` <video controls ref="video"> <source src="VIDEO SOURCE" type="video/mp4" /> </video> ``` And I have added play button like: ``` <button onClick={() => {this.refs.video.play()}}>Play Button</button> ``` This code is working for single video when using `ref` But i have multiple video in one page so How to use multiple ref in loop?
2020/01/28
['https://Stackoverflow.com/questions/59944235', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4316024/']
The file is serializable in theory (base64 for example) but it would probably make using the devtools harder or cause other unexpected side effects with that much data. I agree that it's valid to not store the actual file content in action payloads. You could save a hash of the file (or simply the name and a timestamp) and use this as a key to access the file in another type of storage if it becomes necessary to have the content. This would make time travel work again, but only if the actions are replayed in the same environment where the file content can be accessed.
```js export default configureStore({ reducer: { \\Put your reducers here }, middleware:getDefaultMiddleware({ \\this way you don't remove the middlewares serializableCheck:false, }), }); ```
59,944,235
In my react component I have added video tag like: ``` <video controls ref="video"> <source src="VIDEO SOURCE" type="video/mp4" /> </video> ``` And I have added play button like: ``` <button onClick={() => {this.refs.video.play()}}>Play Button</button> ``` This code is working for single video when using `ref` But i have multiple video in one page so How to use multiple ref in loop?
2020/01/28
['https://Stackoverflow.com/questions/59944235', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4316024/']
```js export default configureStore({ reducer: { \\Put your reducers here }, middleware:getDefaultMiddleware({ \\this way you don't remove the middlewares serializableCheck:false, }), }); ```
I faced the same issue. This is how had configured my store. ``` export default configureStore({ reducer: { vehicles: vehicleReducer, }, middleware: [...getDefaultMiddleware(), apiMiddleware], }); ``` Once I got rid of `getDefaultMiddleware`, the error was gone for me.
18,834,713
I need to allow certain users limited access to the lab server. The server is RHEL 5.6. However, I don't want to give them the root access. Basically, we have configured a LDAP server where all the users have centralized NFS and LDAP login from any of the client machines in the network. So, the LDAP users home area is located in /home/users in the server. I need to give access to only this folder to a certain user. If I edit the visudo file and add the following line in the RHEL server, will I be able to accomplish what am looking for? ``` user1, %operator ALL= /home/users ```
2013/09/16
['https://Stackoverflow.com/questions/18834713', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1742825/']
When you are authenicating users with ldap and nfs mounted share, as such users of ldap or without ldap would be restricted to work in their home directory only. Thanks & Regards, Alok Thaker
Basically, as you giving all users access as users not as root hence all users will not have root access either using local authentication or remote authentication. I hope the users don't know your root password. :) SUDO is used only when you want to give some users privilege to run the command as root like a normal user will not be able to do the command "service network restart" but if you allow the user have sudo privileges, he will be able to do it.
452,083
I have just installed the latest Ubuntu 14.04 and I would like to install KDE along side my Gnome/Unity that I have now. How can I do this? Thanks!
2014/04/21
['https://askubuntu.com/questions/452083', 'https://askubuntu.com', 'https://askubuntu.com/users/2975/']
You can install kde 4.12 easily on ubuntu 14.04 , open terminal : ``` sudo apt-get update sudo apt-get install kubuntu-desktop ``` Enjoy using **KDE**
Good answers here, but when installing you'll be asked a question in a terminal about choosing between lightdm and kdm. Either works well and lightdm should be selected by default, just press [ENTER}. Reboot/logout, and when you go to login again, you'll see a "gear" icon next to your password window. Click it and select KDE, now enter your password. This option will be remembered until you decide to change.
40,447,377
I have a problem sorting a table. My table HTML is this: ``` <table> <tr> <td>3</td> <td>1</td> </tr> <tr> <td>2</td> <td>4</td> </tr> </table> ``` And I want it to look like this: ``` <table> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </table> ``` Here is my current sorting code: ```js var rows = $('tr'); rows.eq(0).find('td').sort(function(a, b) { return $.text([a]) > $.text([b]) ? 1 : -1; }).each(function(newIndex) { var originalIndex = $(this).index(); rows.each(function() { var td = $(this).find('td'); if (originalIndex !== newIndex) td.eq(originalIndex).insertAfter(td.eq(newIndex)); }); }); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <table> <tr> <td>3</td> <td>1</td> </tr> <tr> <td>2</td> <td>4</td> </tr> </table> ``` The code only sorts by separate rows. I can't use any plugins and I need to do this with jquery or javascript. Can anyone suggestion how to make it work?
2016/11/06
['https://Stackoverflow.com/questions/40447377', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7121533/']
It's simple. 1. Store all the numbers from `td` in an array. 2. Sort the array. 3. Modify the `td`s according to array. Here's how you'd do it in JS: ``` var tds= [].slice.call(document.getElementsByTagName("td")); //Find <td> and store in array var tdsa=tds.map(function (a) {return Number(a.innerHTML);}); //Take the innerHTMLs tdsa.sort(); //Sort it tds.forEach(function(a,i) {a.innerHTML=tdsa[i]}); //Modify <td>'s innerHTML ```
Try this - method: * get the items of the table into an array * sort the array * rebuild the rows ```js var columnCount = 2; var items = []; $('td').each(function (idx, obj) { items.push(obj.innerHTML); }); items.sort(); $('table tr').remove(); for(var i=0; i<items.length; i+=2) { var row = '<tr>'; for(var j=0; j<columnCount; j++) { row += '<td>' + items[i+j] + '</td>'; }; row += '</tr>'; $('table').append(row); }; ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <table> <tr> <td>3</td> <td>1</td> </tr> <tr> <td>2</td> <td>4</td> </tr> </table> ```
34,575,731
I am unable to disable/remove some extensions in Visual Studio 2015, including extensions like the "Multilingual App Toolkit" and "MySQL for Visual Studio" that I have installed myself. In several cases, both the `Disable` and `Uninstall` buttons are grayed out in the Extensions and Updates manager. [![Visual Studio Extensions - showing greyed out disable and uninstall options](https://i.stack.imgur.com/S3e35.png)](https://i.stack.imgur.com/S3e35.png) I've tried starting VS as administrator, and also launching VS in safe mode (using `devenv.exe /safemode`). Why is it not possible to disable some extensions, and what is the correct way to safely disable them?
2016/01/03
['https://Stackoverflow.com/questions/34575731', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1624894/']
You can manage extensions from Visual Studio only if they use standard .vsix installer. If they use other installer like .msi you typically use Control Panel - Programs and Features to uninstall them.
Windows *Control Panel -> Programs and Features* can uninstall most of those addons. For anything else, there is an awesome simple utility: [Total-Uninstaller](https://github.com/tsasioglu/Total-Uninstaller). It can uninstall virtually anything, including hidden stuff. Warning: uninstalling too much can make Visual Studio crashing / unusable and can even damage Windows installation. Make sure to back up important info before proceeding.
18,861,370
Need to remove everything between .jpg and > on all instances like these below: * .jpg|500|756|20121231-just-some-image-3.jpg)%> * .jpg|500|729|)%> * .jpg|500|700|)%> * .jpg|500|756|test-43243.jpg)%> So everything becomes .jpg> Any suggestions using preg\_replace?
2013/09/17
['https://Stackoverflow.com/questions/18861370', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1550196/']
``` preg_replace('/\.jpg[^>]+>/', '.jpg>', $your_string); ```
``` $str = '.jpg|500|756|20121231-just-some-image-3.jpg)%>'; preg_replace('/[^\.jpg][^>]+/', '', $str); ```
149,106
Is anyone familiar with this error? It is causing TinyMCE to break in my Wordpress theme. In console it gives me these two errors both seem to originate from wp-admin/post-new.php > > Uncaught ReferenceError:switchEditors is not defined > > > Uncaught TypeError: undefined is not a function /wp-admin/load-scripts.php?c=0&load%5B%5D=hoverIntent,…editor,quickt&load%5B%5D=ags,wplink,wp-fullscreen,media-upload&ver=3.9.1:2 > > > ![enter image description here](https://i.stack.imgur.com/p3rLM.png) Both the Visual and Smart tabs break, becoming unclickable, and the TinyMCE toolbar disappears.
2014/06/10
['https://wordpress.stackexchange.com/questions/149106', 'https://wordpress.stackexchange.com', 'https://wordpress.stackexchange.com/users/45362/']
it might me entirely different solution that i am providing but it solved the problem for me. I followed these steps: 1. Open the user that is getting error. (Wordpress admin menu > users > your profile) 2. Changed the setting of "Disable the visual editor when writing" and saved the settings 3. Again disabled this feature and saved the settings 4. Boom. my editor is back. Maybe it could solve someone else problem. Regards, Rao
You are most probably having a conflict with some plugin or the theme (bad javascript usually). If you got some kind of an adblocker, this might be another reason too, so you'd better check them all and see if it is a browser-sensitive problem.
149,106
Is anyone familiar with this error? It is causing TinyMCE to break in my Wordpress theme. In console it gives me these two errors both seem to originate from wp-admin/post-new.php > > Uncaught ReferenceError:switchEditors is not defined > > > Uncaught TypeError: undefined is not a function /wp-admin/load-scripts.php?c=0&load%5B%5D=hoverIntent,…editor,quickt&load%5B%5D=ags,wplink,wp-fullscreen,media-upload&ver=3.9.1:2 > > > ![enter image description here](https://i.stack.imgur.com/p3rLM.png) Both the Visual and Smart tabs break, becoming unclickable, and the TinyMCE toolbar disappears.
2014/06/10
['https://wordpress.stackexchange.com/questions/149106', 'https://wordpress.stackexchange.com', 'https://wordpress.stackexchange.com/users/45362/']
it might me entirely different solution that i am providing but it solved the problem for me. I followed these steps: 1. Open the user that is getting error. (Wordpress admin menu > users > your profile) 2. Changed the setting of "Disable the visual editor when writing" and saved the settings 3. Again disabled this feature and saved the settings 4. Boom. my editor is back. Maybe it could solve someone else problem. Regards, Rao
You can disable concatenation by defining `CONCATENATE_SCRIPTS` constant to false. In `wp-config.php` would be fitting: ``` define('CONCATENATE_SCRIPTS', false); ``` W3TC shouldn't affect anything on admin side.
149,106
Is anyone familiar with this error? It is causing TinyMCE to break in my Wordpress theme. In console it gives me these two errors both seem to originate from wp-admin/post-new.php > > Uncaught ReferenceError:switchEditors is not defined > > > Uncaught TypeError: undefined is not a function /wp-admin/load-scripts.php?c=0&load%5B%5D=hoverIntent,…editor,quickt&load%5B%5D=ags,wplink,wp-fullscreen,media-upload&ver=3.9.1:2 > > > ![enter image description here](https://i.stack.imgur.com/p3rLM.png) Both the Visual and Smart tabs break, becoming unclickable, and the TinyMCE toolbar disappears.
2014/06/10
['https://wordpress.stackexchange.com/questions/149106', 'https://wordpress.stackexchange.com', 'https://wordpress.stackexchange.com/users/45362/']
it might me entirely different solution that i am providing but it solved the problem for me. I followed these steps: 1. Open the user that is getting error. (Wordpress admin menu > users > your profile) 2. Changed the setting of "Disable the visual editor when writing" and saved the settings 3. Again disabled this feature and saved the settings 4. Boom. my editor is back. Maybe it could solve someone else problem. Regards, Rao
This fixed my issue - I added this line to the bottom of wp-config.php and BOOM! define('CONCATENATE\_SCRIPTS', false);
70,809,910
I have a function that is intended to rotate polygons by 5 degrees left or right and return their new points. This function is as follows, along with the function `player_center` that it requires. ``` # finds center of player shape # finds slope and midpoint of each vertice-midpoint line on the longer sides, # then the intercept of them all def player_center(player): left_mid = line_midpoint(player[0], player[1]) right_mid = line_midpoint(player[0], player[2]) left_mid_slope = line_slope(left_mid, player[2]) right_mid_slope = line_slope(right_mid, player[1]) left_mid_line = find_equation(player[2], left_mid_slope, True) right_mid_line = find_equation(player[1], right_mid_slope, True) standard_left_mid_line = slope_intercept_to_standard(left_mid_line[0], left_mid_line[1], left_mid_line[2]) standard_right_mid_line = slope_intercept_to_standard(right_mid_line[0], right_mid_line[1], right_mid_line[2]) lines = sym.Matrix([standard_left_mid_line, standard_right_mid_line]) return (float(lines.rref()[0].row(0).col(2)[0]), float(lines.rref()[0].row(1).col(2)[0])) # rotates the player using SOHCAHTOA # divides x coordinate by radius to find angle, then adds or subtracts increment of 5 to it depending on direction # calculates the position of point at incremented angle, then appends to new set of points # finally, new set is returned # direction; 1 is left, 0 is right def rotate_player(player, direction): increment = math.pi/36 # radian equivalent of 5 degrees full_circle = 2 * math.pi # radian equivalent of 360 degrees center = player_center(player) new_player = [] for point in player: radius = line_distance(point, center) point_sin = (center[1] - point[1])/radius while (point_sin > 1): point_sin -= 1 point_angle = math.asin(point_sin) if (direction == 1): if ((point_angle+increment) > math.pi * 2): new_angle = (point_angle+increment) - math.pi * 2 else: new_angle = point_angle + increment else: if ((point_angle-increment) < 0): new_angle = 2 * math.pi + (point_angle-increment) else: new_angle = point_angle-increment print("The angle was {}".format(math.degrees(point_angle))) print("The angle is now {}".format(math.degrees(new_angle))) # print lines are for debug purposes new_point = ((radius * math.cos(new_angle)) + center[0], -(radius * math.sin(new_angle)) + center[1]) new_player.append(new_point) print(new_player) return new_player ``` The geometric functions that it relies on are all defined in this file here: ``` import math import sympy as sym # shape is in form of list of tuples e.g [(1,1), (2,1), (1,0), (2,0)] # angle is in degrees # def rotate_shape(shape, angle): def line_distance(first_point, second_point): return math.sqrt( (second_point[0] - first_point[0]) ** 2 + (second_point[1] - first_point[1]) ** 2) # undefined is represented by None in this program def line_slope(first_point, second_point): if (second_point[0] - first_point[0] == 0): return None elif (second_point[1] - first_point[1] == 0): return 0 else: return (second_point[1] - first_point[1])/(second_point[0] - first_point[0]) def line_midpoint(first_point, second_point): return ( (first_point[0] + second_point[0])/2, (first_point[1] + second_point[1])/2 ) def find_equation(coord_pair, slope, array_form): # Array form useful for conversion into standard form if (array_form == True): if (slope == 0): intercept = coord_pair[1] return [0, 1, intercept] elif (slope == None): intercept = coord_pair[0] return [1, 0, intercept] else: intercept = coord_pair[1] - (coord_pair[0] * slope) return [slope, 1, intercept] else: if (slope == 0): intercept = coord_pair[1] print("y = {0}".format(intercept)) return elif (slope == None): intercept = coord_pair[0] print("x = {0}".format(intercept)) return else: intercept = coord_pair[1] - (coord_pair[0] * slope) if (intercept >= 0): print("y = {0}x + {1}".format(slope, intercept)) return else: print("y = {0}x - {1}".format(slope, intercept)) def find_perpendicular(slope): if (slope == 0): return None elif (slope == None): return 0 else: return -(1/slope) def find_perp_bisector(first_point, second_point): # This function finds the perpendicular bisector between two points, using funcs made previously midpoint = line_midpoint(first_point, second_point) slope = line_slope(first_point, second_point) return find_equation(midpoint, -(1/slope)) def find_perp_equation(x, y, m, array_form): # returns the perpendicular equation of a given line if (array_form == True): return [find_perpendicular(x), y, m] else: if (m >= 0): print("{0}y = {1}x + {2}".format(y, find_perpendicular(x), m)) else: print("{0}y = {1}x - {2}".format(y, find_perpendicular(x), m)) def find_hyp(a, b): return math.sqrt((a**2) + (b**2)) def find_tri_area(a, b, c): # finds area of triangle using Heron's formula semi = (a+b+c)/2 return math.sqrt(semi * (semi - a) * (semi - b) * (semi - c) ) def r_tri_check(a, b, c): if (a**2) + (b**2) != (c**2): print("This thing fake, bro.") def find_point_section(first_point, second_point, ratio): # I coded this half a year ago and can't remember what for, but kept it here anyway. # separtions aren't necessary, but good for code readability first_numerator = (ratio[0] * second_point[0]) + (ratio[1] * first_point[0]) second_numerator = (ratio[0] * second_point[1]) + (ratio[1] * first_point[1]) return ( first_numerator/(ratio[0]+ratio[1]), second_numerator/(ratio[0] + ratio[1])) def slope_intercept_to_standard(x, y, b): # x and y are the coeffients of the said variables, for example 5y = 3x + 8 would be inputted as (3, 5, 8) if (x == 0): return [0, 1, b] elif (y == 0): return [x, 0, b] else: return [x, -y, -b] ``` It mathematically seems sound, but when I try to apply it, all hell breaks loose. For example when trying to apply it with the set `polygon_points` equal to `[(400, 300), (385, 340), (415, 340)]`, All hell breaks loose. An example of the output among repeated calls to the function upon `polygon_points`(outputs manually spaced for clarity): ``` The angle was 90.0 The angle is now 95.0 The angle was -41.633539336570394 The angle is now -36.633539336570394 The angle was -41.63353933657017 The angle is now -36.63353933657017 The angle was 64.4439547804165 The angle is now 69.4439547804165 The angle was -64.44395478041695 The angle is now -59.44395478041695 The angle was -64.44395478041623 The angle is now -59.44395478041624 The angle was 80.94458887142648 The angle is now 85.94458887142648 The angle was -80.9445888714264 The angle is now -75.9445888714264 The angle was -80.94458887142665 The angle is now -75.94458887142665 ``` Can anyone explain this?
2022/01/22
['https://Stackoverflow.com/questions/70809910', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/17769030/']
Too much irrelevant code, a lot of magic like this `while (point_sin > 1): point_sin -= 1` - so hard to reproduce. To rotate point around some center, you need just this (where `cos(fi), sin(fi)` are precalculated value in your case): ``` new_x = center_x + (old_x - center_x) * cos(fi) - (old_y - center_y) * sin(fi) new_y = center_y + (old_x - center_x) * sin(fi) + (old_y - center_y) * cos(fi) ```
This is a built-in capability of RegularPolygon in SymPy: ``` >>> from sympy import RegularPolygon, rad >>> p = RegularPolygon((0,0), 1, 5) >>> p.vertices[0] Point2D(1, 0) >>> p.rotate(rad(30)) # or rad(-30) >>> p.vertices[0] Point2D(sqrt(3)/2, 1/2) ```
23,576,155
I’m trying to learn a few things about scripting and Linux systems, so I started learning `bash` scripting. For an exercise, I’m trying to program a script that would install all programs that user chooses. I worked out a skeleton of installation part, but I’m stuck at determining users answer. Here is my code: ``` #!/bin/bash declare -a instal_list=("Gimp" "VLC" "Gedit") for ((i=0; i<3; i++)) do echo "Do you want to install ${instal_list[i]} ?" echo read answer_${instal_list[i]} if [[ $answer_${instal_list[i]} == "yes" ]] || [[ $answer_${instal_list[i]} == "Yes" ]] || [[ $answer_${instal_list[i]} == "YES" ]]; then instal+=" ${install_list[i]}" fi done ``` My problem is in my `if` statement. Inside of it, I’m trying to evaluate if users answer is yes. Problem is in `answer_${instal_list[i]}` variable. I don't know how to explain what I mean, so I will try to explain it on example. Example : * We run the script, and the script asks us if we want install Gimp. * We say yes, and the script stores that answer in variable "answer\_${instal\_list[1]}" ("answer\_Gimp"). * My problem is when I try to call back that variable ("answer\_Gimp"). = To call it I use "$answer\_${instal\_list[1]}" line, but the shell doesn’t recognize that command as answer\_Gimp. So how can I call back variable `answer_${instal_list[1]}` so that shell would recognize it as "answer\_Gimp"?
2014/05/10
['https://Stackoverflow.com/questions/23576155', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3622290/']
``` thing="Gimp" answer_Gimp="Yes" variableName="answer_$thing" echo "The value of $variableName is ${!variableName}" ```
If you have bash version 4, you can use an associative array: ``` declare -a instal_list=("Gimp" "VLC" "Gedit") declare -a to_install declare -A answers for prog in "${instal_list[@]}"; do read -p "Do you want to install $prog? [y/n] " answer["$prog"] if [[ "${answer["$prog"],,}" == y* ]]; then to_install+=( "$prog" ) fi done echo you want to install: printf " %s\n" "${to_install[@]}" ``` Looking at that, I don't see why you need to keep the answers in an array. But if you do, that's how you'd do it.
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
I know this is old, but I just ran into the same problem. My issue was that multiple projects in the solution used Newtonsoft.Json, but some were at different versions. I updated all of them to the most recent (9.0.1 as I type) and the problem went away. Anyway... if anyone is still dealing with this, make sure to update the package in EVERY project in the solution. HTH
run this command in the package manager console: ``` PM> Install-Package Newtonsoft.Json -Version 6.0.1 ```
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
After trying much of the above (and some other posts), I uninstalled with the package manager all of the following from the project affected: ``` Microsoft.AspNet.WebApi Microsoft.AspNet.Client Microsoft.AspNet.Core Microsoft.AspNet.WebHost Newtonsoft.Json ``` Then reinstalled Microsoft.AspNet.WebApi, which auto installed .Client, .Core, .WebHost, .Json.
check the 'Newtonsoft.Json' version in the project references. Add that version in the Web config. It will work. For Example: your Webconfig look like this: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json"publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/> </dependentAssembly> ``` If your version in References is '9.0.0.0' change to this: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json"publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="9.0.0.0"/> </dependentAssembly> ```
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
After trying much of the above (and some other posts), I uninstalled with the package manager all of the following from the project affected: ``` Microsoft.AspNet.WebApi Microsoft.AspNet.Client Microsoft.AspNet.Core Microsoft.AspNet.WebHost Newtonsoft.Json ``` Then reinstalled Microsoft.AspNet.WebApi, which auto installed .Client, .Core, .WebHost, .Json.
In my case, the following code was present in my local debug version of the solution, but not in my live server version of code. Adding the code to my server Web.config file fixed the problem. ``` <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" /> <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> </dependentAssembly> </assemblyBinding> ```
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
After trying much of the above (and some other posts), I uninstalled with the package manager all of the following from the project affected: ``` Microsoft.AspNet.WebApi Microsoft.AspNet.Client Microsoft.AspNet.Core Microsoft.AspNet.WebHost Newtonsoft.Json ``` Then reinstalled Microsoft.AspNet.WebApi, which auto installed .Client, .Core, .WebHost, .Json.
Run `Update-Package Newtonsoft.Json -Reinstall` It should remove the reference to your 4.5 version, and reinstall the newer version referenced in your package.config. It will also update the binding redirect, which should then be as follows: ```xml <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> </dependentAssembly> ``` Since you said in your question that you already tried this, you might want to *first* try removing the existing reference manually. You might also want to make sure the files aren't read-only on disk, or otherwise locked by source control.
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
I know this is old, but I just ran into the same problem. My issue was that multiple projects in the solution used Newtonsoft.Json, but some were at different versions. I updated all of them to the most recent (9.0.1 as I type) and the problem went away. Anyway... if anyone is still dealing with this, make sure to update the package in EVERY project in the solution. HTH
check the 'Newtonsoft.Json' version in the project references. Add that version in the Web config. It will work. For Example: your Webconfig look like this: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json"publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/> </dependentAssembly> ``` If your version in References is '9.0.0.0' change to this: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json"publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="9.0.0.0"/> </dependentAssembly> ```
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
Run `Update-Package Newtonsoft.Json -Reinstall` It should remove the reference to your 4.5 version, and reinstall the newer version referenced in your package.config. It will also update the binding redirect, which should then be as follows: ```xml <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> </dependentAssembly> ``` Since you said in your question that you already tried this, you might want to *first* try removing the existing reference manually. You might also want to make sure the files aren't read-only on disk, or otherwise locked by source control.
1. In your VS solution explorer, remove the Newtonsoft.Json reference. 2. Download the 6.0 binary files at Newtonsoft binary files [here](https://github.com/JamesNK/Newtonsoft.Json/releases/download/6.0.8/Json60r8.zip) 3. Extract the files 4. Add the Newtonsoft library manually. From Visual Studio, right click Reference and select Add Reference 5. Click Browse 6. Navigate to the extracted files under Net45 and select Newtonsoft.Json.dll 7. If it does not work try using Net40 instead by going through the whole procedure again.
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
I had this error myself, and first used `Update-Package –reinstall Newtonsoft.Json -IncludePrerelease` it didn't work, then used `Install-Package Newtonsoft.Json` . it worked.
run this command in the package manager console: ``` PM> Install-Package Newtonsoft.Json -Version 6.0.1 ```
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
Add Newtonsoft reference in my MVC project solves the problem for me.
run this command in the package manager console: ``` PM> Install-Package Newtonsoft.Json -Version 6.0.1 ```
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
I know this is old, but I just ran into the same problem. My issue was that multiple projects in the solution used Newtonsoft.Json, but some were at different versions. I updated all of them to the most recent (9.0.1 as I type) and the problem went away. Anyway... if anyone is still dealing with this, make sure to update the package in EVERY project in the solution. HTH
1. In your VS solution explorer, remove the Newtonsoft.Json reference. 2. Download the 6.0 binary files at Newtonsoft binary files [here](https://github.com/JamesNK/Newtonsoft.Json/releases/download/6.0.8/Json60r8.zip) 3. Extract the files 4. Add the Newtonsoft library manually. From Visual Studio, right click Reference and select Add Reference 5. Click Browse 6. Navigate to the extracted files under Net45 and select Newtonsoft.Json.dll 7. If it does not work try using Net40 instead by going through the whole procedure again.
32,806,744
First, It is not just duplicate. None of answers from following questions are working for me. <http://goo.gl/tS40cn> <http://goo.gl/pH6v2T> I've just updated all my packages using Nuget Package Manager and I started receiving this error. **Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)** My Package Config has: ``` <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> ``` Web.config includes this piece of code: ``` <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> </dependentAssembly> ``` Properties from Reference for `Newtonsoft.Json` [![enter image description here](https://i.stack.imgur.com/K5OMM.png)](https://i.stack.imgur.com/K5OMM.png) According to the answers from the similar questions, I have tried followings: * Reinstalling package using `Update-Package –reinstall Newtonsoft.Json` * Removing `dependentAssembly` config from `Web.config` for `Newtonsoft.Json` * Changing `newVersion` to `6.0.0.0` and `7.0.0.0` in `dependentAssembly`. Doing so gave birth to new error. * Also tried `Get-Project -All | Add-BindingRedirect`. It changes `newVersion` for `Newtonsoft.Json` to `4.5.0.0`. But issue remains unresolved. Please help me fixing this.
2015/09/27
['https://Stackoverflow.com/questions/32806744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1306394/']
Run `Update-Package Newtonsoft.Json -Reinstall` It should remove the reference to your 4.5 version, and reinstall the newer version referenced in your package.config. It will also update the binding redirect, which should then be as follows: ```xml <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> </dependentAssembly> ``` Since you said in your question that you already tried this, you might want to *first* try removing the existing reference manually. You might also want to make sure the files aren't read-only on disk, or otherwise locked by source control.
run this command in the package manager console: ``` PM> Install-Package Newtonsoft.Json -Version 6.0.1 ```
16,982,818
(I'm not sure about the correctness of title) I have an `numpy.array` `f` as follows: ``` # id frame x y z ``` What I want to do is to extract the trajectories for some specific `id`. For `id==1` I get for instance: ``` f_1 = f[ f[:,0]==1 ] ``` and get ``` array([[ 1. , 55. , 381.51 , -135.476 , 163.751 ], [ 1. , 56. , 369.176 , -134.842 , 163.751 ], [ 1. , 57. , 357.499 , -134.204 , 163.751 ], [ 1. , 58. , 346.65 , -133.786 , 163.751 ], [ 1. , 59. , 336.602 , -133.762 , 163.751 ], [ 1. , 60. , 326.762 , -135.157 , 163.751 ], [ 1. , 61. , 315.77 , -135.898 , 163.751 ], [ 1. , 62. , 303.806 , -136.855 , 163.751 ], [ 1. , 63. , 291.273 , -138.255 , 163.751 ], [ 1. , 64. , 278.767 , -139.824 , 163.751 ], [ 1. , 65. , 266.778 , -141.123 , 163.751 ], [ 1. , 66. , 255.773 , -142.42 , 163.751 ], [ 1. , 67. , 244.864 , -143.314 , 163.751 ]]) ``` My problem is I' m not sure I understand how it works. Normally I was expecting something like: ``` f_1 = f[ f[:,0]==1, : ] ``` which also works and makes more sense to me. (take all columns but only those rows that fulfill the required condition) Can someone explain why this form also works and what exactly happens? ``` f_1 = f[ f[:,0]==1 ] ```
2013/06/07
['https://Stackoverflow.com/questions/16982818', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1213793/']
For a 2D array asking only one index returns the line (with all columns) corresponding to that index, so that: ``` np.all( a[0] == a[0,:] ) #True ``` When you do `a[0]==1` you get a boolean array, like: ``` b = a[0]==1 #array([True, True, False, False, True], dtype=bool) ``` Which you can use through fancy indexing to obtain all the lines whose index has a corresponding `True` value in `b`. In this example, doing: ``` c = a[ b ] ``` will get lines corresponding to indices `[0,1,4]`. The same result would be obtained by passing directly these indices, like `c = a[ [0,1,4] ]`.
Quoting from the [Tentative Numpy Tutorial](http://wiki.scipy.org/Tentative_NumPy_Tutorial): > > ...When fewer indices are provided than the number of axes, the missing indices are considered complete slices... > > > So `f[f[:,0]==1]` gets translated to `f[f[:,0]==1,:]` (or equivalently, to `f[f[:,0]==1,...]`) which are all the same thing from programmers' perspective.
42,574,844
[![enter image description here](https://i.stack.imgur.com/Iovci.png)](https://i.stack.imgur.com/Iovci.png) this is my project structure, Failed to load resource: the server responded with a status of 404 (), ShowDetail.jsp is not found, which path i need to give in Route templateURL ? [![enter image description here](https://i.stack.imgur.com/HKeeG.png)](https://i.stack.imgur.com/Iovci.png) When click on name i need to populate details on another page, i am using Server side(Spring MVC) Service to fetch details. My client side code is in below snippet ```js var App = angular.module("myApp", ['ngRoute', 'angularUtils.directives.dirPagination']); App.config(['$routeProvider', function($routeProvider, $locationProvider) { $routeProvider. when('/detail/:username', { templateUrl: 'showDetail.jsp', controller: 'detailController' }); } ]); angular.module('myApp').controller("myController", function($scope, $http) { function getDetails(name) { $http.get(REST_SERVICE_URI + '/detail/' + name) .then( function(response) { self.detail = response.data; }, function(errResponse) { console.error('Error while fetching Users'); } ); } }); ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script> <div ng-controller="myController as ctrl"> <tbody> <tr dir-paginate="u in ctrl.users|orderBy:sortKey:reverse|filter:search|itemsPerPage:5"> <td><span ng-bind="u.id"></span> </td> <td> <a> <span ng-bind="u.name" ng-click="ctrl.getDetails(u.name)"></span> </a> </td> <td><span ng-bind="u.department"></span> </td> <td> <span ng-bind="u.job"></span> </td> </tr> </tbody> </div> ``` IndexController.java ``` @RequestMapping(value= "/detail/{name}",method = RequestMethod.GET) public String getDetails(@PathVariable("name") String name) { return "showDetail"; } ``` MainController.java ``` @RequestMapping(value = "/detail/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Detail> getDetails(@PathVariable("name") String name) { System.out.println("Fetching detail with name " + name); Detail detail = userService.findByName(name); if (detail == null) { System.out.println("Detail with id " + name + " not found"); return new ResponseEntity<Detail>(HttpStatus.NOT_FOUND); } return new ResponseEntity<Detail>(detail, HttpStatus.OK); } ``` ServiceImpl.java ``` public Detail findByName(String name) { for(Detail deatil : details){ if(deatil.getFirstname().equalsIgnoreCase(name)){ return deatil; } } return null; } ``` These are my files, i am able to fetch details and getting in angularJS controller, when i click on a name field in table it should display corresponding details in another page, i can fetch the corresponding details, but page is not changing, i am having problem With routing in angular Js and SpringMVC, Please help me how to resolve this issue
2017/03/03
['https://Stackoverflow.com/questions/42574844', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3639244/']
You can create a Map and map the integer to the String Value. Iterate the reference array and get it listed based on your order. Snippet: ``` Map<Integer,String> maps = new HashMap<Integer,String>(); maps.put(1,"Red"); maps.put(2,"White"); for(Integer a : values){ System.out.println(maps.get(a)); } ```
You can use ``` Collections.swap(test,1,2); Collections.swap(test,2,3); ``` Documentation [Here](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#swap%28java.util.List,%20int,%20int%29)
54,014,687
I have a DataFrame ``` >> test = pd.DataFrame({'A': ['a', 'b', 'b', 'b'], 'B': [1, 2, 3, 4], 'C': [np.nan, np.nan, np.nan, np.nan], 'D': [np.nan, np.nan, np.nan, np.nan]}) A B C D 0 a 1 1 b 2 2 b 3 3 b 4 ``` I also have a dictionary, where `b` in `input_b` signifies that I'm only modifying rows where `row.A = b`. ``` >> input_b = {2: ['Moon', 'Elephant'], 4: ['Sun', 'Mouse']} ``` How do I populate the DataFrame with values from the dictionary to get ``` A B C D 0 a 1 1 b 2 Moon Elephant 2 b 3 3 b 4 Sun Mouse ```
2019/01/02
['https://Stackoverflow.com/questions/54014687', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6503670/']
This may not be the most efficient solution, but from what I understand it got the job done: ``` import pandas as pd import numpy as np test = pd.DataFrame({'A': ['a', 'b', 'b', 'b'], 'B': [1, 2, 3, 4], 'C': [np.nan, np.nan, np.nan, np.nan], 'D': [np.nan, np.nan, np.nan, np.nan]}) input_b = {2: ['Moon', 'Elephant'], 4: ['Sun', 'Mouse']} for key, value in input_b.items(): test.loc[test['B'] == key, ['C', 'D']] = value print(test) ``` Yields: ``` A B C D 0 a 1 NaN NaN 1 b 2 Moon Elephant 2 b 3 NaN NaN 3 b 4 Sun Mouse ``` This will get slower if the dictionary `input_b` gets too large (too many rows are being updated, too many iterations in the for loop), but should be relatively fast with small `input_b`'s even with large `test` dataframes. This answer also assumes the keys in the `input_b` dictionary refer to the values of the `B` column in the original dataframe, and will add repeated values in the `C` and `D` columns for repeated values in the `B` column.
Using `update` ``` test=test.set_index('B') test.update(pd.DataFrame(input_b,index=['C','D']).T) test=test.reset_index() test B A C D 0 1 a NaN NaN 1 2 b Moon Elephant 2 3 b NaN NaN 3 4 b Sun Mouse ```
54,014,687
I have a DataFrame ``` >> test = pd.DataFrame({'A': ['a', 'b', 'b', 'b'], 'B': [1, 2, 3, 4], 'C': [np.nan, np.nan, np.nan, np.nan], 'D': [np.nan, np.nan, np.nan, np.nan]}) A B C D 0 a 1 1 b 2 2 b 3 3 b 4 ``` I also have a dictionary, where `b` in `input_b` signifies that I'm only modifying rows where `row.A = b`. ``` >> input_b = {2: ['Moon', 'Elephant'], 4: ['Sun', 'Mouse']} ``` How do I populate the DataFrame with values from the dictionary to get ``` A B C D 0 a 1 1 b 2 Moon Elephant 2 b 3 3 b 4 Sun Mouse ```
2019/01/02
['https://Stackoverflow.com/questions/54014687', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6503670/']
This may not be the most efficient solution, but from what I understand it got the job done: ``` import pandas as pd import numpy as np test = pd.DataFrame({'A': ['a', 'b', 'b', 'b'], 'B': [1, 2, 3, 4], 'C': [np.nan, np.nan, np.nan, np.nan], 'D': [np.nan, np.nan, np.nan, np.nan]}) input_b = {2: ['Moon', 'Elephant'], 4: ['Sun', 'Mouse']} for key, value in input_b.items(): test.loc[test['B'] == key, ['C', 'D']] = value print(test) ``` Yields: ``` A B C D 0 a 1 NaN NaN 1 b 2 Moon Elephant 2 b 3 NaN NaN 3 b 4 Sun Mouse ``` This will get slower if the dictionary `input_b` gets too large (too many rows are being updated, too many iterations in the for loop), but should be relatively fast with small `input_b`'s even with large `test` dataframes. This answer also assumes the keys in the `input_b` dictionary refer to the values of the `B` column in the original dataframe, and will add repeated values in the `C` and `D` columns for repeated values in the `B` column.
You can use [`loc`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.loc.html) indexing after setting your index to `B`: ``` test = test.set_index('B') test.loc[input_b, ['C', 'D']] = list(input_b.values()) test = test.reset_index() print(test) B A C D 0 1 a NaN NaN 1 2 b Moon Elephant 2 3 b NaN NaN 3 4 b Sun Mouse ```
54,014,687
I have a DataFrame ``` >> test = pd.DataFrame({'A': ['a', 'b', 'b', 'b'], 'B': [1, 2, 3, 4], 'C': [np.nan, np.nan, np.nan, np.nan], 'D': [np.nan, np.nan, np.nan, np.nan]}) A B C D 0 a 1 1 b 2 2 b 3 3 b 4 ``` I also have a dictionary, where `b` in `input_b` signifies that I'm only modifying rows where `row.A = b`. ``` >> input_b = {2: ['Moon', 'Elephant'], 4: ['Sun', 'Mouse']} ``` How do I populate the DataFrame with values from the dictionary to get ``` A B C D 0 a 1 1 b 2 Moon Elephant 2 b 3 3 b 4 Sun Mouse ```
2019/01/02
['https://Stackoverflow.com/questions/54014687', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6503670/']
Using `apply` ``` test['C'] = test['B'].map(input_b).apply(lambda x: x[0] if type(x)==list else x) test['D'] = test['B'].map(input_b).apply(lambda x: x[1] if type(x)==list else x) ``` yields ``` A B C D 0 a 1 NaN NaN 1 b 2 Moon Elephant 2 b 3 NaN NaN 3 b 4 Sun Mouse ```
Using `update` ``` test=test.set_index('B') test.update(pd.DataFrame(input_b,index=['C','D']).T) test=test.reset_index() test B A C D 0 1 a NaN NaN 1 2 b Moon Elephant 2 3 b NaN NaN 3 4 b Sun Mouse ```
54,014,687
I have a DataFrame ``` >> test = pd.DataFrame({'A': ['a', 'b', 'b', 'b'], 'B': [1, 2, 3, 4], 'C': [np.nan, np.nan, np.nan, np.nan], 'D': [np.nan, np.nan, np.nan, np.nan]}) A B C D 0 a 1 1 b 2 2 b 3 3 b 4 ``` I also have a dictionary, where `b` in `input_b` signifies that I'm only modifying rows where `row.A = b`. ``` >> input_b = {2: ['Moon', 'Elephant'], 4: ['Sun', 'Mouse']} ``` How do I populate the DataFrame with values from the dictionary to get ``` A B C D 0 a 1 1 b 2 Moon Elephant 2 b 3 3 b 4 Sun Mouse ```
2019/01/02
['https://Stackoverflow.com/questions/54014687', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6503670/']
Using `apply` ``` test['C'] = test['B'].map(input_b).apply(lambda x: x[0] if type(x)==list else x) test['D'] = test['B'].map(input_b).apply(lambda x: x[1] if type(x)==list else x) ``` yields ``` A B C D 0 a 1 NaN NaN 1 b 2 Moon Elephant 2 b 3 NaN NaN 3 b 4 Sun Mouse ```
You can use [`loc`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.loc.html) indexing after setting your index to `B`: ``` test = test.set_index('B') test.loc[input_b, ['C', 'D']] = list(input_b.values()) test = test.reset_index() print(test) B A C D 0 1 a NaN NaN 1 2 b Moon Elephant 2 3 b NaN NaN 3 4 b Sun Mouse ```
3,169,164
Using asp.net profiles, I've stored a complex type (class) and retrieved it. But it is returning a new object that is not initialized instead of null? Is this the expected behavior, if so how can I determine if I've saved data for the given user? should be some easy points for someone to pick up..
2010/07/02
['https://Stackoverflow.com/questions/3169164', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/254428/']
Your question is a little unclear, but I think you're asking why there's a non-null profile data object for a user who you haven't stored data for yet? [This article](http://msdn.microsoft.com/en-us/magazine/cc163724.aspx#S4) might hopefully clear it up for you. Some of the relevant bits: > > A user profile is a collection of > values that the ASP.NET 2.0 runtime > groups as public fields of a > dynamically generated class. The class > is derived from a system-provided > class and is extended with the > addition of a few new members. The > class doesn't have to be marked as > Serializable, however its contents are > persisted to the storage medium as > individual properties. The storage > occurs on a per-user basis and is > preserved until an administrator > deletes it. > > > And further down: > > When the application runs and a page > is displayed, ASP.NET dynamically > creates a profile object that contains > properly typed data and assigns the > current settings for the logged user > to the properties defined in the data > model. The profile object is added to > the current HttpContext object and > made available to pages through the > Profile property. Assuming that the > profile model has been defined to > store a list of links as a collection, > the following code snippet shows how > to retrieve the list of favorite links > that are created by a given user: > > > ... > > > This code assumes a Links property in > the profile object that references a > collection type. When the page is > loaded, Links and other properties are > initialized to contain the most > recently stored values; when the page > is unloaded their current contents are > stored to the persistent medium. > > > If you need to track whether a user has ever set profile data before, you might be able to use the [FindProfilesByUserName](http://msdn.microsoft.com/en-us/library/system.web.profile.sqlprofileprovider.findprofilesbyusername.aspx) function to check to see if a profile exists before you log them in.
A little late, but [UsingDefaultValue](https://learn.microsoft.com/en-us/dotnet/api/system.configuration.settingspropertyvalue.usingdefaultvalue?view=dotnet-plat-ext-3.1) tells you if the property value is coming from the user profile settings or if it's using a default. Another way you can get, kind of, the same result is using [Deserialized](https://learn.microsoft.com/en-us/dotnet/api/system.configuration.settingspropertyvalue.deserialized?view=dotnet-plat-ext-3.1).
19,778
i am stuck to an issue where i have a List ID - list of Ids i have to find the LoginName of SPUser or SPGroup with the id in the ListID i tried the following but it threws exception as it did not find user when group id is there ``` foreach (var id in ID) { SPUser spUser = web.SiteUsers.GetByID(Convert.ToInt32(id)); if (spUser != null) { lstUsers.Add(spUser.LoginName); continue; } SPGroup spGroup = web.SiteGroups.GetByID(Convert.ToInt32(id )); if (spGroup != null) { lstGroups.Add(spGroup.LoginName); continue; } } ``` please suggest what to do !!!
2011/09/20
['https://sharepoint.stackexchange.com/questions/19778', 'https://sharepoint.stackexchange.com', 'https://sharepoint.stackexchange.com/users/2310/']
After breaking the inheritance of an item (item,list,web) you have to call `update()` on that object to make sure the settings are saved to the database. Once these are saved you can start adding/changing the permissions for that item. BreakRoleInheritance(false) will not copy the permissions of the parent to the new permissionset, supplying true will copy the permissions. **Updates** (see also Vedran Rasols [answer](https://sharepoint.stackexchange.com/questions/19771/powershell-item-level-permission-by-content-type/19792#19792)) * Using `foreach(item in list.items)` is not recommended, use an SPQuery to select the items and properties you really want, otherwise you will [fetch all data from the DB](https://web.archive.org/web/20120729085025/http://blog.dynatrace.com:80/2009/01/13/sharepoint-only-request-data-that-you-really-need/). See also this [MSDN Best Practices Article](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-services/bb687949%28v=office.12%29#WorkingWithFoldersLists)! * In theory you shouldn't have to call `update()`, but in some strange way in helped solving this issue. **bonus:** Note that when breaking inheritance on lists [the AllowUnsafeUpdate property of the parent web reverts to false](https://www.wictorwilen.se/Post/BreakRoleInheritance-and-AllowUnsafeUpdates.aspx), which can be annoying.
You need to take advantage of [SPQuery class](http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.aspx). Using CAML query is much, much, much more faster then doing foreach. Here is script you 'really' want: ``` $webUrl = "http://inside.national.com/Sales" $listName = "2011Sales" $ctname = "2011Sales" $groupname = "Custom SP Group" # Get web and list $web = Get-SPWeb -Identity $webUrl $list = $web.Lists[$listName] # Build CAML query $caml="<Where><Eq><FieldRef Name='ContentType'/><Value Type='Text'>{0}</Value></Eq></Where>" -f $ctname $query = New-Object Microsoft.SharePoint.SPQuery $query.Query = $caml # Set scope to Recursive to include all items from folders and Document Sets $query.ViewAttributes = "Scope='Recursive'" # Get our data (only items with proper ct name) $items = $list.GetItems($query) # Set Role Assignment $spGroup = $web.SiteGroups[$groupname] $spRoleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($spGroup) $sproledefinition = $web.RoleDefinitions["Contribute"] $sproleassignment.RoleDefinitionBindings.Add($sproledefinition) foreach ($item in $items) { # This is the fastest way of deleting all permissions # First you restore inheritance # And then you break it $item.ResetRoleInheritance() $item.BreakRoleInheritance($false) # Add new permission $item.RoleAssignments.Add($spRoleAssignment) } ``` This script will update all items of desired Content Type (including items/files in folders and files in Document Sets). However it will not change permissions of parent Folders or Document Sets. I have tested this on my dev machine. Feel free to ask additional questions.
19,778
i am stuck to an issue where i have a List ID - list of Ids i have to find the LoginName of SPUser or SPGroup with the id in the ListID i tried the following but it threws exception as it did not find user when group id is there ``` foreach (var id in ID) { SPUser spUser = web.SiteUsers.GetByID(Convert.ToInt32(id)); if (spUser != null) { lstUsers.Add(spUser.LoginName); continue; } SPGroup spGroup = web.SiteGroups.GetByID(Convert.ToInt32(id )); if (spGroup != null) { lstGroups.Add(spGroup.LoginName); continue; } } ``` please suggest what to do !!!
2011/09/20
['https://sharepoint.stackexchange.com/questions/19778', 'https://sharepoint.stackexchange.com', 'https://sharepoint.stackexchange.com/users/2310/']
After breaking the inheritance of an item (item,list,web) you have to call `update()` on that object to make sure the settings are saved to the database. Once these are saved you can start adding/changing the permissions for that item. BreakRoleInheritance(false) will not copy the permissions of the parent to the new permissionset, supplying true will copy the permissions. **Updates** (see also Vedran Rasols [answer](https://sharepoint.stackexchange.com/questions/19771/powershell-item-level-permission-by-content-type/19792#19792)) * Using `foreach(item in list.items)` is not recommended, use an SPQuery to select the items and properties you really want, otherwise you will [fetch all data from the DB](https://web.archive.org/web/20120729085025/http://blog.dynatrace.com:80/2009/01/13/sharepoint-only-request-data-that-you-really-need/). See also this [MSDN Best Practices Article](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-services/bb687949%28v=office.12%29#WorkingWithFoldersLists)! * In theory you shouldn't have to call `update()`, but in some strange way in helped solving this issue. **bonus:** Note that when breaking inheritance on lists [the AllowUnsafeUpdate property of the parent web reverts to false](https://www.wictorwilen.se/Post/BreakRoleInheritance-and-AllowUnsafeUpdates.aspx), which can be annoying.
Here is the working code in case someone needs it. ``` $webUrl = "http://inside.national.com/Sales" $web = Get-SPWeb $webUrl $list = $web.Lists["2011Sales"] $ct = "2011 Marketing" $spgroup = "Custom SP Group" $rd="Contribute" foreach ($item in $list.items) { If ($item.ContentType.Name -eq $ct) { $item.ResetRoleInheritance() # Not sure if this line is needed $item.BreakRoleInheritance($false) # I tried $true but did not work, so leave it at $false $item.SystemUpdate() # Very Important $group = $web.AllUsers[$spgroup] $roledef = $web.RoleDefinitions[$rd] $roleass = New-Object Microsoft.SharePoint.SPRoleAssignment($web.SiteGroups[$spgroup]) $roleass.RoleDefinitionBindings.Add($roledef) $item.RoleAssignments.Add($roleass) $item.SystemUpdate() #Update item without changing the updated date Write-Host $item.Name " permission applied" } } $web.dispose() ```
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
I had the same problem, also on Lion. Strangely, my solution was the opposite of Jeremy's. I had a whole bunch of someproject.dev entries on one line in /etc/hosts. Loading a site on any of them the first time took forever, like a minute or so. If I used it again within 5 seconds or so it was very fast, but much longer and it would again take a minute. I had suspected all sorts of things, mysql connections, Ruby versions, Rails bugs, Apache, Phusion Passenger. Until I finally looked at the Console and realized that DNS lookups were being attempted. So, I put all of them on seperate lines: ``` 127.0.0.1 localhost 127.0.0.1 myproject.dev 127.0.0.1 myotherproject.dev ``` And suddenly everything was snappy again. Same on both my machines.
The trick that did it for me was adding ``` 127.0.0.1 locahost ``` on the first line of the host file. From all my virtual hosts, only the ones using a database were slow. I believe it's because the process of looking up "localhost" for the database connection slowed things down, since I only added the addresses for my virtual hosts and not "localhost" as well. Now it's all snappy again. :)
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
I had the same problem and found it to be caused by enabling IPv6 on my LAN, but not having IPv6 configured correctly between my network and my ISP. Apparently the IPv6 DNS-server takes precedence over IPv4 DNS when the client is given both. It took a couple of seconds (on every attempt) for the client to find that the IPv6 DNS was unreachable or missing, and then falling back to IPv4 DNS.
This helped me: [Apache HTTP localhost randomly taking 5 seconds on macOS Monterey but fast on HTTPS](https://stackoverflow.com/questions/70698918/apache-http-localhost-randomly-taking-5-seconds-on-macos-monterey-but-fast-on-ht) ``` Turn off Keep Alive by adding: KeepAlive Off To your http.conf ```
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
There's another issue 10.7.\* to 10.8.4 for sites ending in `.local` which causes five second lookups. Details and solution courtesy Bram Van Damme’s [blog post found here](http://www.bram.us/2011/12/12/mamp-pro-slow-name-resolving-with-local-vhosts-in-lion-fix/). > > “By default, any hostname ending in `.local` is treated as a Bonjour host rather than by querying the DNS server entries in Network preferences.” > > > “To fix this problem (without having to rename each vhost) you need to add IPv6 entries for each of your vhosts in your `/etc/hosts` file:” > > > ``` ::1 mysite.local fe80::1%lo0 mysite.local 127.0.0.1 mysite.local ```
This helped me: [Apache HTTP localhost randomly taking 5 seconds on macOS Monterey but fast on HTTPS](https://stackoverflow.com/questions/70698918/apache-http-localhost-randomly-taking-5-seconds-on-macos-monterey-but-fast-on-ht) ``` Turn off Keep Alive by adding: KeepAlive Off To your http.conf ```
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
Ensuring that the host names are defined at the beginning of the file made the difference for me. By default the line 127.0.0.1 localhost is already at the beginning, just add your entries on the same line.
The trick that did it for me was adding ``` 127.0.0.1 locahost ``` on the first line of the host file. From all my virtual hosts, only the ones using a database were slow. I believe it's because the process of looking up "localhost" for the database connection slowed things down, since I only added the addresses for my virtual hosts and not "localhost" as well. Now it's all snappy again. :)
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
There's another issue 10.7.\* to 10.8.4 for sites ending in `.local` which causes five second lookups. Details and solution courtesy Bram Van Damme’s [blog post found here](http://www.bram.us/2011/12/12/mamp-pro-slow-name-resolving-with-local-vhosts-in-lion-fix/). > > “By default, any hostname ending in `.local` is treated as a Bonjour host rather than by querying the DNS server entries in Network preferences.” > > > “To fix this problem (without having to rename each vhost) you need to add IPv6 entries for each of your vhosts in your `/etc/hosts` file:” > > > ``` ::1 mysite.local fe80::1%lo0 mysite.local 127.0.0.1 mysite.local ```
A dumb issue that led me to waste some considerable time: after applying [@Cleverlemming's answer](https://stackoverflow.com/a/17982964/1588706), I figured out that there were duplicated entries on the hosts file. Something like: ``` ::1 site1.local site2.local site1.local site3.local site4.local fe80::1%lo0 site1.local site2.local site1.local site3.local site4.local 127.0.0.1 site1.local site2.local site1.local site3.local site4.local ``` Then IP resolving for site3.local and site4.local takes these 5-seconds of death.
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
Make sure to put the IP v6 entries not in the line with localhost ``` ::1 localhost ``` the IP v6 entries go in a separate line ``` fe80::1%lo0 here and_here ``` It is sometimes really fast now, but there are rare exceptions where the old lags come back. They might however be based on other reasons.
I had this same problem and finally realized I had the same host entry twice on the same line: e.g. ``` 127.0.0.1 localhost host1 host2 host3 host4 host5 host1 host6 ``` I removed the second instance of the same host (in the example above - host1) - and things immediately sped up. Felt a little silly when I discovered this, but when you've got 10 long host names on the same line and you're frequently adding / removing, it can be eaisly overlooked.
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
I had the exact same problem and it was driving me crazy! Put all your hosts file entries for localhost into one line like so: ``` 127.0.0.1 localhost myproject.dev myotherproject.dev ::1 localhost fe80::1%lo0 localhost ``` Worked like a charm for me. Seems like a bug in Lion.
A dumb issue that led me to waste some considerable time: after applying [@Cleverlemming's answer](https://stackoverflow.com/a/17982964/1588706), I figured out that there were duplicated entries on the hosts file. Something like: ``` ::1 site1.local site2.local site1.local site3.local site4.local fe80::1%lo0 site1.local site2.local site1.local site3.local site4.local 127.0.0.1 site1.local site2.local site1.local site3.local site4.local ``` Then IP resolving for site3.local and site4.local takes these 5-seconds of death.
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
I had the same problem, also on Lion. Strangely, my solution was the opposite of Jeremy's. I had a whole bunch of someproject.dev entries on one line in /etc/hosts. Loading a site on any of them the first time took forever, like a minute or so. If I used it again within 5 seconds or so it was very fast, but much longer and it would again take a minute. I had suspected all sorts of things, mysql connections, Ruby versions, Rails bugs, Apache, Phusion Passenger. Until I finally looked at the Console and realized that DNS lookups were being attempted. So, I put all of them on seperate lines: ``` 127.0.0.1 localhost 127.0.0.1 myproject.dev 127.0.0.1 myotherproject.dev ``` And suddenly everything was snappy again. Same on both my machines.
Specifying same host for IPv6 ::1 helped me. ``` 127.0.0.1 something.local.mydomain.org ::1 something.local.mydomain.org ```
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
There's another issue 10.7.\* to 10.8.4 for sites ending in `.local` which causes five second lookups. Details and solution courtesy Bram Van Damme’s [blog post found here](http://www.bram.us/2011/12/12/mamp-pro-slow-name-resolving-with-local-vhosts-in-lion-fix/). > > “By default, any hostname ending in `.local` is treated as a Bonjour host rather than by querying the DNS server entries in Network preferences.” > > > “To fix this problem (without having to rename each vhost) you need to add IPv6 entries for each of your vhosts in your `/etc/hosts` file:” > > > ``` ::1 mysite.local fe80::1%lo0 mysite.local 127.0.0.1 mysite.local ```
I've run into this a bunch, too. I have a bunch of vhosts defined on two lines, one for IPv4 and one for IPv6. Moving the host I was trying to resolve to be first in the list sped it up. ``` 127.0.0.1 faster.example.dev host1.example.dev host2.example.dev host3.example.dev host4.example.dev host5.example.dev host6.example.dev ::1 faster.example.dev host1.example.dev host2.example.dev host3.example.dev host4.example.dev host5.example.dev host6.example.dev ```
10,064,581
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly. If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. As can be seen below I am not using the .local TLD. My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost My /etc/hosts: ``` 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 myproject.dev ::1 myproject.dev fe80::1%lo0 myproject.dev ``` My virtual host set-up in username.conf: ``` NameVirtualHost *:80 <Directory "/Users/myusername/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/myusername/Dropbox/dev_envs/ </VirtualHost> <VirtualHost *:80> ServerName myproject.dev DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname </VirtualHost> ```
2012/04/08
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
On OSX El Capitan what worked for me was making a duplicate IPv6 entry right above the IPv4 entry like so ``` fe80::1%lo0 demo.test.dev 127.0.0.1 demo.test.dev ```
Note: I am using Windows and XAMPP, however while researching the problem many people have had the same issue on Windows and Mac. Answer for reference for anyone finding this question as I have spent hours trying to find a solution that works for me: I have tried many solutions for the same problem including putting all of the hosts on one line, removing redundant hosts and virtualhosts, and also including the IPv6 lines - none of these *alone* were successful. The only solution which has *so far* appeared to work for me is a combination of all of the solutions: * Changing the domain I am using from mysite.**local** to mysite.**dev**. Inspired by [@Cleverlemming's answer.](https://stackoverflow.com/a/17982964/1588706) * Including the IPv6 lines. * Removing redundant virtualhosts and hosts (I commented them out). In my hosts file my hosts are currently on separate lines and so far the issue seems to be fixed. Good luck to anyone attempting to solve this issue and if anyone has any information to add please do so - this seems to be an issue affected a lot of people with no single known cause or solution.
15,011,569
Lets say I have tables Student and Mentor Does anyone use naming convention for relationship as below? I think this way is good to see the relationships quickly. Would anyone suggest a better way? Student StudentID StudentName Student2MentorID
2013/02/21
['https://Stackoverflow.com/questions/15011569', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/783411/']
To start from scratch, - you probably know this already - there are several ways to represent your database schema, I mean, by using diagrams, for example [ER-diagrams](http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Diagramming_conventions) that helps you (and your team) stay up to date with your database's design and thus making it simpler to understand. Now, personally when it comes to implementation, I do use some kind of naming-convention. For example: * For large projects, I use double underscores to split between table categories, (ie. `hr__personnel`, `hr__clocks`, `hr__timetable`, `vehicles__cars`, `vehicles__trips`) and so on. * Now, having a relationship between two tables, I do Include both (or all) of the involved table names. (ie. `hr__personnel_timetable`, `vehicles__cars_trips`, etc) * Sometimes, (as we all know), we cannot follow strictly a standard, so in those cases I use my own criteria when choosing large relationships' names. * As a rule, I also name table attributes by a three-letter preffix. For example, in my table `trips`, my fields will be `tri_id`,`tri_distance`, `tri_elapsed` * Note also, that in the above item, I didn't include a Foreign Key. So here I go then. When it comes to FK's, It's easy for me (and my team) to realize that the field IS a FK. If we follow the previous example, I would like to know who drives in each trip (to make it easier, we assume that only one person drives one trip). So my table now is something like this: `tri_id`, *`per_id`*, `tri_distance`, `tri_elapsed`. Now you can easily realize that per\_id is just a foreign field of the table. Just, another hint to help. Just by following these simple steps, you will save *hours*, and probably some headaches too. Hope this helps.
It is better to use underscores... I suggest to simply use existing naming convention rules such as this one: <http://www.oracle-base.com/articles/misc/naming-conventions.php>
15,011,569
Lets say I have tables Student and Mentor Does anyone use naming convention for relationship as below? I think this way is good to see the relationships quickly. Would anyone suggest a better way? Student StudentID StudentName Student2MentorID
2013/02/21
['https://Stackoverflow.com/questions/15011569', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/783411/']
I think: you can add prefix (3 letters) to table depending that module represents (scholar,sales,store) module: scholar ->**sc** table: **scStudent** ( IdStudent,nameStudent..) table: **scMentor**(IdMentor,nameMentor...) relationship **scMentorStudent** (**IdMentorStudent** pk..) You can use Microsoft's EF notation : <http://weblogs.asp.net/jamauss/pages/DatabaseNamingConventions.aspx>
It is better to use underscores... I suggest to simply use existing naming convention rules such as this one: <http://www.oracle-base.com/articles/misc/naming-conventions.php>
72,461,386
Consider the following event: ``` $(`#selectpicker).on('change', function(){ if(condition) {} else { //canceel event change } }); ``` How to cancel the change event based on specific condition therefore maintaining the same select picker value.
2022/06/01
['https://Stackoverflow.com/questions/72461386', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5946983/']
Is this what you are looking for? Set a variable for the current value and if an undesired value is selected we set the value of the select field back to the recent value. ``` <select id="selectpicker"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> let currentValue = $('#selectpicker').val(); $('#selectpicker').on('change', function(){ let newValue = $(this).val(); if(newValue == 3){ console.log("3 is not allowed"); $(this).val(currentValue); return; } currentValue = $('#selectpicker').val(); }) ``` You could also disable certain options with "disabled" keyword, but keep in mind that this can be easily bypassed from developer tools. ``` <option disabled value="3">3</option> ```
While you can stop the execution of the callback with `return false`, the value will already have changed when this event is triggered. If you want to return to the previous value, you have to store it somehow, either in a variable or in a `data` property on the element. Then you can set the value back in your condition, or update the variable when your cancel-condition is not met.
18,400,673
In my rails app I have two tables - `device_ports` and `circuits`. My goal is to get a list of `device_ports` whose `id` is not being used in the `physical_port_id` column of the `circuits` table. I have done something similar before on other tables but here my query only returns one row when it should return 23 rows - there are 24 device ports for this device and one is in use. ``` select id, name, device_id, multiuse from device_ports where (device_id = 6 and multiuse = 1) or device_ports.id not in (select physical_port_id from circuits) ``` So this query gets all multiuse ports (so even if the id was referenced in the foreign key, this row should still be returned) and should also get all rows where the device\_id is 6 but is not referenced in circuits but only the multiuse row is being returned. The result from the query is ``` id | name | device_id | multiuse ------------------------------------ 268 | test-1 | 6 | 1 ``` I did try to create an sql fiddle but the build just seems to timeout. ``` CREATE TABLE `device_ports` ( `id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) DEFAULT NULL, `name` tinytext, `speed` tinytext, `multiuse` tinyint(1) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `id` (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=291 DEFAULT CHARSET=latin1; INSERT INTO `device_ports` (`id`, `device_id`, `name`, `speed`, `multiuse`, `created_at`, `updated_at`) *emphasized text*VALUES (1, 1, 'Test Device Port', '100', 0, NULL, NULL), (2, 1, 'Test Port 2', '300', 1, NULL, NULL), (289, 6, 'test-22', '100', 0, NULL, NULL), (290, 6, 'test-23', '100', 0, NULL, NULL), (288, 6, 'test-21', '100', 0, NULL, NULL), (287, 6, 'test-20', '100', 0, NULL, NULL), (286, 6, 'test-19', '100', 0, NULL, NULL), (284, 6, 'test-17', '100', 0, NULL, NULL), (285, 6, 'test-18', '100', 0, NULL, NULL), (283, 6, 'test-16', '100', 0, NULL, NULL), (282, 6, 'test-15', '100', 0, NULL, NULL), (281, 6, 'test-14', '100', 0, NULL, NULL), (280, 6, 'test-13', '100', 0, NULL, NULL), (279, 6, 'test-12', '100', 0, NULL, NULL), (278, 6, 'test-11', '100', 0, NULL, NULL), (277, 6, 'test-10', '100', 0, NULL, NULL), (276, 6, 'test-9', '100', 0, NULL, NULL), (275, 6, 'test-8', '100', 0, NULL, NULL), (274, 6, 'test-7', '100', 0, NULL, NULL), (273, 6, 'test-6', '100', 0, NULL, NULL), (272, 6, 'test-5', '100', 0, NULL, NULL), (271, 6, 'test-4', '100', 0, NULL, NULL), (270, 6, 'test-3', '100', 0, NULL, NULL), (269, 6, 'test-2', '100', 0, NULL, NULL), (268, 6, 'test-1', '100', 1, NULL, NULL), (267, 6, 'test-0', '100', 0, NULL, NULL); CREATE TABLE `circuits` ( `id` int(11) NOT NULL AUTO_INCREMENT, `organisation_id` int(11) DEFAULT NULL, `physical_port_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=248 DEFAULT CHARSET=latin1; INSERT INTO `circuits` (`id`, `organisation_id`, `physical_port_id`) VALUES (1, 125, 267); ```
2013/08/23
['https://Stackoverflow.com/questions/18400673', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/634120/']
You could try using a LEFT OUTER JOIN: ``` SELECT DISTINCT d.id, d.name, d.device_id, d.multiuse FROM device_ports d LEFT OUTER JOIN circuits c ON c.physical_port_id = d.id WHERE (c.physical_port_id IS NULL AND d.device_id = 6) OR (d.multiuse = 1 AND d.device_id = 6) ORDER BY d.id ``` There are several techniques for this query, take a look at [What's the difference between NOT EXISTS vs. NOT IN vs. LEFT JOIN WHERE IS NULL?](https://stackoverflow.com/questions/2246772/whats-the-difference-between-not-exists-vs-not-in-vs-left-join-where-is-null).
``` SELECT p.* FROM device_ports p LEFT JOIN circuits c ON c.physical_port_id = p.id WHERE p.device_id = 6 AND multiuse = 1 AND c.id IS NULL; ```
29,765,504
Currently coding in C#, I wonder if there is a way to factor the code as presented below ``` Entity1 = GetByName("EntityName1"); Entity2 = GetByName("EntityName2"); Entity3 = GetByName("EntityName3"); ``` The idea would be to get a single call in the code, factoring the code by placing the `entities` and the `strings` in a container and iterating on this container to get a single "`GetByName()`" line. Is there a way to do this?
2015/04/21
['https://Stackoverflow.com/questions/29765504', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4311207/']
You can use LINQ: ``` var names=new[]{"EntityName1","EntityName2","EntityName3",.....}; var entities=names.Select(name=>GetByName(name)).ToArray(); ``` Without `ToArray`, `Select` will return an IEnumerable that will be reevalueated each time you enumerate it - that is, `GetByName` will be called each time you enumerate the enumerable. `ToArray()` or `ToList` will create an array (or list) you can use multiple times. You can also call `ToDictionary` if you want to be able to access the entities by name: ``` var entities=names.ToDictionary(name=>name,name=>GetByName(name)); ``` All this assumes that the entities don't already exist or that `GetByName` has to do some significant work to retrieve them. If the entities exist you can simply put them in a `Dictionary<String,Entity>`. If the entities have a `Name` property you can use `ToDictionary` to create the dictionary in one statement: ``` var entities=new []{entity1,entity2,entity3,...}; var entitiesDict=entities.ToDictionary(entity=>entity.Name,entity=>entity); ```
Do you mean something like the below (where `entities` is the collection of `Entity1`, `Entity1` & `Entity3`): ``` var results = entities.Select(e => GetByName(e.Name)); ```
29,765,504
Currently coding in C#, I wonder if there is a way to factor the code as presented below ``` Entity1 = GetByName("EntityName1"); Entity2 = GetByName("EntityName2"); Entity3 = GetByName("EntityName3"); ``` The idea would be to get a single call in the code, factoring the code by placing the `entities` and the `strings` in a container and iterating on this container to get a single "`GetByName()`" line. Is there a way to do this?
2015/04/21
['https://Stackoverflow.com/questions/29765504', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4311207/']
You can use LINQ: ``` var names=new[]{"EntityName1","EntityName2","EntityName3",.....}; var entities=names.Select(name=>GetByName(name)).ToArray(); ``` Without `ToArray`, `Select` will return an IEnumerable that will be reevalueated each time you enumerate it - that is, `GetByName` will be called each time you enumerate the enumerable. `ToArray()` or `ToList` will create an array (or list) you can use multiple times. You can also call `ToDictionary` if you want to be able to access the entities by name: ``` var entities=names.ToDictionary(name=>name,name=>GetByName(name)); ``` All this assumes that the entities don't already exist or that `GetByName` has to do some significant work to retrieve them. If the entities exist you can simply put them in a `Dictionary<String,Entity>`. If the entities have a `Name` property you can use `ToDictionary` to create the dictionary in one statement: ``` var entities=new []{entity1,entity2,entity3,...}; var entitiesDict=entities.ToDictionary(entity=>entity.Name,entity=>entity); ```
It depends on what you're looking for. If you need to set the variables in a single line, that won't work. You could play with reflection if you're dealing with fields or properties, but honestly that seems messier than what you've got already. If the data-structure doesn't matter, and you just need the data and are able to play with it as you see so fit, I'd probably enumerate it into a dictionary. Of course, that's pretty tightly coupled to what you've got now, which looks like it's a fake implementation anyway. If you want to do that, it's pretty straight-forward. It's your choice how you create the `IEnumerable<string>` that's represented below as `entityNames`. You could use an array initializer as I do, you could use a `List<string>` that you build over time, you could even `yield return` it in its own method. ``` var entityNames = new[] { "EntityName1", "EntityName2", "EntityName3" }; var dict = entityNames.ToDictionary(c => c, c => GetByName(c)); ``` Then it's just a matter of checking those. ``` var entity1 = dict["EntityName1"]; ``` Or enumerating over the dictionary. ``` foreach(var kvp in dict) { Console.WriteLine("{0} - {1}", kvp.Key, kvp.Value); } ``` But realistically, it's hard to know whether that's preferable to what you've already got.
29,765,504
Currently coding in C#, I wonder if there is a way to factor the code as presented below ``` Entity1 = GetByName("EntityName1"); Entity2 = GetByName("EntityName2"); Entity3 = GetByName("EntityName3"); ``` The idea would be to get a single call in the code, factoring the code by placing the `entities` and the `strings` in a container and iterating on this container to get a single "`GetByName()`" line. Is there a way to do this?
2015/04/21
['https://Stackoverflow.com/questions/29765504', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4311207/']
You can use LINQ: ``` var names=new[]{"EntityName1","EntityName2","EntityName3",.....}; var entities=names.Select(name=>GetByName(name)).ToArray(); ``` Without `ToArray`, `Select` will return an IEnumerable that will be reevalueated each time you enumerate it - that is, `GetByName` will be called each time you enumerate the enumerable. `ToArray()` or `ToList` will create an array (or list) you can use multiple times. You can also call `ToDictionary` if you want to be able to access the entities by name: ``` var entities=names.ToDictionary(name=>name,name=>GetByName(name)); ``` All this assumes that the entities don't already exist or that `GetByName` has to do some significant work to retrieve them. If the entities exist you can simply put them in a `Dictionary<String,Entity>`. If the entities have a `Name` property you can use `ToDictionary` to create the dictionary in one statement: ``` var entities=new []{entity1,entity2,entity3,...}; var entitiesDict=entities.ToDictionary(entity=>entity.Name,entity=>entity); ```
Ok, here is an idea. You can declare this function. ``` IReadOnlyDictionary<string, T> InstantiateByName<T>( Func<string, T> instantiator params string[] names) { return names.Distinct().ToDictionary( name => name, name => instantiator(name)) } ``` which you could call like this, ``` var entities = InstantiateByName( GetByName, "EntityName1", "EntityName2", "EntityName3"); ``` --- To push the over-engineering to the next level, you can install the Immutable Collections package, ``` PM> Install-Package Microsoft.Bcl.Immutable ``` and modify the function slightly, ``` using Microsoft.Immutable.Collections; IReadOnlyDictionary<string, T> InstantiateByName<T>( Func<string, T> instantiator params string[] names, IEqualityComparer<string> keyComparer = null, IEqualityComparer<T> valueComparer = null) { if (keyComparer == null) { keyComparer = EqualityComparer<string>.Default; } if (valueComparer == null) { valueComparer = EqualityComparer<T>.Default; } return names.ToImmutableDictionary( name => name, name => instantiator(name), keyComparer, valueComparer); } ``` The function would be used in the exactly the same way. However, the caller is responsible for passing unique keys to the function but, an alternative equality comparer can be passed.
29,765,504
Currently coding in C#, I wonder if there is a way to factor the code as presented below ``` Entity1 = GetByName("EntityName1"); Entity2 = GetByName("EntityName2"); Entity3 = GetByName("EntityName3"); ``` The idea would be to get a single call in the code, factoring the code by placing the `entities` and the `strings` in a container and iterating on this container to get a single "`GetByName()`" line. Is there a way to do this?
2015/04/21
['https://Stackoverflow.com/questions/29765504', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4311207/']
Do you mean something like the below (where `entities` is the collection of `Entity1`, `Entity1` & `Entity3`): ``` var results = entities.Select(e => GetByName(e.Name)); ```
Ok, here is an idea. You can declare this function. ``` IReadOnlyDictionary<string, T> InstantiateByName<T>( Func<string, T> instantiator params string[] names) { return names.Distinct().ToDictionary( name => name, name => instantiator(name)) } ``` which you could call like this, ``` var entities = InstantiateByName( GetByName, "EntityName1", "EntityName2", "EntityName3"); ``` --- To push the over-engineering to the next level, you can install the Immutable Collections package, ``` PM> Install-Package Microsoft.Bcl.Immutable ``` and modify the function slightly, ``` using Microsoft.Immutable.Collections; IReadOnlyDictionary<string, T> InstantiateByName<T>( Func<string, T> instantiator params string[] names, IEqualityComparer<string> keyComparer = null, IEqualityComparer<T> valueComparer = null) { if (keyComparer == null) { keyComparer = EqualityComparer<string>.Default; } if (valueComparer == null) { valueComparer = EqualityComparer<T>.Default; } return names.ToImmutableDictionary( name => name, name => instantiator(name), keyComparer, valueComparer); } ``` The function would be used in the exactly the same way. However, the caller is responsible for passing unique keys to the function but, an alternative equality comparer can be passed.
29,765,504
Currently coding in C#, I wonder if there is a way to factor the code as presented below ``` Entity1 = GetByName("EntityName1"); Entity2 = GetByName("EntityName2"); Entity3 = GetByName("EntityName3"); ``` The idea would be to get a single call in the code, factoring the code by placing the `entities` and the `strings` in a container and iterating on this container to get a single "`GetByName()`" line. Is there a way to do this?
2015/04/21
['https://Stackoverflow.com/questions/29765504', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4311207/']
It depends on what you're looking for. If you need to set the variables in a single line, that won't work. You could play with reflection if you're dealing with fields or properties, but honestly that seems messier than what you've got already. If the data-structure doesn't matter, and you just need the data and are able to play with it as you see so fit, I'd probably enumerate it into a dictionary. Of course, that's pretty tightly coupled to what you've got now, which looks like it's a fake implementation anyway. If you want to do that, it's pretty straight-forward. It's your choice how you create the `IEnumerable<string>` that's represented below as `entityNames`. You could use an array initializer as I do, you could use a `List<string>` that you build over time, you could even `yield return` it in its own method. ``` var entityNames = new[] { "EntityName1", "EntityName2", "EntityName3" }; var dict = entityNames.ToDictionary(c => c, c => GetByName(c)); ``` Then it's just a matter of checking those. ``` var entity1 = dict["EntityName1"]; ``` Or enumerating over the dictionary. ``` foreach(var kvp in dict) { Console.WriteLine("{0} - {1}", kvp.Key, kvp.Value); } ``` But realistically, it's hard to know whether that's preferable to what you've already got.
Ok, here is an idea. You can declare this function. ``` IReadOnlyDictionary<string, T> InstantiateByName<T>( Func<string, T> instantiator params string[] names) { return names.Distinct().ToDictionary( name => name, name => instantiator(name)) } ``` which you could call like this, ``` var entities = InstantiateByName( GetByName, "EntityName1", "EntityName2", "EntityName3"); ``` --- To push the over-engineering to the next level, you can install the Immutable Collections package, ``` PM> Install-Package Microsoft.Bcl.Immutable ``` and modify the function slightly, ``` using Microsoft.Immutable.Collections; IReadOnlyDictionary<string, T> InstantiateByName<T>( Func<string, T> instantiator params string[] names, IEqualityComparer<string> keyComparer = null, IEqualityComparer<T> valueComparer = null) { if (keyComparer == null) { keyComparer = EqualityComparer<string>.Default; } if (valueComparer == null) { valueComparer = EqualityComparer<T>.Default; } return names.ToImmutableDictionary( name => name, name => instantiator(name), keyComparer, valueComparer); } ``` The function would be used in the exactly the same way. However, the caller is responsible for passing unique keys to the function but, an alternative equality comparer can be passed.
517,315
I have created some domain users in ADUC and added them to the "Domain Admins" group. On a domain server when I try run a batch file that restart some services, with "net stop ", "net start " and "taskkill ", I get the following error message: ``` System error 5 has occured. Access id denied. ``` And if I try to run the batch file with "Run as administrator" I get the following error message: "This file does not have a program associated with it for performing this action..." It only works if I open an new cmd as administrator and rund the batch script from there. What rights do my domain admins account lack?
2012/12/10
['https://superuser.com/questions/517315', 'https://superuser.com', 'https://superuser.com/users/179239/']
* insert a blank column in column C * in `C1` put `=IF(A1="gmail.com","EN",B1)` and copy down * copy and paste special value column C over the values in Column B * delete the working column C For a partial search try something like `=IF(ISERROR(SEARCH("gmail.com",A1)>0),B1,"EN")` in `C1` then copy down etc
Use `Sort & Filter`. Select column A and B (entirely) and apply the (auto)filter; select filter options on column A and chose text filters: contains. Set contains to "gmail.com", and apply filter. Column B will be filtered accordingly. Change the first cell in column B, and copy it (`Ctrl C`). Then select the remaining cells in column B and press `Ctrl V`.
517,315
I have created some domain users in ADUC and added them to the "Domain Admins" group. On a domain server when I try run a batch file that restart some services, with "net stop ", "net start " and "taskkill ", I get the following error message: ``` System error 5 has occured. Access id denied. ``` And if I try to run the batch file with "Run as administrator" I get the following error message: "This file does not have a program associated with it for performing this action..." It only works if I open an new cmd as administrator and rund the batch script from there. What rights do my domain admins account lack?
2012/12/10
['https://superuser.com/questions/517315', 'https://superuser.com', 'https://superuser.com/users/179239/']
* insert a blank column in column C * in `C1` put `=IF(A1="gmail.com","EN",B1)` and copy down * copy and paste special value column C over the values in Column B * delete the working column C For a partial search try something like `=IF(ISERROR(SEARCH("gmail.com",A1)>0),B1,"EN")` in `C1` then copy down etc
Use an `IF` statement combined with a `RIGHT` function in column B. Place this formula in `B1`. ``` =IF(RIGHT(A1,9)="gmail.com","EN", "HR") ``` This will look for the `gmail.com` and if it exists will populate the cell with `EN`, otherwise it will make it `HR`. To copy it down all the rows in the column, double click on the bottom right corner of the cell where the drag cross is.
517,315
I have created some domain users in ADUC and added them to the "Domain Admins" group. On a domain server when I try run a batch file that restart some services, with "net stop ", "net start " and "taskkill ", I get the following error message: ``` System error 5 has occured. Access id denied. ``` And if I try to run the batch file with "Run as administrator" I get the following error message: "This file does not have a program associated with it for performing this action..." It only works if I open an new cmd as administrator and rund the batch script from there. What rights do my domain admins account lack?
2012/12/10
['https://superuser.com/questions/517315', 'https://superuser.com', 'https://superuser.com/users/179239/']
Use an `IF` statement combined with a `RIGHT` function in column B. Place this formula in `B1`. ``` =IF(RIGHT(A1,9)="gmail.com","EN", "HR") ``` This will look for the `gmail.com` and if it exists will populate the cell with `EN`, otherwise it will make it `HR`. To copy it down all the rows in the column, double click on the bottom right corner of the cell where the drag cross is.
Use `Sort & Filter`. Select column A and B (entirely) and apply the (auto)filter; select filter options on column A and chose text filters: contains. Set contains to "gmail.com", and apply filter. Column B will be filtered accordingly. Change the first cell in column B, and copy it (`Ctrl C`). Then select the remaining cells in column B and press `Ctrl V`.
8,727,018
I have been using some P/Invoke code to simulate a key press, but I can't work out how to press more than one key at once. I am trying to simulate pressing and holding CTRL and then pressing C and then V, so just a copy and paste. The code I am using so far is this, but so far I can only manage to press CTRL, not hold it and press C and V: ``` [DllImport("user32.dll", SetLastError = true)] static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); public const int VK_LCONTROL = 0xA2; static void Main(string[] args) { keybd_event(VK_LCONTROL, 0, 0, 0); } ``` I would really appreciate any suggestions. Thanks.
2012/01/04
['https://Stackoverflow.com/questions/8727018', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/799586/']
The `dwFlags` controls if the key is released or not. Try the following: ``` keybd_event(VK_CONTROL, 0, 0, 0);// presses ctrl keybd_event(0x43, 0, 0, 0); // presses c keybd_event(0x43, 0, 2, 0); //releases c keybd_event(VK_CONTROL, 0, 2, 0); //releases ctrl ```
keybd\_event should be called twice for each keystroke, once to press it down, and once to release it, with the third argument including the bit KEYEVENTF\_KEYUP. You should of course press both keys down before releasing either. See [here](http://social.msdn.microsoft.com/Forums/en/netfxcompact/thread/d5d6097e-f221-452e-8b65-5659e2c9faaa) for a working example of pressing "SHIFT+TAB" using keybd\_event on the .NET Compact Framework (may be slight differences). Note that keybd\_event has been superseded by [SendInput](http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx), but should still work.
7,026,438
I am in the process of writing my own gridview implementation( Based of the tableview pattern). I have followed a datasource model similar to table view, but when I check if the data source responds to the message the call always fails. I have tried putting in break points and following execution, I even tried missing out the call to respondsToSelector. Nothing I try seems to work. What am I missing here? Thanks in advance **GridView.h** ``` ... @protocol GridViewDataSource - (NSInteger) numberOfRowsForGridView:(GridView *)gridView; - (NSInteger) numberOfColumnsForGridView:(GridView *)gridView; - (GridViewCell *) cellForRow:(NSInteger) row column:(NSInteger )column; @end ``` **GridView.m** ``` ... #pragma mark datasource methods -(NSInteger)numberOfRowsForGridView { if( [dataSource respondsToSelector:@selector(numberOfRowsForGridView:)] ) return [dataSource numberOfRowsForGridView:self]; // NSLog(@"Failed, dataSource does not implement properly"); return 0; } -(NSInteger)numberOfColumnsForGridView { if( [dataSource respondsToSelector:@selector(numberOfColumnsForGridView:)] ) return [dataSource numberOfColumnsForGridView:self]; return 0; } -(GridViewCell *)cellForRow:(NSInteger)row column:(NSInteger)column { if( [dataSource respondsToSelector:@selector(cellForRow:column:)]) return [dataSource cellForRow:row column:column]; return nil; } ``` **GridViewAppDelegate.h** ``` ... @interface GridViewAppDelegate : NSObject <UIApplicationDelegate, GridViewDataSource> ... ``` **GridViewAppDelegate.m** ``` #pragma mark datasource methods -(NSInteger)numberOfRowsForGridView:(GridView *)gridView { return 1; } -(NSInteger)numberOfColumnsForGridView:(GridView *)gridView { return 1; } -(GridViewCell *)cellForRow:(NSInteger)row column:(NSInteger)column { CGRect frame = [view bounds]; GridViewCell *cell = [[GridViewCell alloc]initWithFrame:frame]; return cell; } ```
2011/08/11
['https://Stackoverflow.com/questions/7026438', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/299450/']
Is your `dataSource` object `nil`? Any message sent to `nil` will return `NO` for boolean results *(0 for numbers, and `nil` for objects as well)*.
Have you checked whether `dataSource` is non-nil?
13,124
``` \documentclass{article} \usepackage{tikz} \begin{document} % DOES NOT WORK %\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p and 1); %WORKS \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (1 and \p); \end{document} ``` `(1 and \p)` works but `(\p and 1)` does not, why?
2011/03/10
['https://tex.stackexchange.com/questions/13124', 'https://tex.stackexchange.com', 'https://tex.stackexchange.com/users/2099/']
The `(<x radius> and <y radius>)` syntax is old and, if not deprecated, at least not encouraged any more. The current way to do is is to use `[x radius]` and `[y radius]`: ``` \documentclass{article} \usepackage{tikz} \begin{document} % WORKS with current syntax \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse [x radius=\p, y radius=1]; %WORKS \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse [x radius=1, y radius=\p]; \end{document} ```
``` \documentclass{article} \usepackage{tikz} \begin{document} \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p cm and 1 cm); \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (1 cm and \p cm); \end{document} ``` problem with the parser, I suppose ! and the remark of Jake is fine, better now it's to use `x radius` and `y radius`
13,124
``` \documentclass{article} \usepackage{tikz} \begin{document} % DOES NOT WORK %\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p and 1); %WORKS \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (1 and \p); \end{document} ``` `(1 and \p)` works but `(\p and 1)` does not, why?
2011/03/10
['https://tex.stackexchange.com/questions/13124', 'https://tex.stackexchange.com', 'https://tex.stackexchange.com/users/2099/']
Spaces after TeX commands are ignored, thus by using `\p and 1` you'll get an equivalent of, say, `1and 1`, which you can verify to give the same error. Therefore we just need to restore the space: ``` \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p{} and 1); ``` Note that, as Jake mentions, this syntax is deprecated (refer to the [TikZ manual](http://ctan.org/pkg/pgf)).
``` \documentclass{article} \usepackage{tikz} \begin{document} \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p cm and 1 cm); \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (1 cm and \p cm); \end{document} ``` problem with the parser, I suppose ! and the remark of Jake is fine, better now it's to use `x radius` and `y radius`
13,124
``` \documentclass{article} \usepackage{tikz} \begin{document} % DOES NOT WORK %\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p and 1); %WORKS \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (1 and \p); \end{document} ``` `(1 and \p)` works but `(\p and 1)` does not, why?
2011/03/10
['https://tex.stackexchange.com/questions/13124', 'https://tex.stackexchange.com', 'https://tex.stackexchange.com/users/2099/']
Spaces after TeX commands are ignored, thus by using `\p and 1` you'll get an equivalent of, say, `1and 1`, which you can verify to give the same error. Therefore we just need to restore the space: ``` \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p{} and 1); ``` Note that, as Jake mentions, this syntax is deprecated (refer to the [TikZ manual](http://ctan.org/pkg/pgf)).
The `(<x radius> and <y radius>)` syntax is old and, if not deprecated, at least not encouraged any more. The current way to do is is to use `[x radius]` and `[y radius]`: ``` \documentclass{article} \usepackage{tikz} \begin{document} % WORKS with current syntax \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse [x radius=\p, y radius=1]; %WORKS \tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse [x radius=1, y radius=\p]; \end{document} ```
26,009,586
I've had a look into the Documentation and Examples (`http://83.212.101.132/`) but I can't find anything. Is it even possible? In large scale projects, like the one I'm working on right now, I most definitely prefer to use OOP. And not being able to support it would be a big letdown.
2014/09/24
['https://Stackoverflow.com/questions/26009586', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4037009/']
I assume you have a toolchain that lets you build applications for your embedded linux platform. This should include gdb (named something like arm-linux-gdb). Next check if linux for your board already includes gdb/gdbserver. If it does, you don't have to build anything. If it does not, configure gdb like this: ``` ./path/to/gdb/source/configure --host=arm-linux --target=arm-linux --prefix=/path/to/installation/directory ``` Then make and make install. Note that --host and --target will probably match your toolchains prefix. As part of this installation you will get gdbserver. Install it on your board. Then use it, as explained [here](https://sourceware.org/gdb/current/onlinedocs/gdb/Server.html). It depends on your connection type (TCP, serial), but you need to run program under gdbserver on board (gdbserver binary), then run you toolchain's gdb on PC and connect to board using "target remote" command.
Remote debugging of embedded systems: GDB, as a server, must be compiled into the debugging target build in order to support connected GDB clients. When running on the client side, there must exist a copy of the target source as well as an unstripped (of symbols) version of the executable. GCC compilation should be done with the -g flag. On the target/server side, run with gdbserver --attach or gdbserver host: On the client side, run gdb and then (gdb) target remote IP:PORT What gdb client to run? Must be built with the right target processor in mind, for example .../toolchain/bin/powerpc-linux-gdb core/mydaemon/src/mydaemon -x gdb-command-script -x is a filename option Hope this helps!
26,009,586
I've had a look into the Documentation and Examples (`http://83.212.101.132/`) but I can't find anything. Is it even possible? In large scale projects, like the one I'm working on right now, I most definitely prefer to use OOP. And not being able to support it would be a big letdown.
2014/09/24
['https://Stackoverflow.com/questions/26009586', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4037009/']
Have you already looked at [Buildroot](http://buildroot.uclibc.org/)? It will take care of cross-compiler and root file system. You can choose to compile host and target gdb/gdbserver, so that you'll have everything from one hand. See BR's [documentation](http://nightly.buildroot.org/manual.html#_advanced_usage).
Remote debugging of embedded systems: GDB, as a server, must be compiled into the debugging target build in order to support connected GDB clients. When running on the client side, there must exist a copy of the target source as well as an unstripped (of symbols) version of the executable. GCC compilation should be done with the -g flag. On the target/server side, run with gdbserver --attach or gdbserver host: On the client side, run gdb and then (gdb) target remote IP:PORT What gdb client to run? Must be built with the right target processor in mind, for example .../toolchain/bin/powerpc-linux-gdb core/mydaemon/src/mydaemon -x gdb-command-script -x is a filename option Hope this helps!
26,009,586
I've had a look into the Documentation and Examples (`http://83.212.101.132/`) but I can't find anything. Is it even possible? In large scale projects, like the one I'm working on right now, I most definitely prefer to use OOP. And not being able to support it would be a big letdown.
2014/09/24
['https://Stackoverflow.com/questions/26009586', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4037009/']
Remote debugging of embedded systems: GDB, as a server, must be compiled into the debugging target build in order to support connected GDB clients. When running on the client side, there must exist a copy of the target source as well as an unstripped (of symbols) version of the executable. GCC compilation should be done with the -g flag. On the target/server side, run with ``` gdbserver <port> --attach <pid> or gdbserver host:<port> <program> ``` On the client side, run gdb and then ``` (gdb) target remote IP:PORT ``` What gdb client to run? Must be built with the right target processor in mind, for example ``` .../toolchain/bin/powerpc-linux-gdb core/mydaemon/src/mydaemon -x gdb-command-script ``` -x is a filename option Hope this helps!
Remote debugging of embedded systems: GDB, as a server, must be compiled into the debugging target build in order to support connected GDB clients. When running on the client side, there must exist a copy of the target source as well as an unstripped (of symbols) version of the executable. GCC compilation should be done with the -g flag. On the target/server side, run with gdbserver --attach or gdbserver host: On the client side, run gdb and then (gdb) target remote IP:PORT What gdb client to run? Must be built with the right target processor in mind, for example .../toolchain/bin/powerpc-linux-gdb core/mydaemon/src/mydaemon -x gdb-command-script -x is a filename option Hope this helps!
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
The line-of-sight benefits are not actually very much, if any. If you've every played wargames with model-based LOS, you're familiar with the excruciating process of eyeballing, using bits of string, and finally arguing over whether being able to draw LOS to a teeny bit of the tip of a sword sticking up above terrain counts as having LOS or not. Using real LOS, you lose much of the time saved by using a grid. Either go gridless on a sphere and measure everything in real inches, or use a flat, imprecise abstraction with extra LOS limits and movement rules to roughly emulate a spherical surface. Besides which, there's no good tiling of squares onto a sphere that doesn't introduce aberrations in how they connect to each other. To get regularity you have to use a different tile shape, at which point you'd have to make up new rules for adjacency and AOE coverage.
If you are free to alter the dimensions of your planet, you can use any [one of these nice projections](http://en.wikipedia.org/wiki/List_of_map_projections) of a sphere's surface. Note that the projections have 24 squares across and top to bottom (15 degrees lat/long each) ie. a 24x24 grid. At 5' per grid square you end up with a circumference of 120' and a 19' radius. Note that most projections lose a lot of latitude squares near the poles. Now the trick becomes distance to visual horizon. But again the internet provides a [handy calculator](http://www.neoprogrammics.com/spheres/distance_to_horizon.php). Using this tool, assuming 6' person gives a surface to horizon of 13'. Making an assumption that double that is hidden. So absolute LOS = 26' = 5 or 6 squares. For fun give anyone in squares 5 and 6 a cover save.
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
The line-of-sight benefits are not actually very much, if any. If you've every played wargames with model-based LOS, you're familiar with the excruciating process of eyeballing, using bits of string, and finally arguing over whether being able to draw LOS to a teeny bit of the tip of a sword sticking up above terrain counts as having LOS or not. Using real LOS, you lose much of the time saved by using a grid. Either go gridless on a sphere and measure everything in real inches, or use a flat, imprecise abstraction with extra LOS limits and movement rules to roughly emulate a spherical surface. Besides which, there's no good tiling of squares onto a sphere that doesn't introduce aberrations in how they connect to each other. To get regularity you have to use a different tile shape, at which point you'd have to make up new rules for adjacency and AOE coverage.
3d movement in D&D is made by dividing the space in cubes. Each cube that's less than 50% filled is a void space, each cube that's not is all filled. If you build a sphere made of cubes you'll get sections similar to a small circle drawn in Paint. If you get a sphere, sunlight (which rays are parallel) and a transparent sheet with parallel lines you can trace the projection of these lines on the sphere. Rotating the sphere exactly 90° on the 3 axis of the sheet will get you a gridded sheet. The elements of the grid near to the axes will be squared, and the boundaries between those areas will feature triangular elements. It's fine, I've explained earlier what they are, corners of a cube. Despite being triangular, they still count as squares. --- As an alternative, this really is a cube, but it looks like a sphere [![One practical way to map a square grid to a sphere](https://i.stack.imgur.com/EiHe4.jpg)](https://i.stack.imgur.com/EiHe4.jpg)
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
Mike Krahulik of Penny Arcade modeled spherical, planar combat in *[D&D in the Elemental Chaos part 1](http://www.penny-arcade.com/2010/06/28/dd-in-the-elemental-chaos-part-1)* and *[D&D in the Elemental Chaos part 2](http://www.penny-arcade.com/2010/06/30/dd-in-the-elemental-chaos-part-2)*. A concern exists that LOE and AOE in Krahulik's models, as well as, prolonged combat and movement were not possible in the models documented. However, both context of Krahulik's efforts and his entries, he notes that the oddites of modeling the grid on the sphere as well as the success of the models in play. Krahulik talks about "...I was drawing these squares on a curved surface they got sort of wonky in some places, but that is why **I made separate [areas] of grid zones on each planet.**" The photo of these grids clearly shows Krahulik "solving for wonky" with compromises to aesthetic problems by ignoring the curvature of the sphere and scale at the polar coordinates. ![enter image description here](https://i.stack.imgur.com/Qs5qf.jpg) Image © Copyright 1998-2013 Penny Arcade, Inc. The disconnected grid addresses the "wonkiness" as well as LOS...and likely solved for AOE too (constrained within the "separate areas of grid zones"). Nearby grid zones could be handled as a "hand wave" or even built-in as player-GM expectation. Both articles are great resources for creatively solving a problem and delivering an exciting table experience. **Hexagons** Read [*Geodesic Discrete Global Grid Systems*](http://webpages.sou.edu/~sahrk/dgg/pubs/gdggs03.pdf) by Kevin Sahr, Denis White, and A. Jon Kimerling. I skimmed it, but it offers some great ideas to **achieve full coverage with hexagons.** The research is quite detailed and expounds at length regarding the popularity and resolution available with hexagons.
If you are free to alter the dimensions of your planet, you can use any [one of these nice projections](http://en.wikipedia.org/wiki/List_of_map_projections) of a sphere's surface. Note that the projections have 24 squares across and top to bottom (15 degrees lat/long each) ie. a 24x24 grid. At 5' per grid square you end up with a circumference of 120' and a 19' radius. Note that most projections lose a lot of latitude squares near the poles. Now the trick becomes distance to visual horizon. But again the internet provides a [handy calculator](http://www.neoprogrammics.com/spheres/distance_to_horizon.php). Using this tool, assuming 6' person gives a surface to horizon of 13'. Making an assumption that double that is hidden. So absolute LOS = 26' = 5 or 6 squares. For fun give anyone in squares 5 and 6 a cover save.
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
Mike Krahulik of Penny Arcade modeled spherical, planar combat in *[D&D in the Elemental Chaos part 1](http://www.penny-arcade.com/2010/06/28/dd-in-the-elemental-chaos-part-1)* and *[D&D in the Elemental Chaos part 2](http://www.penny-arcade.com/2010/06/30/dd-in-the-elemental-chaos-part-2)*. A concern exists that LOE and AOE in Krahulik's models, as well as, prolonged combat and movement were not possible in the models documented. However, both context of Krahulik's efforts and his entries, he notes that the oddites of modeling the grid on the sphere as well as the success of the models in play. Krahulik talks about "...I was drawing these squares on a curved surface they got sort of wonky in some places, but that is why **I made separate [areas] of grid zones on each planet.**" The photo of these grids clearly shows Krahulik "solving for wonky" with compromises to aesthetic problems by ignoring the curvature of the sphere and scale at the polar coordinates. ![enter image description here](https://i.stack.imgur.com/Qs5qf.jpg) Image © Copyright 1998-2013 Penny Arcade, Inc. The disconnected grid addresses the "wonkiness" as well as LOS...and likely solved for AOE too (constrained within the "separate areas of grid zones"). Nearby grid zones could be handled as a "hand wave" or even built-in as player-GM expectation. Both articles are great resources for creatively solving a problem and delivering an exciting table experience. **Hexagons** Read [*Geodesic Discrete Global Grid Systems*](http://webpages.sou.edu/~sahrk/dgg/pubs/gdggs03.pdf) by Kevin Sahr, Denis White, and A. Jon Kimerling. I skimmed it, but it offers some great ideas to **achieve full coverage with hexagons.** The research is quite detailed and expounds at length regarding the popularity and resolution available with hexagons.
3d movement in D&D is made by dividing the space in cubes. Each cube that's less than 50% filled is a void space, each cube that's not is all filled. If you build a sphere made of cubes you'll get sections similar to a small circle drawn in Paint. If you get a sphere, sunlight (which rays are parallel) and a transparent sheet with parallel lines you can trace the projection of these lines on the sphere. Rotating the sphere exactly 90° on the 3 axis of the sheet will get you a gridded sheet. The elements of the grid near to the axes will be squared, and the boundaries between those areas will feature triangular elements. It's fine, I've explained earlier what they are, corners of a cube. Despite being triangular, they still count as squares. --- As an alternative, this really is a cube, but it looks like a sphere [![One practical way to map a square grid to a sphere](https://i.stack.imgur.com/EiHe4.jpg)](https://i.stack.imgur.com/EiHe4.jpg)
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
I would print out a [flattened geodesic sphere](http://sci-toys.com/scitoys/scitoys/mathematics/dome/paper_dome/color_complete.gif) for the minis alongside a printed out and [assembled version of the same](http://sci-toys.com/scitoys/scitoys/mathematics/dome/dome.html#paper_dome), using post-it notes or similar to reference where the minis map to on the sphere. For movement, it's triangles instead of squares. Movement along a side is adjacent triangles. I would probably disallow movement across corners, just to make things simpler.
If you are free to alter the dimensions of your planet, you can use any [one of these nice projections](http://en.wikipedia.org/wiki/List_of_map_projections) of a sphere's surface. Note that the projections have 24 squares across and top to bottom (15 degrees lat/long each) ie. a 24x24 grid. At 5' per grid square you end up with a circumference of 120' and a 19' radius. Note that most projections lose a lot of latitude squares near the poles. Now the trick becomes distance to visual horizon. But again the internet provides a [handy calculator](http://www.neoprogrammics.com/spheres/distance_to_horizon.php). Using this tool, assuming 6' person gives a surface to horizon of 13'. Making an assumption that double that is hidden. So absolute LOS = 26' = 5 or 6 squares. For fun give anyone in squares 5 and 6 a cover save.
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
I would print out a [flattened geodesic sphere](http://sci-toys.com/scitoys/scitoys/mathematics/dome/paper_dome/color_complete.gif) for the minis alongside a printed out and [assembled version of the same](http://sci-toys.com/scitoys/scitoys/mathematics/dome/dome.html#paper_dome), using post-it notes or similar to reference where the minis map to on the sphere. For movement, it's triangles instead of squares. Movement along a side is adjacent triangles. I would probably disallow movement across corners, just to make things simpler.
3d movement in D&D is made by dividing the space in cubes. Each cube that's less than 50% filled is a void space, each cube that's not is all filled. If you build a sphere made of cubes you'll get sections similar to a small circle drawn in Paint. If you get a sphere, sunlight (which rays are parallel) and a transparent sheet with parallel lines you can trace the projection of these lines on the sphere. Rotating the sphere exactly 90° on the 3 axis of the sheet will get you a gridded sheet. The elements of the grid near to the axes will be squared, and the boundaries between those areas will feature triangular elements. It's fine, I've explained earlier what they are, corners of a cube. Despite being triangular, they still count as squares. --- As an alternative, this really is a cube, but it looks like a sphere [![One practical way to map a square grid to a sphere](https://i.stack.imgur.com/EiHe4.jpg)](https://i.stack.imgur.com/EiHe4.jpg)
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
1. Buy a soccer ball 2. Add velcro 3. ??? 4. Profit On a more serious note, you'd need to sort out how movement would work, and possibly subdivide each patch into 5 or 6 triangles depending on the size of the pieces you're velcroing on. Additionally, you might want to prop the soccer ball up on stilts so that you could have units on the entire world.
If you are free to alter the dimensions of your planet, you can use any [one of these nice projections](http://en.wikipedia.org/wiki/List_of_map_projections) of a sphere's surface. Note that the projections have 24 squares across and top to bottom (15 degrees lat/long each) ie. a 24x24 grid. At 5' per grid square you end up with a circumference of 120' and a 19' radius. Note that most projections lose a lot of latitude squares near the poles. Now the trick becomes distance to visual horizon. But again the internet provides a [handy calculator](http://www.neoprogrammics.com/spheres/distance_to_horizon.php). Using this tool, assuming 6' person gives a surface to horizon of 13'. Making an assumption that double that is hidden. So absolute LOS = 26' = 5 or 6 squares. For fun give anyone in squares 5 and 6 a cover save.
29,234
In an upcoming campaign I'm planning, I would like a combat encounter to take place on a small sphere, with gravity pointing in towards the center. I'd like a sphere about 50' in diameter - something large enough to allow plenty of movement on its surface, but small enough so that players can typically run around it in a few turns. My problem is setting up the map. My first thought is to purchase a to-scale foam craft sphere, and provide miniatures with small pins so that they stick into the "board." The problem with this, tho, is that I would either need to draw on a geodesic grid by hand or go grid-less, which my group has not done before. My second thought is to simply use a flat map with "wrapping" edges, so that it acts somewhat sphere-like. The problems with this are that it distorts the distances greatly, and, more importantly, doesn't show the affect that the curvature of the sphere has on line-of-sight. I could get around this by imposing a circular limit to line-of-sight, but I feel it loses much of the effect. Has anyone attempted to run grid-based combat on a non-flat surface like this? What tools and rules made the combat go smoothly without ignoring important aspects of the unique terrain?
2013/10/07
['https://rpg.stackexchange.com/questions/29234', 'https://rpg.stackexchange.com', 'https://rpg.stackexchange.com/users/2161/']
1. Buy a soccer ball 2. Add velcro 3. ??? 4. Profit On a more serious note, you'd need to sort out how movement would work, and possibly subdivide each patch into 5 or 6 triangles depending on the size of the pieces you're velcroing on. Additionally, you might want to prop the soccer ball up on stilts so that you could have units on the entire world.
3d movement in D&D is made by dividing the space in cubes. Each cube that's less than 50% filled is a void space, each cube that's not is all filled. If you build a sphere made of cubes you'll get sections similar to a small circle drawn in Paint. If you get a sphere, sunlight (which rays are parallel) and a transparent sheet with parallel lines you can trace the projection of these lines on the sphere. Rotating the sphere exactly 90° on the 3 axis of the sheet will get you a gridded sheet. The elements of the grid near to the axes will be squared, and the boundaries between those areas will feature triangular elements. It's fine, I've explained earlier what they are, corners of a cube. Despite being triangular, they still count as squares. --- As an alternative, this really is a cube, but it looks like a sphere [![One practical way to map a square grid to a sphere](https://i.stack.imgur.com/EiHe4.jpg)](https://i.stack.imgur.com/EiHe4.jpg)
34,569,249
I saw the following program on a site and I cannot understand the output . <http://codepad.org/T0qblfYg> ``` #include <iostream> using namespace std; int i; class A { public: ~A() { i=10; } }; int foo() { i=3; A ob; return i; } int main() { cout <<"\n 1) Before calling i is "<<i; cout <<"\n 2) i = "<<i << " & the function return value = " << foo() << " and now i is " << i << endl; return 0; } ``` output is : ``` 1) Before calling i is 0 2) i = 10 & the function return value = 3 and now i is 10 ``` Now i is a global variable and destruction of A should have changed it to 10 before the call was returned to main. It is suggested that destruction of A happens after the call is returned to main but as a caller when i call a function i always expect the result to be final . Here the function return value is not 10 but 3 . My question is why did i see this and where exactly is destruction getting called .
2016/01/02
['https://Stackoverflow.com/questions/34569249', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1636300/']
The order of evaluation is not what you would expect. When calling functions, the arguments to the functions can be evaluated in any order and even interleaved. So if you call ``` f( g(), h(), i() ); ``` the order in which `g()`, `h()` and `i()` are called is up to the compiler. *This also applies to operators.* When you have an expression of the form ``` expr1 << expr2 << expr3 << expr4; ``` the order in which the expressions are evaluated is arbitrary. You only know, that the `operator<<` calls will be evaluated from left to right, because the operator is left-to right associative and you could rewrite the expression as ``` ((expr1 << expr2) << expr3) << expr4; ``` The syntax tree looks like that: ``` << / \ << expr4 / \ << expr3 / \ expr1 expr2 ``` The leafs of the syntax tree can be evaluated in any order, even interleaved. And after all the leafs of an operator or function call are evaluated, the function itself will be called. In your case `foo()` seems to get called before `i` gets printed out the first time and it is perfectly valid (though unexpected) behaviour.
> > why did i see this and where exactly is destruction getting called . > > > I believe the instance destructor is called when that instance goes out of scope. You might test it the following way (by controlling the scope of the instance -- see bar() below) Note - to reduce confusion, I 1) renamed the global and 2) explicitly controlled when the foo or bar is called w.r.t. subsequent cout. ``` int g; // uninitialized! class A { public: ~A() { g=10; } }; int foo() { g=3; A ob; return g; } // <<<<<<<<<<< ob destructor called here int bar() { g=3; { A ob; } // <<<<<<<<<<< ob destructor called here return g; } int t272(void) { g = 0; // force to 0 std::cout << "\n 1) Before calling foo g is " << g; int fooRetVal = foo(); // control when called // do not leave up to compiler std::cout << "\n 2) after foo, g = " << g << "\n 3) fooRetVal = " << fooRetVal << "\n 4) and now g = " << g << std::endl; g = 0; // force to 0 std::cout << "\n 1) Before calling bar g is " << g; int barRetVal = bar(); // control when called // do not leave up to compiler std::cout << "\n 2) after bar, g = " << g << "\n 3) barRetVal = " << barRetVal << "\n 4) and now g = " << g << std::endl; return (0); } ``` With the output ``` 1) Before calling foo g is 0 2) after foo, g = 10 3) fooRetVal = 3 <<< dtor called after return of foo 4) and now g = 10 1) Before calling bar g is 0 2) after bar, g = 10 3) barRetVal = 10 <<< dtor was called before return of bar 4) and now g = 10 ```
34,569,249
I saw the following program on a site and I cannot understand the output . <http://codepad.org/T0qblfYg> ``` #include <iostream> using namespace std; int i; class A { public: ~A() { i=10; } }; int foo() { i=3; A ob; return i; } int main() { cout <<"\n 1) Before calling i is "<<i; cout <<"\n 2) i = "<<i << " & the function return value = " << foo() << " and now i is " << i << endl; return 0; } ``` output is : ``` 1) Before calling i is 0 2) i = 10 & the function return value = 3 and now i is 10 ``` Now i is a global variable and destruction of A should have changed it to 10 before the call was returned to main. It is suggested that destruction of A happens after the call is returned to main but as a caller when i call a function i always expect the result to be final . Here the function return value is not 10 but 3 . My question is why did i see this and where exactly is destruction getting called .
2016/01/02
['https://Stackoverflow.com/questions/34569249', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1636300/']
Destructors run **after** the expression in the `return` statement is evaluated. If it was the other way around you'd be in deep trouble: ``` std::string f() { std::string res = "abcd"; return res; } ``` This function should return a string object that holds `"abcd"`, not a copy of a string object that has already been destroyed.
> > why did i see this and where exactly is destruction getting called . > > > I believe the instance destructor is called when that instance goes out of scope. You might test it the following way (by controlling the scope of the instance -- see bar() below) Note - to reduce confusion, I 1) renamed the global and 2) explicitly controlled when the foo or bar is called w.r.t. subsequent cout. ``` int g; // uninitialized! class A { public: ~A() { g=10; } }; int foo() { g=3; A ob; return g; } // <<<<<<<<<<< ob destructor called here int bar() { g=3; { A ob; } // <<<<<<<<<<< ob destructor called here return g; } int t272(void) { g = 0; // force to 0 std::cout << "\n 1) Before calling foo g is " << g; int fooRetVal = foo(); // control when called // do not leave up to compiler std::cout << "\n 2) after foo, g = " << g << "\n 3) fooRetVal = " << fooRetVal << "\n 4) and now g = " << g << std::endl; g = 0; // force to 0 std::cout << "\n 1) Before calling bar g is " << g; int barRetVal = bar(); // control when called // do not leave up to compiler std::cout << "\n 2) after bar, g = " << g << "\n 3) barRetVal = " << barRetVal << "\n 4) and now g = " << g << std::endl; return (0); } ``` With the output ``` 1) Before calling foo g is 0 2) after foo, g = 10 3) fooRetVal = 3 <<< dtor called after return of foo 4) and now g = 10 1) Before calling bar g is 0 2) after bar, g = 10 3) barRetVal = 10 <<< dtor was called before return of bar 4) and now g = 10 ```
39,332
> > [Galatians 5:19 Now](https://biblehub.com/galatians/5-19.htm) the works of the flesh are manifest, which are > these; Adultery, fornication, uncleanness, lasciviousness, > > > What is the difference between adultery, fornication, uncleanness & lasciviousness in the verse above? I looked into the Greek from [this website](http://www.godrules.net/library/kjvstrongs/kjvstrongsgal5.htm) but could not understand well.
2019/03/06
['https://hermeneutics.stackexchange.com/questions/39332', 'https://hermeneutics.stackexchange.com', 'https://hermeneutics.stackexchange.com/users/26800/']
The word ἀδελφός (adelphos) occurs well over 300 times in the NT for which BDAG has two basic meanings: > > (1) **a male from the same womb as the reference person, *brother***, > eg, **Matt 1:2, 11, 4:18, 21, Gal 1:19**, etc. … Hence there is no > doubt that in Luke 21:16 that the plural "adelphoi" = brothers and > sisters … > > > **(2) a person viewed as a brother in terms of a close affinity, *brother, fellow member, member, associate*** > > > (a) one who shares beliefs eg, matt 12:50, Mark 3:35 … > > > (b) a compatriot Lev 10:4, 15:3, 12, 17:15, Acts 2:29, 3:17 etc. > > > (c) without reference to a common nationality or faith, neighbor 9or > an intimate friend), eg, Matt 5:22, 7:3, etc. > > > (d) Form of addressused by a king to persons in very high position - > (used in classical, non-Biblical literature) > > > I have only included the highlights from BDAG to provide the general idea. For more detail consult BDAG. However, it appears correct that "adelphos" can, indeed, be used in the sense of fellow countryman or compatriot, or even close associate.
In I John 2:12, the very next verse, John speaks to 'little children'. In such a context, it is my own understanding that the 'brother' referred to in the previous few verses would be a sibling. Or like a sibling - namely a brother in Christ. To hate one's own Christian brother is a terrible thing. I believe that is what John is talking about.
39,332
> > [Galatians 5:19 Now](https://biblehub.com/galatians/5-19.htm) the works of the flesh are manifest, which are > these; Adultery, fornication, uncleanness, lasciviousness, > > > What is the difference between adultery, fornication, uncleanness & lasciviousness in the verse above? I looked into the Greek from [this website](http://www.godrules.net/library/kjvstrongs/kjvstrongsgal5.htm) but could not understand well.
2019/03/06
['https://hermeneutics.stackexchange.com/questions/39332', 'https://hermeneutics.stackexchange.com', 'https://hermeneutics.stackexchange.com/users/26800/']
The word ἀδελφός (adelphos) occurs well over 300 times in the NT for which BDAG has two basic meanings: > > (1) **a male from the same womb as the reference person, *brother***, > eg, **Matt 1:2, 11, 4:18, 21, Gal 1:19**, etc. … Hence there is no > doubt that in Luke 21:16 that the plural "adelphoi" = brothers and > sisters … > > > **(2) a person viewed as a brother in terms of a close affinity, *brother, fellow member, member, associate*** > > > (a) one who shares beliefs eg, matt 12:50, Mark 3:35 … > > > (b) a compatriot Lev 10:4, 15:3, 12, 17:15, Acts 2:29, 3:17 etc. > > > (c) without reference to a common nationality or faith, neighbor 9or > an intimate friend), eg, Matt 5:22, 7:3, etc. > > > (d) Form of addressused by a king to persons in very high position - > (used in classical, non-Biblical literature) > > > I have only included the highlights from BDAG to provide the general idea. For more detail consult BDAG. However, it appears correct that "adelphos" can, indeed, be used in the sense of fellow countryman or compatriot, or even close associate.
The definition is found in Greek Lexicon de Thayer: Thayer’s Greek Lexicon Strong’s NT 80: ἀδελφός ἀδελφός, (οῦ, ὁ (from ἆ copulative and δελφύς, **from the same womb**), however, the word was used for the father Jacob in Genesis 37:3-4 with four different wives (septuagint). There was an advance of meaning of the word for Jacob. All these were brother cousins (adelphos) by the same father.
39,332
> > [Galatians 5:19 Now](https://biblehub.com/galatians/5-19.htm) the works of the flesh are manifest, which are > these; Adultery, fornication, uncleanness, lasciviousness, > > > What is the difference between adultery, fornication, uncleanness & lasciviousness in the verse above? I looked into the Greek from [this website](http://www.godrules.net/library/kjvstrongs/kjvstrongsgal5.htm) but could not understand well.
2019/03/06
['https://hermeneutics.stackexchange.com/questions/39332', 'https://hermeneutics.stackexchange.com', 'https://hermeneutics.stackexchange.com/users/26800/']
The word ἀδελφός (adelphos) occurs well over 300 times in the NT for which BDAG has two basic meanings: > > (1) **a male from the same womb as the reference person, *brother***, > eg, **Matt 1:2, 11, 4:18, 21, Gal 1:19**, etc. … Hence there is no > doubt that in Luke 21:16 that the plural "adelphoi" = brothers and > sisters … > > > **(2) a person viewed as a brother in terms of a close affinity, *brother, fellow member, member, associate*** > > > (a) one who shares beliefs eg, matt 12:50, Mark 3:35 … > > > (b) a compatriot Lev 10:4, 15:3, 12, 17:15, Acts 2:29, 3:17 etc. > > > (c) without reference to a common nationality or faith, neighbor 9or > an intimate friend), eg, Matt 5:22, 7:3, etc. > > > (d) Form of addressused by a king to persons in very high position - > (used in classical, non-Biblical literature) > > > I have only included the highlights from BDAG to provide the general idea. For more detail consult BDAG. However, it appears correct that "adelphos" can, indeed, be used in the sense of fellow countryman or compatriot, or even close associate.
**What's the meaning of brother in 1 John 2.9-11?** In context of John's writings,the expression "brothers" refers to the anointed brothers of Christ, more commonly known as "saints" they are also referred to as "the least of these brothers or sisters of mine. Matthew 25:40 NET > > 40" And the king will answer them,[d] ‘I tell you the truth,[e] just > as you did it for one of **the least of these brothers** or sisters[f] of > mine, you did it for me." > > >
34,459,128
I have Form1 and Form2 simultaneously active, Form2 has a TabControl and I want button click event on Form1 to change 'Enable' property of tabControl on Form2 TabControl on Form2 is set to `tabControl1.enabled = false;` and Form1 acts as a login form for Form2, so I need a Login button on Form1 to enable 'tabControl1' on Form2 I can access the property by setting `private System.Windows.Forms.TabControl tabControl1;` to 'Public', still, using the following on button click event on Form1 doesn't do anything. ``` Form2 formnew2 = new Form2(); formnew2.tabControl1.Enabled = true; ``` Can someone please provide a simple example to help me understand or link to a previously answered question
2015/12/25
['https://Stackoverflow.com/questions/34459128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2095012/']
You get this error since `xxxSlider.value` is of type `Float`, whereas `UIColor` initialiser calls for type `CGFloat` for all four arguments. You can redeem this error by changing the line into: ``` colorView.backgroundColor = UIColor(red: CGFloat(redSlider.value), green: CGFloat(greenSlider.value), blue: CGFloat(blueSlider.value), alpha: 1.0) ``` However, to achieve the goal of your program, there are more issues that needs to be addressed. I'll go through these below. --- First of all, you have one `@IBAction` as well as one `@IBOutlet` connected to each slider. With former (action), the latter is really not needed. Hence, remove the `@IBOutlet` connections (code as well as connections) ``` @IBOutlet weak var redSlider: UISlider! // remove (also remove connection) @IBOutlet weak var greenSlider: UISlider! // ... @IBOutlet weak var blueSlider: UISlider! // ... ``` Now, in your `@IBAction`:s, you define a local variable that is never used ``` var red = CGFloat(sender.value) // in @IBAction func redValueChanged(... var green = CGFloat(sender.value) // ... var blue = CGFloat(sender.value) // ... ``` In their current form, you don't need these, so remove these also. Instead, in the scope of the class (see full program below), declare three class variables to hold the current value of each slide (note: these are not to be defined *within* a class method/action/function). Moreover, let these be of type `CGFloat` rather than `Float`, as initialiser of `UIColor` that we use to change background colour takes arguments of type `CGFloat`: ``` var redValue: CGFloat = 0.5 // 0.5: middle slider (init) var greenValue: CGFloat = 0.5 var blueValue: CGFloat = 0.5 ``` In your `@IBAction` closures, change these class variables by the `sender.value` (which holds slider value). After update of variable value, call your `displayColors()` method (that we will look at shortly). ``` // Actions @IBAction func redValueChanged(sender: UISlider) { redValue = CGFloat(sender.value) displayColors() } @IBAction func greenValueChanged(sender: UISlider) { greenValue = CGFloat(sender.value) displayColors() } @IBAction func blueValueChanged(sender: UISlider) { blueValue = CGFloat(sender.value) displayColors() } ``` Your `displayColors()` can be simplified simply to: ``` func displayColors() { colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } ``` Finally, not that the overridden method `viewDidLoad()` is only called once when the ViewController is loaded, so in this case, you can see this as an initialiser for your ViewController. The only thing we want to do here is set the default colour: RGB(0.5, 0.5, 0.5) = gray. ``` override func viewDidLoad() { super.viewDidLoad() // Initial BG color (viewDidLoad() loads only once when ViewController view loads) colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } ``` And we're done! --- Wrapping it up, your ViewController class should now look like the following ``` import UIKit class ViewController: UIViewController { // Properties var redValue: CGFloat = 0.5 var greenValue: CGFloat = 0.5 var blueValue: CGFloat = 0.5 @IBOutlet weak var colorView: UIView! // Actions @IBAction func redValueChanged(sender: UISlider) { redValue = CGFloat(sender.value) displayColors() } @IBAction func greenValueChanged(sender: UISlider) { greenValue = CGFloat(sender.value) displayColors() } @IBAction func blueValueChanged(sender: UISlider) { blueValue = CGFloat(sender.value) displayColors() } func displayColors() { colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } override func viewDidLoad() { super.viewDidLoad() // Initial BG color (viewDidLoad() loads only once when ViewController view loads) colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } } ``` Running your app produces the following behaviour: [![enter image description here](https://i.stack.imgur.com/jJGuP.gif)](https://i.stack.imgur.com/jJGuP.gif)
`CGFloat` and `Float` are technically different types. The Swift programming language does not do any numeric type conversion / coercion. As such, you must explicitly convert from `Float` to `CGFloat` using one of the constructors on `CGFloat`. ``` colorView.backgroundColor = UIColor(red: CGFloat(redSlider.value), green: CGFloat(greenSlider.value), blue: CGFloat(blueSlider.value), alpha: 1.0) ``` You can read more about [Numeric Type Conversion](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-ID324) in [The Swift Programming Language](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/).
34,459,128
I have Form1 and Form2 simultaneously active, Form2 has a TabControl and I want button click event on Form1 to change 'Enable' property of tabControl on Form2 TabControl on Form2 is set to `tabControl1.enabled = false;` and Form1 acts as a login form for Form2, so I need a Login button on Form1 to enable 'tabControl1' on Form2 I can access the property by setting `private System.Windows.Forms.TabControl tabControl1;` to 'Public', still, using the following on button click event on Form1 doesn't do anything. ``` Form2 formnew2 = new Form2(); formnew2.tabControl1.Enabled = true; ``` Can someone please provide a simple example to help me understand or link to a previously answered question
2015/12/25
['https://Stackoverflow.com/questions/34459128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2095012/']
You get this error since `xxxSlider.value` is of type `Float`, whereas `UIColor` initialiser calls for type `CGFloat` for all four arguments. You can redeem this error by changing the line into: ``` colorView.backgroundColor = UIColor(red: CGFloat(redSlider.value), green: CGFloat(greenSlider.value), blue: CGFloat(blueSlider.value), alpha: 1.0) ``` However, to achieve the goal of your program, there are more issues that needs to be addressed. I'll go through these below. --- First of all, you have one `@IBAction` as well as one `@IBOutlet` connected to each slider. With former (action), the latter is really not needed. Hence, remove the `@IBOutlet` connections (code as well as connections) ``` @IBOutlet weak var redSlider: UISlider! // remove (also remove connection) @IBOutlet weak var greenSlider: UISlider! // ... @IBOutlet weak var blueSlider: UISlider! // ... ``` Now, in your `@IBAction`:s, you define a local variable that is never used ``` var red = CGFloat(sender.value) // in @IBAction func redValueChanged(... var green = CGFloat(sender.value) // ... var blue = CGFloat(sender.value) // ... ``` In their current form, you don't need these, so remove these also. Instead, in the scope of the class (see full program below), declare three class variables to hold the current value of each slide (note: these are not to be defined *within* a class method/action/function). Moreover, let these be of type `CGFloat` rather than `Float`, as initialiser of `UIColor` that we use to change background colour takes arguments of type `CGFloat`: ``` var redValue: CGFloat = 0.5 // 0.5: middle slider (init) var greenValue: CGFloat = 0.5 var blueValue: CGFloat = 0.5 ``` In your `@IBAction` closures, change these class variables by the `sender.value` (which holds slider value). After update of variable value, call your `displayColors()` method (that we will look at shortly). ``` // Actions @IBAction func redValueChanged(sender: UISlider) { redValue = CGFloat(sender.value) displayColors() } @IBAction func greenValueChanged(sender: UISlider) { greenValue = CGFloat(sender.value) displayColors() } @IBAction func blueValueChanged(sender: UISlider) { blueValue = CGFloat(sender.value) displayColors() } ``` Your `displayColors()` can be simplified simply to: ``` func displayColors() { colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } ``` Finally, not that the overridden method `viewDidLoad()` is only called once when the ViewController is loaded, so in this case, you can see this as an initialiser for your ViewController. The only thing we want to do here is set the default colour: RGB(0.5, 0.5, 0.5) = gray. ``` override func viewDidLoad() { super.viewDidLoad() // Initial BG color (viewDidLoad() loads only once when ViewController view loads) colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } ``` And we're done! --- Wrapping it up, your ViewController class should now look like the following ``` import UIKit class ViewController: UIViewController { // Properties var redValue: CGFloat = 0.5 var greenValue: CGFloat = 0.5 var blueValue: CGFloat = 0.5 @IBOutlet weak var colorView: UIView! // Actions @IBAction func redValueChanged(sender: UISlider) { redValue = CGFloat(sender.value) displayColors() } @IBAction func greenValueChanged(sender: UISlider) { greenValue = CGFloat(sender.value) displayColors() } @IBAction func blueValueChanged(sender: UISlider) { blueValue = CGFloat(sender.value) displayColors() } func displayColors() { colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } override func viewDidLoad() { super.viewDidLoad() // Initial BG color (viewDidLoad() loads only once when ViewController view loads) colorView.backgroundColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0) } } ``` Running your app produces the following behaviour: [![enter image description here](https://i.stack.imgur.com/jJGuP.gif)](https://i.stack.imgur.com/jJGuP.gif)
In my app using Swift 4, I am using this to convert Float to CGFloat: ``` let slider = sender as? UISlider let val = CGFloat((slider?.value)!) ``` And then using the variable val as needed, which in my case is for hue, saturation and brightness, e.g. ``` coolButton.saturation = val ```
34,459,128
I have Form1 and Form2 simultaneously active, Form2 has a TabControl and I want button click event on Form1 to change 'Enable' property of tabControl on Form2 TabControl on Form2 is set to `tabControl1.enabled = false;` and Form1 acts as a login form for Form2, so I need a Login button on Form1 to enable 'tabControl1' on Form2 I can access the property by setting `private System.Windows.Forms.TabControl tabControl1;` to 'Public', still, using the following on button click event on Form1 doesn't do anything. ``` Form2 formnew2 = new Form2(); formnew2.tabControl1.Enabled = true; ``` Can someone please provide a simple example to help me understand or link to a previously answered question
2015/12/25
['https://Stackoverflow.com/questions/34459128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2095012/']
`CGFloat` and `Float` are technically different types. The Swift programming language does not do any numeric type conversion / coercion. As such, you must explicitly convert from `Float` to `CGFloat` using one of the constructors on `CGFloat`. ``` colorView.backgroundColor = UIColor(red: CGFloat(redSlider.value), green: CGFloat(greenSlider.value), blue: CGFloat(blueSlider.value), alpha: 1.0) ``` You can read more about [Numeric Type Conversion](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-ID324) in [The Swift Programming Language](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/).
In my app using Swift 4, I am using this to convert Float to CGFloat: ``` let slider = sender as? UISlider let val = CGFloat((slider?.value)!) ``` And then using the variable val as needed, which in my case is for hue, saturation and brightness, e.g. ``` coolButton.saturation = val ```
92,034
The gospel of Matthew records that after Jesus’ death, the Pharisees and teachers of the Law went to Pilate to ask for a guard, since they remembered that Jesus said he would rise again on the third day. > > “The next day, the one after Preparation Day, the chief priests and the Pharisees went to Pilate. “Sir,” they said, “we remember that while he was still alive that deceiver said, ‘After three days I will rise again.’ So give the order for the tomb to be made secure until the third day. Otherwise, his disciples may come and steal the body and tell the people that he has been raised from the dead. This last deception will be worse than the first.”” > ‭‭Matthew‬ ‭27:62-64‬ ‭ > > > However, part of the whole surprise of Jesus’ resurrection was that despite Jesus telling everyone he would rise again, the disciples still didn’t understand it. Further, the concept of a resurrection like the one of Jesus being physically resurrected was basically a new and radical concept that was not widely believed at all. So: How is it that the Jews would be aware of Jesus’ resurrecting on the third day when the disciples weren’t? And how can they have been so aware of it to the point of sending guards to the tomb? Was sending a guard to the tomb of a dead person even a common thing during that time if people don’t even rise from the dead? What happened to all the guards? If the tomb stone had been rolled away and people spread the rumour that Jesus’ body had been stolen, would the guards not have faced strong discipline for letting Jesus’ body be “stolen”? (in accordance with what Matthew writes about people believing the body was stolen) I don’t understand why a guard would be sent to the tomb of a dead person (especially since the Pharisees believed Jesus was just a human!), and I don’t understand how the Pharisees could remember that Jesus would rise from the dead on the third day (when the disciples couldn’t), yet also still spread a rumour that his body was stolen, especially if they knew they had guards there in the first place. I hear skeptics talk about how Matthew made up the guard story as an apologetic resource to defend the empty tomb, so if I could get some defence/ clarification on this and the questions above that would greatly help.
2022/07/30
['https://christianity.stackexchange.com/questions/92034', 'https://christianity.stackexchange.com', 'https://christianity.stackexchange.com/users/59680/']
The Pharisees did not believe that a crucified Jesus of Nazareth would ever rise from the dead. Had they believed he was the foretold Messiah, they would have taken the possibility of that seriously. Given that they wanted this Jesus out of the way due to his claims, they wanted him to stay out of the way once they'd got the Roman authorities to crucify him. That was when they remembered that one of Jesus' claims while alive was that he would rise from the dead, and ***that*** made them think of tricks his disciples might employ to deceive people into thinking Christ was now alive. The verse you quote is very clear in showing their reasoning behind asking for a guard at the tomb: "his disciples may come and steal the body and tell the people that he has been raised from the dead. This last deception will be worse than the first." They'd also called Jesus *"that deceiver"* to Pilate, so they did not believe Jesus would actually arise (vs.63). This categorically proves that these men did ***not*** believe Jesus would rise from the dead. But given that, while alive, Jesus three times stated to his disciples that he would arise, the simple reason why the disciples were not full of faith about that was that Jesus' arrest and sentence to crucifixion was a bombshell, and they no doubt thought they could be rounded up next, hence the way they kept out of sight behind locked doors. They supposed Jesus would triumph over the Romans, not that the Romans would kill him! The Pharisees, however, knew that if a trick was played, with the corpse of Jesus taken away in the night, the disciples could then spread a story that he had been resurrected, and that deception would be far harder for them to deal with. So they asked Pilate for permission to set a seal and a guard over the tomb, that happened, and when the guards reported the miracle of the resurrection, they were bribed to spread the lie that, while they were asleep, the disciples came to do just that. It's very plainly stated in the gospel account. Why would skeptical disbelief about Matthew's account require more consideration than Matthew's account, for Matthew saw with his own eyes the resurrected Christ? There's no way Matthew would need to invent *"an apologetic resource to defend the empty tomb,"* when the empty tomb was the proof the disciples needed to restore their faith in Jesus' promise that, on the third day, he would be raised! Proof substantiated shortly after by the followers then seeing the living Christ, and even touching his wounds, and eating with him. Then when they went to the mountain specified in Galilee, he met with them to give parting instructions, and they saw him literally ascend, bodily, up into the sky till clouds hid him from their sight. So, **the answer to your main question is that the Pharisees did ***not*** anticipate Jesus' resurrection (at any time, let alone before the disciples started to believe in it). The Pharisees never, at any point, expected Jesus to arise from the dead.** They ***did*** expect the disciples to do a trick to deceive the populace that that had happened, and that was the reason for them getting a Roman guard placed, with a sealed stone over the tomb. Their actions were those of total disbelievers who wanted to second-guess the disciples. They guessed wrong, for the resurrection happened before any of the women followers even got to the tomb, to then tell the disciples they'd seen the risen Christ. The strange thing is that the last two sentences of the text you quote answers your question. And Matthew 28:11-15 deals with your other question about the guards.
**The Pharisees' reasoning** The Pharisees did not believe Jesus would rise on the third day. They knew that Jesus had prophesied it would happen, and they wanted to prevent anyone from believing the prophecy had been fulfilled through deception on the part of the disciples (by stealing the body). The Pharisees did not simply want to kill Jesus, they wanted to destroy His movement. Having Him put to death by crucifixion would be humiliating, and having Him put to death *by Rome* would intimate that His teachings were opposed by the might of Rome. The slow, tortuous death by crucifixion also afforded ample opportunity to mock Him as He suffered (see Matthew 27:39-43). They realized that if Jesus were thought to have risen from the dead, it could further strengthen His movement (it did). This is what is meant by "This last deception will be worse than the first". If the Pharisees genuinely believed Jesus was the Son God who would conquer death...of course they wouldn't have posted a guard! What chance would the guards have against the power of God? It was because the Pharisees *did not believe* in Jesus that the posting of the guard (to prevent theft of the body) made sense in their twisted, doubting minds. -- **The disciples' struggle to believe** That the promised Messiah would be put to death by Rome, rather than conquering Rome, was so foreign to contemporary thought that many of Jesus' followers genuinely entertained doubts when they saw Jesus arrested and put to death. Forasmuch as He had told Him it would happen, they were shocked and grieving. It is not that the Pharisees understood Jesus' prophecy and the disciples did not, rather: * The Pharisees didn't believe in Jesus before He died and still didn't believe after He died * The disciples did believe in Jesus before He died and were struggling to believe after He died -- **The apologetic value of the story of the guards** Posting a guard at a tomb was not standard practice; it was specifically to prevent the theft of Jesus' body--which the Pharisees realized could fuel Jesus' movement--that guards were posted in this case. Although the Pharisees did believe in the resurrection (the Sadducees did not), they believed it would happen only at the end of the world, and certainly not begin in their own lifetimes. As William Lane Craig (and others) have pointed out, the argument between the Pharisees and the believers in Christ presupposes the empty tomb: > > Christian: 'The Lord is risen!' > > > Jew: 'No, his disciples stole away his body.' > > > Christian: 'The guard at the tomb would have prevented any such > theft.' > > > Jew: 'No, his disciples stole away his body while the guard slept.' > > > Christian: 'The chief priests bribed the guard to say this.' ([source](https://www.reasonablefaith.org/writings/scholarly-writings/historical-jesus/the-guard-at-the-tomb)) > > > As Craig further points out: > > The sleeping of the guard could only have been a Jewish development, as it would serve no purpose to the Christian polemic (*ibid*) > > > The argument would have never progressed this far unless both sides agreed: 1. The tomb was empty & 2. There was a guard posted The Pharisees had no reason to agree to those points unless they were incontrovertibly true. -- **The reliability of Matthew** My work on the Synoptic Problem & the authorship of the Gospels leads me decisively to the conclusion that the Gospel of Matthew was written in or near Judea within a few years of Easter. If this is true, Matthew's defense of the resurrection would be ineffective--as his evidence could be easily rebutted by people who were there and knew what really happened--unless the claims he made about the tomb & guards were actually true. This is why the account of the guards is found only in Matthew--Matthew's audience (in/near Judea) has the ability to fact check this part of the story. Mark's audience in Rome, Luke's audience in Greece, and John's audience in Ephesus, would have no ability to validate the story about the guards, so the account about the guards would at best be a distraction from the main point they were trying to make. But for Matthew, writing to the local population, the story about the guards was potent, verifiable evidence of the veracity of his claims. The Jewish leaders had every incentive in the world to produce a crucified body and squash the nascent Christian movement. The fact that they were unable to do so stands resolutely in favor of the view that Jesus really was buried in a tomb and the tomb really was found empty a few days later. Matthew could only get away with his claims about the empty tomb & the guards if: 1. Everybody in the area knew it was true OR 2. The text was written so long after the fact that the people familiar with the events were dead. This is why atheists work so hard to claim that the Gospel of Matthew was written a generation or more after Easter. For my work demonstrating that the Gospel of Matthew was written by the apostle Matthew well within the lifetime and geographic reach of eyewitnesses, see this video series: [Who When & Why - the Writing of the Gospels](https://youtube.com/playlist?list=PLGACqQS4ut5iFeKqqvQPK_dzMnjF7NBhw)
92,034
The gospel of Matthew records that after Jesus’ death, the Pharisees and teachers of the Law went to Pilate to ask for a guard, since they remembered that Jesus said he would rise again on the third day. > > “The next day, the one after Preparation Day, the chief priests and the Pharisees went to Pilate. “Sir,” they said, “we remember that while he was still alive that deceiver said, ‘After three days I will rise again.’ So give the order for the tomb to be made secure until the third day. Otherwise, his disciples may come and steal the body and tell the people that he has been raised from the dead. This last deception will be worse than the first.”” > ‭‭Matthew‬ ‭27:62-64‬ ‭ > > > However, part of the whole surprise of Jesus’ resurrection was that despite Jesus telling everyone he would rise again, the disciples still didn’t understand it. Further, the concept of a resurrection like the one of Jesus being physically resurrected was basically a new and radical concept that was not widely believed at all. So: How is it that the Jews would be aware of Jesus’ resurrecting on the third day when the disciples weren’t? And how can they have been so aware of it to the point of sending guards to the tomb? Was sending a guard to the tomb of a dead person even a common thing during that time if people don’t even rise from the dead? What happened to all the guards? If the tomb stone had been rolled away and people spread the rumour that Jesus’ body had been stolen, would the guards not have faced strong discipline for letting Jesus’ body be “stolen”? (in accordance with what Matthew writes about people believing the body was stolen) I don’t understand why a guard would be sent to the tomb of a dead person (especially since the Pharisees believed Jesus was just a human!), and I don’t understand how the Pharisees could remember that Jesus would rise from the dead on the third day (when the disciples couldn’t), yet also still spread a rumour that his body was stolen, especially if they knew they had guards there in the first place. I hear skeptics talk about how Matthew made up the guard story as an apologetic resource to defend the empty tomb, so if I could get some defence/ clarification on this and the questions above that would greatly help.
2022/07/30
['https://christianity.stackexchange.com/questions/92034', 'https://christianity.stackexchange.com', 'https://christianity.stackexchange.com/users/59680/']
The Pharisees did not believe that a crucified Jesus of Nazareth would ever rise from the dead. Had they believed he was the foretold Messiah, they would have taken the possibility of that seriously. Given that they wanted this Jesus out of the way due to his claims, they wanted him to stay out of the way once they'd got the Roman authorities to crucify him. That was when they remembered that one of Jesus' claims while alive was that he would rise from the dead, and ***that*** made them think of tricks his disciples might employ to deceive people into thinking Christ was now alive. The verse you quote is very clear in showing their reasoning behind asking for a guard at the tomb: "his disciples may come and steal the body and tell the people that he has been raised from the dead. This last deception will be worse than the first." They'd also called Jesus *"that deceiver"* to Pilate, so they did not believe Jesus would actually arise (vs.63). This categorically proves that these men did ***not*** believe Jesus would rise from the dead. But given that, while alive, Jesus three times stated to his disciples that he would arise, the simple reason why the disciples were not full of faith about that was that Jesus' arrest and sentence to crucifixion was a bombshell, and they no doubt thought they could be rounded up next, hence the way they kept out of sight behind locked doors. They supposed Jesus would triumph over the Romans, not that the Romans would kill him! The Pharisees, however, knew that if a trick was played, with the corpse of Jesus taken away in the night, the disciples could then spread a story that he had been resurrected, and that deception would be far harder for them to deal with. So they asked Pilate for permission to set a seal and a guard over the tomb, that happened, and when the guards reported the miracle of the resurrection, they were bribed to spread the lie that, while they were asleep, the disciples came to do just that. It's very plainly stated in the gospel account. Why would skeptical disbelief about Matthew's account require more consideration than Matthew's account, for Matthew saw with his own eyes the resurrected Christ? There's no way Matthew would need to invent *"an apologetic resource to defend the empty tomb,"* when the empty tomb was the proof the disciples needed to restore their faith in Jesus' promise that, on the third day, he would be raised! Proof substantiated shortly after by the followers then seeing the living Christ, and even touching his wounds, and eating with him. Then when they went to the mountain specified in Galilee, he met with them to give parting instructions, and they saw him literally ascend, bodily, up into the sky till clouds hid him from their sight. So, **the answer to your main question is that the Pharisees did ***not*** anticipate Jesus' resurrection (at any time, let alone before the disciples started to believe in it). The Pharisees never, at any point, expected Jesus to arise from the dead.** They ***did*** expect the disciples to do a trick to deceive the populace that that had happened, and that was the reason for them getting a Roman guard placed, with a sealed stone over the tomb. Their actions were those of total disbelievers who wanted to second-guess the disciples. They guessed wrong, for the resurrection happened before any of the women followers even got to the tomb, to then tell the disciples they'd seen the risen Christ. The strange thing is that the last two sentences of the text you quote answers your question. And Matthew 28:11-15 deals with your other question about the guards.
The leaders of the people requested a guard be posted because they listened and understood what was spoken to them. They identified Jesus of Nazareth as the Christ, and wanted him dead. Once dead, they where concerned an event would happen. They likely where unsure what exactly would happen. Jesus mentioned he would raise up the Temple in three days, and the statement confused them. But they would have known the Christ would be cut off, yet live. 1. Though the birth of the Christ can't be predicted from reading the Prophets, his approximate lifespan can be identified in advance. 2. All Jerusalem was disturbed at the arrival of the Magi. It was now known the Christ was born, his family and location identified. At his birth, Joseph had registered with the tax and cencus, as being of the House of David. 3. Jesus opened the eyes of the blind. A sign. 4. He healed lepers, and instructed them to present themselves to the Priest. The Priest where required to preform the Offering for the Leper in the Day of His Cleansing. Never before preformed by the Priesthood, it was a sign. 5. He raised the dead. 6. The leaders could predict the Christ's entry into the Temple to an approximate one hour window. 7. When examined by the Priest, Jesus told the leaders in person, the Parable of the Husband Men. He stated the men knew who the Heir was, planned to kill him, and seize the inheritance. The leaders listened and understood Jesus was referring to them. These are only a few selected items of evidence condemning the leaders of the people. They understood they were killing the Christ. The Christ was not a mere mortal, as the Son of God, he is simply not going to stay in a tomb. He would not see corruption, as foretold of the Holy One. The Sign of Jonah was mentioned to the leaders, as a Sign to their generation, just as Jonah was dead for three days and three nights. The leaders would have known any resurrection would occur around dawn on Sunday.
17,269,744
HTML: ```html <input id="otherCheckbox2" type="checkbox" value="Accepted" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" /> <span style="color: Black">Accepted</span> <br /> <input id="otherCheckbox3" type="checkbox" value="Contracted" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" /> <span style="color: Black">Contracted</span> <br /> <input id="otherCheckbox4" type="checkbox" value="Pending" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" /> <span style="color: Black">Pending</span><br /> <input id="otherCheckbox5" type="checkbox" value="Pre-Authorized" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" /> <span style="color: Black">Pre-Authorized</span> <br /> <input id="otherCheckbox6" type="checkbox" value="Show Deleted" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" /> <span style="color: Black">Show Deleted</span> <br /> <input id="otherCheckbox7" type="checkbox" value="Treated" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" />   <span style="color: Black">Treated</span> <br /> ``` MY javascript function with jquery but it does not work. called this function on a button click.Wen i click on button `alert("hi");` is fired but not `alert(index);` Also explain my main question and just me the way for this question ```js function ShowHideDxColumn() { alert("hi"); $(".ckhdisplay").each(function (index) { if ($(this).is(":checked")) { alert(index); } }); } ``` thank u
2013/06/24
['https://Stackoverflow.com/questions/17269744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2194674/']
You have a typo, `.ckhdisplay` should be `.chkdisplay`. Because of that, your `.each` call has no elements to iterate over because there are none with the given class. ``` function ShowHideDxColumn() { alert("hi"); $(".chkdisplay").each(function (index) { if ($(this).is(":checked")) { alert(index); } }); } ``` You actually don't really need the condiiton in the each, you can just select the checked checkboxes: ``` $(".chkdisplay:checked").each(function(index){ console.log(this); }); ```
Please try this: ``` $.each($(".chkdisplay"), function(index, element) { if ($(this).attr('checked')){ alert(index); } }); ```
37,694,419
I need to pass checkbox Boolean value(True or False) from below java method to java script function. Java Method:: ``` M1() { generatedXML.append("<div id=checkboxes> "); generatedXML.append("<input type=checkbox "); generatedXML.append(" onchange=\"setValue('"); generatedXML.append(obj); generatedXML.append("','"); generatedXML.append('this'); generatedXML.append("');\""); } ``` JavaScript function:: ``` function setValue(obj,refr) { alert(refr.checked); // i think it will alert true or false?? //Need Boolean value of checkbox } ```
2016/06/08
['https://Stackoverflow.com/questions/37694419', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4873517/']
You should add an id attribute to the checkbox and in the javascript access the checkbox itself by its own id. Something like ``` document.getElementById('checkIdHere'); ```
Assign your checkbox with an ID and in `onchange` function access checkbox with that id or you can pass the instance of checkbox to `onchange` function and directly access the value of checkbox. ``` var value = document.getElementById("chkTest").checked ``` And if you want to access value without `id` than pass `this` to `onchange` function from java like (syntax may not be correct please ignore as i don have editor for this) ``` generatedXML.append(" onchange=\"setValue('"); generatedXML.append(obj); generatedXML.append("','"); generatedXML.append(path); generatedXML.append("',this); generatedXML.append(");\""); ``` And in javascript do this ``` function setValue(obj,path,chkBox) { var value = chkBox.checked; } ```