qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
216,432
I have tried hard to look for a solution to my problems, but I can't manage to find it on this site or with Google. I have tried: `minipage`, `multicol`, `longtable`, `tabu`. I've read the documentation on `glossaries` and I can not make head or tails from it. I've got a glossary, with linguistic gloss abbreviations in it. I just need the gloss entry abbreviation and the description. No need for a third part. To save paper, I would like the glossary to be in two columns (abbrev. descr. abbrev. descr.) and I want it not to be on a seperate page. My MWE: ``` \documentclass[openright,12pt,dutch]{report} \usepackage{longtable} \usepackage[nomain,nonumberlist,nogroupskip,nostyles]{glossaries} % voor de lijst met glossen. \usepackage{glossary-super} \usepackage{leipzig} % voor glossen \makeglossaries \newglossarystyle{myglosses}{ \renewenvironment{theglossary}{ \longtable{r l} }{ \endlongtable } \renewcommand*{\glossaryheader}{} \renewcommand*{\glsgroupheading}[1]{} \renewcommand*{\glsgroupskip}{} \renewcommand*{\glsclearpage}{} % set how each entry should appear: \renewcommand*{\glossentry}[2]{ \glstarget{##1}{\textsc{\glossentryname{##1}}} & \glossentrydesc{##1} \\ } \renewcommand*{\subglossentry}[3]{% \glossentry{##2}{##3} } } \begin{document} What does \Pl{} mean? My (\Fsg{}.\Poss{}) houses (house-\Pl{}). \Agr, \Antip, \Ben, \Caus, \Compl, \Comp, \Third, \Dem, \Erg, \Fut, \F, \Loc, \Irr, \Impf, \Inf, \Ind, \Indf, \Ins, \Neg, \N, \M, \Nmlz, \Obj, \Obl, \Parg, \Prf, \Prs, \Prog. \printglossary[style=myglosses,type=\leipzigtype,title=]. \end{document} ``` Remember to run `makeglossaries`. I'd really appreciate your help with my thesis.
2014/12/10
[ "https://tex.stackexchange.com/questions/216432", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/10367/" ]
Here is a way of using `multicol` with `\parbox` commands to format the glossary. The `section=section` package option is used to prevent a page break before the glossary by altering the sectioning level from the default chapter to section (which doesn't start a new page). ``` \documentclass[openright,12pt,dutch]{report} \usepackage[nomain,nonumberlist,nogroupskip,nostyles,section=section]{glossaries} % voor de lijst met glossen. \usepackage{leipzig} % voor glossen \usepackage{multicol} \makeglossaries \newglossarystyle{myglosses}{% \renewenvironment{theglossary}{% \setlength{\parindent}{0pt}% \begin{multicols}{2}% }{% \end{multicols}% }% \renewcommand*{\glossaryheader}{}% \renewcommand*{\glsgroupheading}[1]{}% \renewcommand*{\glsclearpage}{\columnbreak}% % set how each entry should appear: \renewcommand*{\glossentry}[2]{% \parbox{.3\linewidth}{\hskip \fill\glstarget{##1}{\textsc{\glossentryname{##1}}}}% \hspace{.1\linewidth}% \parbox{.6\linewidth}{\glossentrydesc{##1}\hskip \fill}\par% }% \renewcommand*{\subglossentry}[3]{% \glossentry{##2}{##3}% }% } \begin{document} What does \Pl{} mean? My (\Fsg{}.\Poss{}) houses (house-\Pl{}). \Agr, \Antip, \Ben, \Caus, \Compl, \Comp, \Third, \Dem, \Erg, \Fut, \F, \Loc, \Irr, \Impf, \Inf, \Ind, \Indf, \Ins, \Neg, \N, \M, \Nmlz, \Obj, \Obl, \Parg, \Prf, \Prs, \Prog. \printglossary[style=myglosses,type=\leipzigtype,title=] \end{document} ``` ![two columns of glossary entries](https://i.stack.imgur.com/4G5W1.png)
I'll add an answer for leipzig 2.0 (which has just been added to CTAN, 2017-06-16). It's too late for your thesis, but might help someone else. I have included a pre-defined multicolumn glossary style in this version of leipzig. After a lot of experimentation, I ultimately decided that any style based on a tabular format was no good, because they often do not break across pages nicely, and lists of gloss abbreviations are often multiple pages long. Instead, the predefined block styles are built on the `alttree` and `mcolalttree` styles of the glossaries package. The easiest way to set the style for the glossary of abbreviations is to use the package option [mcolblock]. All unknown package options for leipzig are passed to glossaries. Therefore, like @cfr, I used the [section] option to print the glossary name in a section header instead of a chapter header. If you really want no title, you can uncomment one line to redefine the glossary section to do nothing. MWE: ``` \documentclass[openright,12pt,dutch]{report} % leipzig 2.0 has a simpler preamble declaration! \usepackage[% mcolblock,% multicolumn block glossary section,% glossary begins with a section header (not chapter header) ]{leipzig} % voor glossen \makeglossaries % Uncomment if you want no chapter/section heading at all: %\renewcommand*{\glossarysection}[2][]{} \begin{document} What does \Pl{} mean? My (\Fsg{}.\Poss{}) houses (house-\Pl{}). \Agr, \Antip, \Ben, \Caus, \Compl, \Comp, \Third, \Dem, \Erg, \Fut, \F, \Loc, \Irr, %\Impf, % changed to \Ipfv! \Ipfv, \Inf, \Ind, \Indf, \Ins, \Neg, \N, \M, \Nmlz, \Obj, \Obl, \Parg, \Prf, \Prs, \Prog. \printglosses \end{document} ``` Output: [![enter image description here](https://i.stack.imgur.com/YSKzv.jpg)](https://i.stack.imgur.com/YSKzv.jpg) You can also see that leipzig 2.0 fixes some errors! No more PL.pluralpl.
871,546
Instead of using the normal copy and paste function, is there a way to lookup data in an entire column (rather than an individual cell) in one spreadsheet and put it in another - minus the blank cells - so it's condensed?
2015/01/30
[ "https://superuser.com/questions/871546", "https://superuser.com", "https://superuser.com/users/413867/" ]
This is another way without macros or VBA: 1. Select the column 2. Go to Home -> Find & Select -> Go To Special 3. Choose Constants & OK 4. Now, only the cells with a value are selected. 5. Copy & Paste. It's done !!!!
This small macro will copy column **A** from *Sheet1* to column **A** of *Sheet2* omitting the blanks. Adjust the code for your own columns and sheet names: ``` Sub CopyNoBanks() Dim sh1 As Worksheet, s2 As Worksheet, i As Long Dim j As Long, N As Long, r1 As Range Set sh1 = Sheets("Sheet1") Set sh2 = Sheets("Sheet2") N = sh1.Cells(Rows.Count, "A").End(xlUp).Row j = 1 For i = 1 To N Set r1 = sh1.Cells(i, "A") If r1.Value <> "" Then r1.Copy sh2.Cells(j, "A") j = j + 1 End If Next i End Sub ``` Macros are very easy to install and use: 1. ALT-F11 brings up the VBE window 2. ALT-I ALT-M opens a fresh module 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx To remove the macro: 1. bring up the VBE window as above 2. clear the code out 3. close the VBE window To use the macro from Excel: 1. ALT-F8 2. Select the macro 3. Touch RUN To learn more about macros in general, see: <http://www.mvps.org/dmcritchie/excel/getstarted.htm> and <http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx> **Macros must be enabled for this to work!**
2,771,972
I've got a TextBox in which user can input a their desired username. Underneath I've got a checkbox that once clicked it copies the user's email adress into the textfield and then disable it to prevent further changes. This feature is implemented by using jQuery. The problem is that I've got a RequiredFieldValidator on that TextBox and it looks like it can't validate a disabled textfield, even if the value is set. How can I solve this?
2010/05/05
[ "https://Stackoverflow.com/questions/2771972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/333262/" ]
Just for future reference: I fixed this by setting the property "readonly" instead of "disabled".
You could use a custom validator control like in this sample: <http://asp.net-tutorials.com/validation/custom-validator/>
7,667,756
I am working on a client's site, and I'm writing an amortization schedule calculator in in ruby on rails. For longer loan term calculations, it doesn't seem to be breaking when the balance reaches 0 Here is my code: ``` def calculate_amortization_results p = params[:price].to_i i = params[:rate].to_d l = params[:term].to_i j = i/(12*100) n = l * 12 m = p * (j / (1 - (1 + j) ** (-1 * n))) @loanAmount = p @rateAmount = i @monthlyAmount = m @amort = [] @interestAmount = 0 while p > 0 line = Hash.new h = p*j c = m-h p = p-c line["interest"] = h line["principal"] = c if p <= 0 line["balance"] = 0 else line["balance"] = p end line["payment"] = h+c @amort.push(line) @interestAmount += h end end ``` And here is the view: ``` - @amort.each_with_index do |a, i| %li .m = i+1 .i = number_to_currency(a["interest"], :unit => "$") .p = number_to_currency(a["principal"], :unit => "$") .pp = number_to_currency(a["payment"], :unit => "$") .b = number_to_currency(a["balance"], :unit => "$") ``` What I am seeing is, in place of $0.00 in the final payment balance, it shows "-$-inf", iterates one more loop, then displays $0.00, but shows "-$-inf" for interest. It should loop until p gets to 0, then stop and set the balance as 0, but it isn't. Any idea what I've done wrong? The calculator is [here](http://www.mortgages.metatroid.com/calculator/amortization). It seems to work fine for shorter terms, like 5 years, but longer terms cause the above error. Edit: Changing the while loop to `n.times do` and then changing the balance view to ``` = number_to_currency(a["balance"], :unit => "$", :negative_format => "$0.00") ``` Is a workaround, but i'd like to know why the while loop wouldn't work correctly
2011/10/05
[ "https://Stackoverflow.com/questions/7667756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/434598/" ]
in Ruby the default for numerical values is Fixnum ... e.g.: ``` > 15 / 4 => 3 ``` You will see weird rounding errors if you try to use Fixnum values and divide them. To make sure that you use Floats, at least one of the numbers in the calculation needs to be a Float ``` > 15.0 / 4 => 3.75 > 15 / 4.0 => 3.75 ``` You do two comparisons against 0 , which should be OK if you make sure that p is a Float. As the other answer suggests, you should use "decimal" type in your database to represent currency. Please try if this will work: ``` def calculate_amortization_results p = params[:price].to_f # instead of to_i i = params[:rate].to_f # <-- what is to_d ? use to_f l = params[:term].to_i j = i/(12*100.0) # instead of 100 n = l * 12 m = p * (j / (1 - (1 + j) ** (-1 * n))) # division by zero if i==0 ==> j==0 @loanAmount = p @rateAmount = i @monthlyAmount = m @amort = [] @interestAmount = 0.0 # instead of 0 while p > 0 line = Hash.new h = p*j c = m-h p = p-c line["interest"] = h line["principal"] = c if p <= 0 line["balance"] = 0 else line["balance"] = p end line["payment"] = h+c @amort.push(line) @interestAmount += h end end ``` If you see "inf" in your output, you are doing a division by zero somewhere.. better check the logic of your calculation, and guard against division by zero. --- according to Wikipedia the formula is: <http://en.wikipedia.org/wiki/Amortization_calculator> to improve rounding errors, it's probably better to re-structure the formula like this: ``` m = (p * j) / (1 - (1 + j) ** (-1 * n) # these are two divisions! x**-1 == 1/x ``` which is equal to: ``` m = (p * j) + (p * j) / ((1 + j) ** n) - 1.0) ``` which is equal to: (use this one) ``` q = p * j # this is much larger than 1 , so fewer rounding errors when dividing it by something m = q + q / ((1 + j) ** n) - 1.0) # only one division ```
I think it has something to do with the floating point operations precision. It has already been discussed here: [Ruby number precision with simple arithmetic](https://stackoverflow.com/questions/5419839/ruby-number-precision-with-simple-arithmetic) and it would be better to use decimal format for financial purposes. The answer could be computing the numbers in the loop, but with precomputed number of iterations and from the scratch.
33,040,426
I will give You two slices of code from the SQL script I'm currently working with, but they will suffice. Firstly, I am declaring a variable: ``` FUNCTION Run ( i_PlafId IN INTEGER ) RETURN INTEGER IS l_tables_excl VARCHAR2(256) := 'TABLE_1,TABLE_2'; ``` Later I would like to use it in some place, like this: ``` AND cos.table_name NOT IN l_tables_excl ``` Which would be the exact representation of: ``` AND cos.table_name NOT IN ('TABLE_1', 'TABLE_2') ``` There is no way of experimenting, cause a run of this Oracle package takes about 2 days... Thanks in advance!
2015/10/09
[ "https://Stackoverflow.com/questions/33040426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4012392/" ]
The best way to deal with a list of values like this is to use an array: ``` create or replace type t_table_list as table of varchar2(50); FUNCTION Run ( i_PlafId IN INTEGER ) RETURN INTEGER IS l_tables_excl t_table_list := t_table_list('TABLE_1','TABLE_2'); ... AND cos.table_name NOT IN (select * from table(l_tables_excl)) ``` You should note that the type must be created as a database object, not declared within a package.
**Option A - Use LIKE** You can do a `LIKE` to see if the table name is in the string. Whether or not this works will depend on how similar your table names are. ``` /* Returns true if table name isn't a substring of l_tables.excl */ AND l_tables_excl NOT LIKE '%' || cos.table_name || '%' ``` **Option B - Split string into table** Or you can split the string into a table and you'll be able to use `NOT IN`. It's a bit more difficult so I'll just give you references: * [How to split comma separated string and pass to in clause](https://blogs.oracle.com/aramamoo/entry/how_to_split_comma_separated_string_and_pass_to_in_clause_of_select_statement) * [Splitting string into multiple rows in Oracle (SO answer)](https://stackoverflow.com/questions/14328621/splitting-string-into-multiple-rows-in-oracle) **Testing note**: If running your package takes two days, you might want to find a way of only doing a part of the work. Like if it processes a 1000 rows, add a variable to tell it to only do 100 rows just so it will finish. You really need to be able to test and two days is just too long.
33,040,426
I will give You two slices of code from the SQL script I'm currently working with, but they will suffice. Firstly, I am declaring a variable: ``` FUNCTION Run ( i_PlafId IN INTEGER ) RETURN INTEGER IS l_tables_excl VARCHAR2(256) := 'TABLE_1,TABLE_2'; ``` Later I would like to use it in some place, like this: ``` AND cos.table_name NOT IN l_tables_excl ``` Which would be the exact representation of: ``` AND cos.table_name NOT IN ('TABLE_1', 'TABLE_2') ``` There is no way of experimenting, cause a run of this Oracle package takes about 2 days... Thanks in advance!
2015/10/09
[ "https://Stackoverflow.com/questions/33040426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4012392/" ]
The best way to deal with a list of values like this is to use an array: ``` create or replace type t_table_list as table of varchar2(50); FUNCTION Run ( i_PlafId IN INTEGER ) RETURN INTEGER IS l_tables_excl t_table_list := t_table_list('TABLE_1','TABLE_2'); ... AND cos.table_name NOT IN (select * from table(l_tables_excl)) ``` You should note that the type must be created as a database object, not declared within a package.
You can use the REGEXP\_LIKE function to simulate the in clause: ``` WHERE NOT REGEXP_LIKE(l_tables_excl, '(^|,)'||cos.table_name||'(,|$)') ```
111,818
I have a Thinkpad T61p with Quadro FX570M. I just installed the Ubuntu 11.10. I have tried to download the driver LINUX DISPLAY DRIVER - X86 version 295.20 from NVIDIA, but I do not manage to install it. If I open System > Screens, there is an unknovn screen driver. My installation works fine except, fails on resume with a black and white pattern all over the screen and I have difficulties detecting an external monitor. Please, if you have any clue - help me out.
2012/03/10
[ "https://askubuntu.com/questions/111818", "https://askubuntu.com", "https://askubuntu.com/users/50001/" ]
You can install the latest drivers for NVidia doing this: ``` sudo add-apt-repository ppa:ubuntu-x-swat/x-updates sudo apt-get update sudo apt-get upgrade sudo apt-get install nvidia-current nvidia-settings ``` if anything goes wrong, simply purge the ppa: ``` sudo apt-get install ppa-purge sudo ppa-purge ppa:ubuntu-x-swat/x-updates ```
launch jockey-gtk by pressing `alt`+`f2` and then typing in `jockey-gtk`. It will list the drivers that apply for your hardware. Activate the Nvidia ones. Otherwise, to install it from the Nvidia download, you would need to exit X-Server and run it there, which is more complicated and shouldn't be necessary. If you install it from jockey it will also be easier to keep the drivers up to date.
111,818
I have a Thinkpad T61p with Quadro FX570M. I just installed the Ubuntu 11.10. I have tried to download the driver LINUX DISPLAY DRIVER - X86 version 295.20 from NVIDIA, but I do not manage to install it. If I open System > Screens, there is an unknovn screen driver. My installation works fine except, fails on resume with a black and white pattern all over the screen and I have difficulties detecting an external monitor. Please, if you have any clue - help me out.
2012/03/10
[ "https://askubuntu.com/questions/111818", "https://askubuntu.com", "https://askubuntu.com/users/50001/" ]
You can install the latest drivers for NVidia doing this: ``` sudo add-apt-repository ppa:ubuntu-x-swat/x-updates sudo apt-get update sudo apt-get upgrade sudo apt-get install nvidia-current nvidia-settings ``` if anything goes wrong, simply purge the ppa: ``` sudo apt-get install ppa-purge sudo ppa-purge ppa:ubuntu-x-swat/x-updates ```
I had similar issue with my ThinkPad t510 that had Intel display driver and Nvidia GT218 [NVS 3100M} driver. This is how I was able to switch default display driver to NVIDIA. First clean-up any third-party NVIDIA drivers (in case you have them) ``` sudo apt-get purge xserver-xorg-video-nouveau ``` Then perform the following steps (as listed above by Messie, except the last line which includes --reinstall to cleanup the existing installation) ``` sudo add-apt-repository ppa:ubuntu-x-swat/x-updates sudo apt-get update sudo apt-get upgrade sudo apt-get --reinstall install nvidia-current nvidia-settings ``` Reboot laptop and hold F-1 to get to the BIOS setup ([thinkpad BIOS Setup](http://support.lenovo.com/en_US/detail.page?LegacyDocID=MIGR-76476)). ``` go to Display switch "Graphics Device" from "NVIDIA Optimus" to "Discrete Graphics" change "OS Detection for NVIDIA Optimus" to "Disabled" Save using F10 and let the boot continue ``` Now your laptop should be using NVIDIA as you can confirm by ``` nvidia-settings ``` To revert just reverse the listed steps.
10,593,132
iv created a program which works really well with MySQL. However, when I convert it to SQLlite, everything works such as Creating tables, getConnection() to the database and such EXCEPT inserting values to the table?? I am unable to insert value to the table using Java (Netbeans) to SQLite database. I can only insert ONE row but not multiple rows? In MySQL, i could insert multiple rows at once, however, I cant in SQLite? The code is (This works for only ONE row): ``` Connection con; Statement s= con.CreateStatement(); String st = "Insert into table1 (10,'abc')"; s.executeUpdate(st); s.close(); ``` If I do something like this (DOES NOT work for more than one row - have no idea why- SQLite): ``` Connection con; Statement s= con.CreateStatement(); String st = "Insert into table1 (10,'abc'), (5,'vfvdv')"; //now it doesnt work since Im inserting more than one row. I can't figure out what Im doing wrong - //Iv also tried Insert into table1(ID, Name) values (10,'abc'), (5,'afb'); but it dont work. s.executeUpdate(st); s.close(); ``` Could any java expert or anyone help me on this. I cant figure out what Im doing wrong or anything because when I type my commands in the 'SQLite' command line it works fine for ALL. But, In JAVA with SQLite, I can only update one row for some reason? However, Java with MySQL works fine but not SQLlite. Anyone could clarify what Im doing wrong would be brillant. Thanks alot for reading this and your time.
2012/05/15
[ "https://Stackoverflow.com/questions/10593132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1394982/" ]
It's possible that the SQLite JDBC driver doesn't support the multi-insert syntax. This syntax is also not standard, though many databases do support it. Another option for doing multiple inserts like this is to use the batching mechanism of PreparedStatement. ``` Connection conn = ....; PreparedStatement stmt = conn.prepareStatement("INSERT INTO table1(id, name) VALUES (?, ?)"); stmt.setInt(1, 10); stmt.setString(2, "abc"); stmt.addBatch(); stmt.setInt(1, 5); stmt.setString(2, "vfvdv"); stmt.addBatch(); stmt.executeBatch(); ``` Typically, you'd use the setInt, setString, addBatch sequence in a loop, instead of unrolled as I've shown here, and call executeBatch after the loop. This will work with all JDBC compliant databases.
Multi row insert is not standard according to the SQL92 standard. SQLite suports it since version 3.7.11. If you have a version under this one, you need to make one insert for each row...
50,464,483
Expected: find the number files in the folder, and collect the absolute path for each file in the directory. ``` File certificatePath = new File("resources/NPL"); String absolutePath = certificatePath.getAbsolutePath(); File directory = new File(absolutePath); int fileCount=directory.list().length; ``` From the above code getting the no of files in folder (resources/NPL), now i'm struggle to get the absolute path for the files.
2018/05/22
[ "https://Stackoverflow.com/questions/50464483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2257288/" ]
In HTML neither `CR`, `LF` nor `CRLF` matters really. That's why `<br />` tag exists and you need to use it instead or display your content in `<pre>` block or similar which is one of a few exceptions when `CR`/`LF` thing actually works as elsewhere.
file\_put\_contents($file, $someData . PUT THE BREAK HERE IN INVERTED COMMAS . PHP\_EOL, FILE\_APPEND); It was as simple as that on Chrome. I think I might have (gulp) forgotten to upload a file when i was trying this earlier.
13,885,783
I couldn't find or come up with a generic and elegant algorithm that would let me populate the tree-like structure. The simplest example is a blog archive: I have a bunch of records which can be selected and sorted by date. I want to have a tree where years may be top level, months are next level and actual post titles are next again. So far I've came up with a naive straight forward implementation that works, but I'm sure that could be improved using LINQ, etc. Here I just sort records by date and iterate checking if the year or month has changed, and add tree nodes accordingly. "BlogEntry" is a class that has a reference to both a parent and children and is later used to generate HTML. I welcome suggestions on improving the algorithm! ``` IEnumerable<Post> posts = db.Posts.OrderBy(p => p.DateCreated); var topPost = posts.First(); int curYear = topPost.DateCreated.Year; int curMonth = topPost.DateCreated.Month; //create first "year-level" item var topYear = new BlogEntry { Name = topPost.DateCreated.Year.ToString().ToLink(string.Empty) }; entries.Add(topYear); var currentYear = topYear; var topMonth = new BlogEntry { Name = topPost.DateCreated.ToString("MMMM").ToLink(string.Empty), Parent = currentYear }; currentYear.Children.Add(topMonth); var currentMonth = topMonth; foreach (var post in posts) { if(post.DateCreated.Year == curYear) { if (post.DateCreated.Month != curMonth) { //create "month-level" item var month = new BlogEntry { Name = post.DateCreated.ToString("MMMM").ToLink(string.Empty), Parent = currentYear }; currentYear.Children.Add(month); currentMonth = month; curMonth = post.DateCreated.Month; } //create "blog entry level" item var blogEntry = new BlogEntry { Name = post.Title.ToLink("/Post/" + post.PostID + "/" + post.Title.ToSeoUrl() ), Parent = currentMonth }; currentMonth.Children.Add(blogEntry); } else { //create "year-level" item var year = new BlogEntry { Name = post.DateCreated.Year.ToString().ToLink(string.Empty) }; entries.Add(year); currentYear = year; curMonth = post.DateCreated.Month; curYear = post.DateCreated.Year; } } ```
2012/12/14
[ "https://Stackoverflow.com/questions/13885783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26447/" ]
I've created a test example, to check the correctness of the logic. I think this is what you need. ``` public class BlogEntyTreeItem { public string Text { set; get; } public string URL { set; get; } public List<BlogEntyTreeItem> Children { set; get; } public List<BlogEntyTreeItem> GetTree() { NWDataContext db = new NWDataContext(); var p = db.Posts.ToList(); var list = p.GroupBy(g => g.DateCreated.Year).Select(g => new BlogEntyTreeItem { Text = g.Key.ToString(), Children = g.GroupBy(g1 => g1.DateCreated.ToString("MMMM")).Select(g1 => new BlogEntyTreeItem { Text = g1.Key, Children = g1.Select(i => new BlogEntyTreeItem { Text = i.Name }).ToList() }).ToList() }).ToList(); return list; } } ```
using the link [Playing with Linq grouping: GroupByMany ?](http://blogs.msdn.com/b/mitsu/archive/2007/12/22/playing-with-linq-grouping-groupbymany.aspx) suggested in [How can I hierarchically group data using LINQ?](https://stackoverflow.com/questions/2230202/how-can-i-hierarchically-group-data-using-linq) I first refactored my code into **Solution 1** ``` var results = from allPosts in db.Posts.OrderBy(p => p.DateCreated) group allPosts by allPosts.DateCreated.Year into postsByYear select new { postsByYear.Key, SubGroups = from yearLevelPosts in postsByYear group yearLevelPosts by yearLevelPosts.DateCreated.Month into postsByMonth select new { postsByMonth.Key, SubGroups = from monthLevelPosts in postsByMonth group monthLevelPosts by monthLevelPosts.Title into post select post } }; foreach (var yearPosts in results) { //create "year-level" item var year = new BlogEntry { Name = yearPosts.Key.ToString().ToLink(string.Empty) }; entries.Add(year); foreach (var monthPosts in yearPosts.SubGroups) { //create "month-level" item var month = new BlogEntry { Name = new DateTime(2000, (int)monthPosts.Key, 1).ToString("MMMM").ToLink(string.Empty), Parent = year }; year.Children.Add(month); foreach (var postEntry in monthPosts.SubGroups) { //create "blog entry level" item var post = postEntry.First() as Post; var blogEntry = new BlogEntry { Name = post.Title.ToLink("/Post/" + post.PostID + "/" + post.Title.ToSeoUrl()), Parent = month }; month.Children.Add(blogEntry); } } } ``` And then into a more generic **Solution 2** ``` var results = db.Posts.OrderBy(p => p.DateCreated).GroupByMany(p => p.DateCreated.Year, p => p.DateCreated.Month); foreach (var yearPosts in results) { //create "year-level" item var year = new BlogEntry { Name = yearPosts.Key.ToString().ToLink(string.Empty) }; entries.Add(year); foreach (var monthPosts in yearPosts.SubGroups) { //create "month-level" item var month = new BlogEntry { Name = new DateTime(2000, (int)monthPosts.Key, 1).ToString("MMMM").ToLink(string.Empty), Parent = year }; year.Children.Add(month); foreach (var postEntry in monthPosts.Items) { //create "blog entry level" item var post = postEntry as Post; var blogEntry = new BlogEntry { Name = post.Title.ToLink("/Post/" + post.PostID + "/" + post.Title.ToSeoUrl()), Parent = month }; month.Children.Add(blogEntry); } } } ................................................ public static class MyEnumerableExtensions { public static IEnumerable<GroupResult> GroupByMany<TElement>( this IEnumerable<TElement> elements, params Func<TElement, object>[] groupSelectors) { if (groupSelectors.Length > 0) { var selector = groupSelectors.First(); //reduce the list recursively until zero var nextSelectors = groupSelectors.Skip(1).ToArray(); return elements.GroupBy(selector).Select( g => new GroupResult { Key = g.Key, Items = g, SubGroups = g.GroupByMany(nextSelectors) }); } else return null; } } public class GroupResult { public object Key { get; set; } public IEnumerable Items { get; set; } public IEnumerable<GroupResult> SubGroups { get; set; } } ```
26,320,321
``` $ip = $_SERVER['REMOTE_ADDR']; //get IP $referer = $_SERVER['HTTP_REFERER']; //get referer $time = time(); //extracting timestamp $date = date('d-m-y H:i:s',$time); //generating date $f = fopen("log.php", "a"); //opening files $counter = fgetc("hitleap.txt"); $f2 = fopen("hitleap.txt", "w+"); if($referer == "http://hitleap.com/traffic-exchange"){ fwrite($f2, $counter++); fclose($f2); } else { fwrite ($f, '<div class="spoiler"><input type="button" onclick="showSpoiler(this)" value="Show/Hide" /> Data/Ora: <b>['.$date.']</b><br> <div class="inner" style="display:none"> IP: <b>['.$ip.']</b> <br> Provenienza: <b>['.$referer.']</b> </div></div><br> '); fclose($f); } ``` Basically if the site visitor is coming from hitleap site, I want to increment a number inside a txt file by 1. If not, add into another log file his IP and referer inside a spoiler. The second part works pretty well but I can't still get the first part to work Also the hitleap.txt somehow gets flushed everytime the "else" applies. **EDIT** Solved like this: ``` $ip = $_SERVER['REMOTE_ADDR']; $referer = $_SERVER['HTTP_REFERER']; $time = time(); $date = date('d-m-y H:i:s',$time); $hits = file_get_contents("hitleap.txt"); $nhits = $hits+1; if($referer == "http://XXX"){ $f2 = fopen("hitleap.txt", "w+"); fwrite($f2, $nhits); fclose($f2); } else { $f = fopen("log.php", "a"); fwrite ($f, 'wh@tever u want here'); fclose($f); } ``` seems to work fine for me
2014/10/11
[ "https://Stackoverflow.com/questions/26320321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4133417/" ]
You'll wanna use ``` fwrite($f2, ++$counter); ``` instead of ``` fwrite($f2, $counter++); ``` What's happening is that your incrementing the variable after it's been written to file and not before. The solution will increment the variable before writing it.
Your final code would be: ``` $ip = $_SERVER['REMOTE_ADDR']; //get IP $referer = $_SERVER['HTTP_REFERER']; //get referer $time = time(); //extracting timestamp $date = date('d-m-y H:i:s',$time); //generating date $f = fopen("log.php", "a"); //opening files $counter = fgetc("hitleap.txt"); // this line has been moved into the if block if($referer == "http://hitleap.com/traffic-exchange"){ $f2 = fopen("hitleap.txt", "w+"); // here it is fwrite($f2, ++$counter); // using ++$counter fclose($f2); } else { fwrite ($f, '<div class="spoiler"><input type="button" onclick="showSpoiler(this)" value="Show/Hide" /> Data/Ora: <b>['.$date.']</b><br> <div class="inner" style="display:none"> IP: <b>['.$ip.']</b> <br> Provenienza: <b>['.$referer.']</b> </div></div><br> '); fclose($f); } ```
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
Well, I was thinking, maybe it was Cole himself. Come of think of it, Cole removed his teeth too, right? And the old man had his teeth removed too. He always knew what Cole was thinking, because he probably had been through it. He thought the same things because he is Cole himself, now an old man and he knows what the young Cole is gonna think about. Cole says something about 'dimensions' while he was being interrogated ny scientists in the future. Maybe the old man Cole came from a parallel dimension where he and Railly actually went to the Keys and lived their life. Or whatever, just ultimately, he survived, grew old and went crazy all the time, probably because he couldn't get the images of adult Cole trying to gather information or young Cole witnessing the airport scene. Though I can't understand...why Bob?
I thought that the man in the mental hospital wearing the suit and the bunny slippers was the voice that called Cole bob. But I can only base that on the tapping of his foot. In the scene where we see the man in the suit in the mental hospital he explains that he is not from outer space etc. After he is finished telling his story there is a close up of his foot tapping. At the end of the film when Cole is hearing the voice again in the bathroom you see a man in de toillet tapping his foot as well. I know this is pretty far fetched but it also really stood out.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
In short, there's no definitive answer to this question. The film's themes of psychology and chaotic treatment of time travel make it difficult to pin down a solid answer. Still... The voice Cole hears calling him Bob is mostly unexplained, but the homeless man he and Kathyrn run into multiple times shares the voice. While it is unlikely that this man is the sole source of the voice (as Cole hears it several times before when escaping the mental hospital, and at other points where it is incredibly unlikely the homeless man is around), the confusion and mental degradation caused by repeated time travel (or the medication in the mental hospital) throughout the film is hinted at as the source of the voice. Keep in mind that the first place Cole hears it is while strapped down after his first return to the future. Cole may simply be imagining it because he has started to go insane, an interesting contrast to the dramatic irony produced in the audience, who know that Cole is sane about being from the future. Nonetheless, the voice does seem to perform a Donnie Darko-like role in driving Cole's actions as another personality only he can hear. As Cole can be thought of as the "monkey" (in reference to the monkey sent into the well to retrieve the kid, but instead taking the sandwich, much like Cole is only back in time to find a sample of the virus, not stop it from spreading), there's a possibility he is being used as a test animal by the scientists. To support this piece of speculation, note that the virus first breaks out in the airport where young Cole is. Odds are, if he weren't immune, he would have died, but even if he weren't (and built up an immunity after being exposed to the virus), he would have lived through the virus outbreak, and probably had it at one point. Unless the scientists had a way to rid a person of the virus (which would negate the need to send somebody back to begin with to get a sample), the sanitation procedures the scientists are putting on are all a show, and everyone still alive is infected, with an immune response keeping them unharmed. If Cole is a test animal, it is likely that it is for time travel itself, as the procedure seems unrefined (they send him to the wrong time frequently). Thus, he may very well be receiving brain damage from time travel (if not already from the stress of the events), and the voice may be a product of that fact. One other explanation is that somebody from the future is somehow observing and speaking to Cole during his ordeal, which isn't out of the question either. Otherwise, it has a supernatural explanation.
I thought that the man in the mental hospital wearing the suit and the bunny slippers was the voice that called Cole bob. But I can only base that on the tapping of his foot. In the scene where we see the man in the suit in the mental hospital he explains that he is not from outer space etc. After he is finished telling his story there is a close up of his foot tapping. At the end of the film when Cole is hearing the voice again in the bathroom you see a man in de toillet tapping his foot as well. I know this is pretty far fetched but it also really stood out.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
In short, there's no definitive answer to this question. The film's themes of psychology and chaotic treatment of time travel make it difficult to pin down a solid answer. Still... The voice Cole hears calling him Bob is mostly unexplained, but the homeless man he and Kathyrn run into multiple times shares the voice. While it is unlikely that this man is the sole source of the voice (as Cole hears it several times before when escaping the mental hospital, and at other points where it is incredibly unlikely the homeless man is around), the confusion and mental degradation caused by repeated time travel (or the medication in the mental hospital) throughout the film is hinted at as the source of the voice. Keep in mind that the first place Cole hears it is while strapped down after his first return to the future. Cole may simply be imagining it because he has started to go insane, an interesting contrast to the dramatic irony produced in the audience, who know that Cole is sane about being from the future. Nonetheless, the voice does seem to perform a Donnie Darko-like role in driving Cole's actions as another personality only he can hear. As Cole can be thought of as the "monkey" (in reference to the monkey sent into the well to retrieve the kid, but instead taking the sandwich, much like Cole is only back in time to find a sample of the virus, not stop it from spreading), there's a possibility he is being used as a test animal by the scientists. To support this piece of speculation, note that the virus first breaks out in the airport where young Cole is. Odds are, if he weren't immune, he would have died, but even if he weren't (and built up an immunity after being exposed to the virus), he would have lived through the virus outbreak, and probably had it at one point. Unless the scientists had a way to rid a person of the virus (which would negate the need to send somebody back to begin with to get a sample), the sanitation procedures the scientists are putting on are all a show, and everyone still alive is infected, with an immune response keeping them unharmed. If Cole is a test animal, it is likely that it is for time travel itself, as the procedure seems unrefined (they send him to the wrong time frequently). Thus, he may very well be receiving brain damage from time travel (if not already from the stress of the events), and the voice may be a product of that fact. One other explanation is that somebody from the future is somehow observing and speaking to Cole during his ordeal, which isn't out of the question either. Otherwise, it has a supernatural explanation.
*12 Monkeys* follows the structure of a Greek tragedy, with the idea of *hamartia* - a sort of mixture of fate and human fallibility - literally 'however much you try to escape, you are always there'. In traditional tragedy, there is always a chorus who reminds both audience and protagonist of this at key intervals, known as episodes or interludes, as well as commenting on the action and how it is affecting the protagonist and moving things towards their inevitable conclusion. 'Bob' is the chorus.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
The voice that calls Cole "Bob" **seems to be a communication from the authorities in the future. First the voice interrogates, then it manipulates, and finally it is hostile:** -In its first scene, the voice interrogates Cole, asking him what happened during his time travel. *"Hey, Bob, you do the job? Did you find out the big info?...Army of the Twelve Monkeys...where the virus was prior to mutation?"* -In its second scene, the voice seems to suggest to Cole that he wants to return to the future, and stay there. *"To see the sky -- and the ocean -- to be topside -- breathe the air -- to be with her. ... Isn't that right? Isn't that what you want?"* -In its final scene, the voice ominously reminds Cole -- just before he is killed -- that he is not allowed to stay in the pre-virus world. *"Point of fact -- you don't belong here. It's not permitted to let you stay."*
*12 Monkeys* follows the structure of a Greek tragedy, with the idea of *hamartia* - a sort of mixture of fate and human fallibility - literally 'however much you try to escape, you are always there'. In traditional tragedy, there is always a chorus who reminds both audience and protagonist of this at key intervals, known as episodes or interludes, as well as commenting on the action and how it is affecting the protagonist and moving things towards their inevitable conclusion. 'Bob' is the chorus.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
After seeing Gilliam's new film, Zero Theorem- I believe the mysterious voice in 12 Monkeys to be 'Bob' from Zero Theorom. He is introduced as Bob and that he calls everyone else Bob because it's quicker and uses less memory. He is also the son of 'Management' and seems to know an awful lot about what's going on...all of the time....
Bob is ambiguous and up to the viewer, I like to think of Bob as fate personafied and it has capacity to be anywhere and anytime. Also a tinge of karma for the human race, it has a mission to rebalance human Vs earth war and nothing will change it. Essentially Bob is the Cassandra virus with a voice, capacity and tenacity to make sure it's plan to reduce 80% of the human race succeeds.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
Well, I was thinking, maybe it was Cole himself. Come of think of it, Cole removed his teeth too, right? And the old man had his teeth removed too. He always knew what Cole was thinking, because he probably had been through it. He thought the same things because he is Cole himself, now an old man and he knows what the young Cole is gonna think about. Cole says something about 'dimensions' while he was being interrogated ny scientists in the future. Maybe the old man Cole came from a parallel dimension where he and Railly actually went to the Keys and lived their life. Or whatever, just ultimately, he survived, grew old and went crazy all the time, probably because he couldn't get the images of adult Cole trying to gather information or young Cole witnessing the airport scene. Though I can't understand...why Bob?
Bob is ambiguous and up to the viewer, I like to think of Bob as fate personafied and it has capacity to be anywhere and anytime. Also a tinge of karma for the human race, it has a mission to rebalance human Vs earth war and nothing will change it. Essentially Bob is the Cassandra virus with a voice, capacity and tenacity to make sure it's plan to reduce 80% of the human race succeeds.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
I think the overall theme of this movie is that fate exists and any attempt to subvert it will only backfire. I think the Bob voice is a symptom of his insanity and his repressed guilt as, on some level, he feels responsible for the end of the world. I think it ultimately serves to preserve ambiguity concerning his insanity, probably for entertainment. That aspect of the movie and in prison Jose's lines about the volunteers "You don't know that. Nobody knows that. That's just a rumour, I don't believe that." I think play in a role into a greater theme I haven't been able to dissect. If there is another theme to the movie it is that we are all insane.
I thought that the man in the mental hospital wearing the suit and the bunny slippers was the voice that called Cole bob. But I can only base that on the tapping of his foot. In the scene where we see the man in the suit in the mental hospital he explains that he is not from outer space etc. After he is finished telling his story there is a close up of his foot tapping. At the end of the film when Cole is hearing the voice again in the bathroom you see a man in de toillet tapping his foot as well. I know this is pretty far fetched but it also really stood out.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
*12 Monkeys* follows the structure of a Greek tragedy, with the idea of *hamartia* - a sort of mixture of fate and human fallibility - literally 'however much you try to escape, you are always there'. In traditional tragedy, there is always a chorus who reminds both audience and protagonist of this at key intervals, known as episodes or interludes, as well as commenting on the action and how it is affecting the protagonist and moving things towards their inevitable conclusion. 'Bob' is the chorus.
I thought that the man in the mental hospital wearing the suit and the bunny slippers was the voice that called Cole bob. But I can only base that on the tapping of his foot. In the scene where we see the man in the suit in the mental hospital he explains that he is not from outer space etc. After he is finished telling his story there is a close up of his foot tapping. At the end of the film when Cole is hearing the voice again in the bathroom you see a man in de toillet tapping his foot as well. I know this is pretty far fetched but it also really stood out.
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
In short, there's no definitive answer to this question. The film's themes of psychology and chaotic treatment of time travel make it difficult to pin down a solid answer. Still... The voice Cole hears calling him Bob is mostly unexplained, but the homeless man he and Kathyrn run into multiple times shares the voice. While it is unlikely that this man is the sole source of the voice (as Cole hears it several times before when escaping the mental hospital, and at other points where it is incredibly unlikely the homeless man is around), the confusion and mental degradation caused by repeated time travel (or the medication in the mental hospital) throughout the film is hinted at as the source of the voice. Keep in mind that the first place Cole hears it is while strapped down after his first return to the future. Cole may simply be imagining it because he has started to go insane, an interesting contrast to the dramatic irony produced in the audience, who know that Cole is sane about being from the future. Nonetheless, the voice does seem to perform a Donnie Darko-like role in driving Cole's actions as another personality only he can hear. As Cole can be thought of as the "monkey" (in reference to the monkey sent into the well to retrieve the kid, but instead taking the sandwich, much like Cole is only back in time to find a sample of the virus, not stop it from spreading), there's a possibility he is being used as a test animal by the scientists. To support this piece of speculation, note that the virus first breaks out in the airport where young Cole is. Odds are, if he weren't immune, he would have died, but even if he weren't (and built up an immunity after being exposed to the virus), he would have lived through the virus outbreak, and probably had it at one point. Unless the scientists had a way to rid a person of the virus (which would negate the need to send somebody back to begin with to get a sample), the sanitation procedures the scientists are putting on are all a show, and everyone still alive is infected, with an immune response keeping them unharmed. If Cole is a test animal, it is likely that it is for time travel itself, as the procedure seems unrefined (they send him to the wrong time frequently). Thus, he may very well be receiving brain damage from time travel (if not already from the stress of the events), and the voice may be a product of that fact. One other explanation is that somebody from the future is somehow observing and speaking to Cole during his ordeal, which isn't out of the question either. Otherwise, it has a supernatural explanation.
Well, I was thinking, maybe it was Cole himself. Come of think of it, Cole removed his teeth too, right? And the old man had his teeth removed too. He always knew what Cole was thinking, because he probably had been through it. He thought the same things because he is Cole himself, now an old man and he knows what the young Cole is gonna think about. Cole says something about 'dimensions' while he was being interrogated ny scientists in the future. Maybe the old man Cole came from a parallel dimension where he and Railly actually went to the Keys and lived their life. Or whatever, just ultimately, he survived, grew old and went crazy all the time, probably because he couldn't get the images of adult Cole trying to gather information or young Cole witnessing the airport scene. Though I can't understand...why Bob?
27,768
In Twelve Monkeys, Cole hears someone who calls him as "Bob"... He hears him in the past and also in the future... Who or what is he?
2012/12/07
[ "https://scifi.stackexchange.com/questions/27768", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/4742/" ]
The voice that calls Cole "Bob" **seems to be a communication from the authorities in the future. First the voice interrogates, then it manipulates, and finally it is hostile:** -In its first scene, the voice interrogates Cole, asking him what happened during his time travel. *"Hey, Bob, you do the job? Did you find out the big info?...Army of the Twelve Monkeys...where the virus was prior to mutation?"* -In its second scene, the voice seems to suggest to Cole that he wants to return to the future, and stay there. *"To see the sky -- and the ocean -- to be topside -- breathe the air -- to be with her. ... Isn't that right? Isn't that what you want?"* -In its final scene, the voice ominously reminds Cole -- just before he is killed -- that he is not allowed to stay in the pre-virus world. *"Point of fact -- you don't belong here. It's not permitted to let you stay."*
After seeing Gilliam's new film, Zero Theorem- I believe the mysterious voice in 12 Monkeys to be 'Bob' from Zero Theorom. He is introduced as Bob and that he calls everyone else Bob because it's quicker and uses less memory. He is also the son of 'Management' and seems to know an awful lot about what's going on...all of the time....
199,736
I know that the tax rate varies based on how happy the Sims are. Let's say my Sims are 99% happy. The tax rate is 20%. But 20% of what? City hall says I get a tax rate of 20%, which equals §12075 every 24 hours. If the tax rate were based on population, my population is 104184, so times 20% = §20837. That can't be it, so it must be something else.
2015/01/06
[ "https://gaming.stackexchange.com/questions/199736", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/29603/" ]
Here is what I received from EA: > > Please note - the figure of 20% tax is calculated from levels and ratios for happiness and population, it's not as simple as happiness multiplied by population! A 20% tax rate is not simply 20% of your total population number in Simoleon form. If it were this simple an equation, early level Mayors would receive barely anything and find it a real struggle to make money for a long time, whereas higher level Mayors could buy everything in sight and would dominate the Markets. We didn't think this was very fair, particularly for a free-to-play game, and the balance of the game would have suffered too much. > > >
One thing which is quite obvious is that the tax is good at lower levels but exponentially decreases with every population. I was able to raise the tax to 10k when I had 100k population, but now I am at 150k population and the tax is only 12k. (Both at 99% happiness) This seems to be a well designed trick by EA. People who are deeply engaged in the game and rising in population are more susceptible to spending money.
199,736
I know that the tax rate varies based on how happy the Sims are. Let's say my Sims are 99% happy. The tax rate is 20%. But 20% of what? City hall says I get a tax rate of 20%, which equals §12075 every 24 hours. If the tax rate were based on population, my population is 104184, so times 20% = §20837. That can't be it, so it must be something else.
2015/01/06
[ "https://gaming.stackexchange.com/questions/199736", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/29603/" ]
Here is what I received from EA: > > Please note - the figure of 20% tax is calculated from levels and ratios for happiness and population, it's not as simple as happiness multiplied by population! A 20% tax rate is not simply 20% of your total population number in Simoleon form. If it were this simple an equation, early level Mayors would receive barely anything and find it a real struggle to make money for a long time, whereas higher level Mayors could buy everything in sight and would dominate the Markets. We didn't think this was very fair, particularly for a free-to-play game, and the balance of the game would have suffered too much. > > >
Actually, what I noticed is that it seems to be 20% of your base population based on number of residences without the adders for parks, transport etc. So even though I have a population of 350,000 without all of the population boosters my population should be around 72,000. Big difference, but that makes my sense for why my daily tax is less than $15,000.
199,736
I know that the tax rate varies based on how happy the Sims are. Let's say my Sims are 99% happy. The tax rate is 20%. But 20% of what? City hall says I get a tax rate of 20%, which equals §12075 every 24 hours. If the tax rate were based on population, my population is 104184, so times 20% = §20837. That can't be it, so it must be something else.
2015/01/06
[ "https://gaming.stackexchange.com/questions/199736", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/29603/" ]
Here is what I received from EA: > > Please note - the figure of 20% tax is calculated from levels and ratios for happiness and population, it's not as simple as happiness multiplied by population! A 20% tax rate is not simply 20% of your total population number in Simoleon form. If it were this simple an equation, early level Mayors would receive barely anything and find it a real struggle to make money for a long time, whereas higher level Mayors could buy everything in sight and would dominate the Markets. We didn't think this was very fair, particularly for a free-to-play game, and the balance of the game would have suffered too much. > > >
I got the same BS answer from EA. if you really want to know how your paid the 20 percent is absolutely meaningless. using regression trend lines on Excel I have formulated the equations, note this is with 100% happiness. Y=.018x+10199 I started this with my population at 110704. This tells you how much money one will receive with x=pop. Y=-.06ln(x)+.8063 this is the percentage you get per population this is a downward logarithmic trendline. the first equation has an R value of 1 and I have 9 different points, an R value of one is perfect. the second trend line has an R value of .976 which is close to perfect.
199,736
I know that the tax rate varies based on how happy the Sims are. Let's say my Sims are 99% happy. The tax rate is 20%. But 20% of what? City hall says I get a tax rate of 20%, which equals §12075 every 24 hours. If the tax rate were based on population, my population is 104184, so times 20% = §20837. That can't be it, so it must be something else.
2015/01/06
[ "https://gaming.stackexchange.com/questions/199736", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/29603/" ]
Actually, what I noticed is that it seems to be 20% of your base population based on number of residences without the adders for parks, transport etc. So even though I have a population of 350,000 without all of the population boosters my population should be around 72,000. Big difference, but that makes my sense for why my daily tax is less than $15,000.
One thing which is quite obvious is that the tax is good at lower levels but exponentially decreases with every population. I was able to raise the tax to 10k when I had 100k population, but now I am at 150k population and the tax is only 12k. (Both at 99% happiness) This seems to be a well designed trick by EA. People who are deeply engaged in the game and rising in population are more susceptible to spending money.
199,736
I know that the tax rate varies based on how happy the Sims are. Let's say my Sims are 99% happy. The tax rate is 20%. But 20% of what? City hall says I get a tax rate of 20%, which equals §12075 every 24 hours. If the tax rate were based on population, my population is 104184, so times 20% = §20837. That can't be it, so it must be something else.
2015/01/06
[ "https://gaming.stackexchange.com/questions/199736", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/29603/" ]
Actually, what I noticed is that it seems to be 20% of your base population based on number of residences without the adders for parks, transport etc. So even though I have a population of 350,000 without all of the population boosters my population should be around 72,000. Big difference, but that makes my sense for why my daily tax is less than $15,000.
I got the same BS answer from EA. if you really want to know how your paid the 20 percent is absolutely meaningless. using regression trend lines on Excel I have formulated the equations, note this is with 100% happiness. Y=.018x+10199 I started this with my population at 110704. This tells you how much money one will receive with x=pop. Y=-.06ln(x)+.8063 this is the percentage you get per population this is a downward logarithmic trendline. the first equation has an R value of 1 and I have 9 different points, an R value of one is perfect. the second trend line has an R value of .976 which is close to perfect.
5,145,324
I have some old tables with, what I think, are nearly worthless indexes. How can I easily be sure that are not ever being used before I drop them.
2011/02/28
[ "https://Stackoverflow.com/questions/5145324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/626960/" ]
Based on Joe's answer I came up with this: ``` SELECT row_number() over(order by user_seeks,user_lookups,user_scans), [Database] = d.name, [Schema]= s.name, [Table]= o.name, [Index]= x.name, [Scans] = user_scans, [Seeks] = user_seeks, [Lookups] = user_lookups, [Last Scan] = last_user_scan, [System Scans] = system_scans FROM sys.dm_db_index_usage_stats u INNER JOIN sys.sysdatabases d on u.database_id = d.dbid INNER JOIN sys.sysindexes x on u.object_id = x.id and u.index_id = x.indid INNER JOIN sys.objects o on u.object_id = o.object_id INNER JOIN sys.schemas s on s.schema_id = o.schema_id where x.name is not null order by 1 desc ```
Take a look at the [sys.dm\_db\_index\_usage\_stats](http://msdn.microsoft.com/en-us/library/ms188755.aspx) DMV. Just be careful to keep in mind that these counters are reset every time SQL Server is restarted.
5,145,324
I have some old tables with, what I think, are nearly worthless indexes. How can I easily be sure that are not ever being used before I drop them.
2011/02/28
[ "https://Stackoverflow.com/questions/5145324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/626960/" ]
Take a look at the [sys.dm\_db\_index\_usage\_stats](http://msdn.microsoft.com/en-us/library/ms188755.aspx) DMV. Just be careful to keep in mind that these counters are reset every time SQL Server is restarted.
Check out [this section](http://msdn.microsoft.com/en-us/magazine/cc135978.aspx#S5) of [this article](http://msdn.microsoft.com/en-us/magazine/cc135978.aspx) by Ian Stirk in 2007. Very nice set of tools, including finding your unused indexes.
5,145,324
I have some old tables with, what I think, are nearly worthless indexes. How can I easily be sure that are not ever being used before I drop them.
2011/02/28
[ "https://Stackoverflow.com/questions/5145324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/626960/" ]
Take a look at the [sys.dm\_db\_index\_usage\_stats](http://msdn.microsoft.com/en-us/library/ms188755.aspx) DMV. Just be careful to keep in mind that these counters are reset every time SQL Server is restarted.
Check if the user seeks of the index are increasing with every select on the table u r using unless the server is restarted this will give you a clear idea which index is being used or not. ``` SELECT DISTINCT OBJECT_NAME(sis.OBJECT_ID) TableName, si.name AS IndexName, sc.Name AS ColumnName, sic.Index_ID, sis.user_seeks, sis.user_scans, sis.user_lookups, sis.user_updates FROM sys.dm_db_index_usage_stats sis INNER JOIN sys.indexes si ON sis.OBJECT_ID = si.OBJECT_ID AND sis.Index_ID = si.Index_ID INNER JOIN sys.index_columns sic ON sis.OBJECT_ID = sic.OBJECT_ID AND sic.Index_ID = si.Index_ID INNER JOIN sys.columns sc ON sis.OBJECT_ID = sc.OBJECT_ID AND sic.Column_ID = sc.Column_ID WHERE sis.Database_ID = DB_ID('database_name') AND sis.OBJECT_ID = OBJECT_ID('table_name'); GO ```
5,145,324
I have some old tables with, what I think, are nearly worthless indexes. How can I easily be sure that are not ever being used before I drop them.
2011/02/28
[ "https://Stackoverflow.com/questions/5145324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/626960/" ]
Based on Joe's answer I came up with this: ``` SELECT row_number() over(order by user_seeks,user_lookups,user_scans), [Database] = d.name, [Schema]= s.name, [Table]= o.name, [Index]= x.name, [Scans] = user_scans, [Seeks] = user_seeks, [Lookups] = user_lookups, [Last Scan] = last_user_scan, [System Scans] = system_scans FROM sys.dm_db_index_usage_stats u INNER JOIN sys.sysdatabases d on u.database_id = d.dbid INNER JOIN sys.sysindexes x on u.object_id = x.id and u.index_id = x.indid INNER JOIN sys.objects o on u.object_id = o.object_id INNER JOIN sys.schemas s on s.schema_id = o.schema_id where x.name is not null order by 1 desc ```
Check out [this section](http://msdn.microsoft.com/en-us/magazine/cc135978.aspx#S5) of [this article](http://msdn.microsoft.com/en-us/magazine/cc135978.aspx) by Ian Stirk in 2007. Very nice set of tools, including finding your unused indexes.
5,145,324
I have some old tables with, what I think, are nearly worthless indexes. How can I easily be sure that are not ever being used before I drop them.
2011/02/28
[ "https://Stackoverflow.com/questions/5145324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/626960/" ]
Based on Joe's answer I came up with this: ``` SELECT row_number() over(order by user_seeks,user_lookups,user_scans), [Database] = d.name, [Schema]= s.name, [Table]= o.name, [Index]= x.name, [Scans] = user_scans, [Seeks] = user_seeks, [Lookups] = user_lookups, [Last Scan] = last_user_scan, [System Scans] = system_scans FROM sys.dm_db_index_usage_stats u INNER JOIN sys.sysdatabases d on u.database_id = d.dbid INNER JOIN sys.sysindexes x on u.object_id = x.id and u.index_id = x.indid INNER JOIN sys.objects o on u.object_id = o.object_id INNER JOIN sys.schemas s on s.schema_id = o.schema_id where x.name is not null order by 1 desc ```
Check if the user seeks of the index are increasing with every select on the table u r using unless the server is restarted this will give you a clear idea which index is being used or not. ``` SELECT DISTINCT OBJECT_NAME(sis.OBJECT_ID) TableName, si.name AS IndexName, sc.Name AS ColumnName, sic.Index_ID, sis.user_seeks, sis.user_scans, sis.user_lookups, sis.user_updates FROM sys.dm_db_index_usage_stats sis INNER JOIN sys.indexes si ON sis.OBJECT_ID = si.OBJECT_ID AND sis.Index_ID = si.Index_ID INNER JOIN sys.index_columns sic ON sis.OBJECT_ID = sic.OBJECT_ID AND sic.Index_ID = si.Index_ID INNER JOIN sys.columns sc ON sis.OBJECT_ID = sc.OBJECT_ID AND sic.Column_ID = sc.Column_ID WHERE sis.Database_ID = DB_ID('database_name') AND sis.OBJECT_ID = OBJECT_ID('table_name'); GO ```
5,145,324
I have some old tables with, what I think, are nearly worthless indexes. How can I easily be sure that are not ever being used before I drop them.
2011/02/28
[ "https://Stackoverflow.com/questions/5145324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/626960/" ]
Check if the user seeks of the index are increasing with every select on the table u r using unless the server is restarted this will give you a clear idea which index is being used or not. ``` SELECT DISTINCT OBJECT_NAME(sis.OBJECT_ID) TableName, si.name AS IndexName, sc.Name AS ColumnName, sic.Index_ID, sis.user_seeks, sis.user_scans, sis.user_lookups, sis.user_updates FROM sys.dm_db_index_usage_stats sis INNER JOIN sys.indexes si ON sis.OBJECT_ID = si.OBJECT_ID AND sis.Index_ID = si.Index_ID INNER JOIN sys.index_columns sic ON sis.OBJECT_ID = sic.OBJECT_ID AND sic.Index_ID = si.Index_ID INNER JOIN sys.columns sc ON sis.OBJECT_ID = sc.OBJECT_ID AND sic.Column_ID = sc.Column_ID WHERE sis.Database_ID = DB_ID('database_name') AND sis.OBJECT_ID = OBJECT_ID('table_name'); GO ```
Check out [this section](http://msdn.microsoft.com/en-us/magazine/cc135978.aspx#S5) of [this article](http://msdn.microsoft.com/en-us/magazine/cc135978.aspx) by Ian Stirk in 2007. Very nice set of tools, including finding your unused indexes.
13,893,803
I have a plain text file with some data in it, that I'm trying to open and read using a Python (ver 3.2) program, and trying to load that data into a data structure within the program. Here's what my text file looks like (file is called "data.txt") ``` NAME: Joe Smith CLASS: Fighter STR: 14 DEX: 7 ``` Here's what my program looks like: ``` player_name = None player_class = None player_STR = None player_DEX = None f = open("data.txt") data = f.readlines() for d in data: # parse input, assign values to variables print(d) f.close() ``` **My question is, how do I assign the values to the variables (something like setting player\_STR = 14 within the program)?**
2012/12/15
[ "https://Stackoverflow.com/questions/13893803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348408/" ]
``` player = {} f = open("data.txt") data = f.readlines() for line in data: # parse input, assign values to variables key, value = line.split(":") player[key.strip()] = value.strip() f.close() ``` now the name of your player will be `player['name']`, and the same goes for all other properties in your file.
``` import re pattern = re.compile(r'([\w]+): ([\w\s]+)') f = open("data.txt") v = dict(pattern.findall(f.read())) player_name = v.get("name") plater_class = v.get('class') # ... f.close() ```
13,893,803
I have a plain text file with some data in it, that I'm trying to open and read using a Python (ver 3.2) program, and trying to load that data into a data structure within the program. Here's what my text file looks like (file is called "data.txt") ``` NAME: Joe Smith CLASS: Fighter STR: 14 DEX: 7 ``` Here's what my program looks like: ``` player_name = None player_class = None player_STR = None player_DEX = None f = open("data.txt") data = f.readlines() for d in data: # parse input, assign values to variables print(d) f.close() ``` **My question is, how do I assign the values to the variables (something like setting player\_STR = 14 within the program)?**
2012/12/15
[ "https://Stackoverflow.com/questions/13893803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348408/" ]
``` player = {} f = open("data.txt") data = f.readlines() for line in data: # parse input, assign values to variables key, value = line.split(":") player[key.strip()] = value.strip() f.close() ``` now the name of your player will be `player['name']`, and the same goes for all other properties in your file.
The most direct way to do it is to assign the variables one at a time: ``` f = open("data.txt") for line in f: # loop over the file directly line = line.rstrip() # remove the trailing newline if line.startswith('NAME: '): player_name = line[6:] elif line.startswith('CLASS: '): player_class = line[7:] elif line.startswith('STR: '): player_strength = int(line[5:]) elif line.startswith('DEX: '): player_dexterity = int(line[5:]) else: raise ValueError('Unknown attribute: %r' % line) f.close() ``` That said, most Python programmers would stored the values in a dictionary rather than in variables. The fields can be stripped (removing the line endings) and split with: `characteristic, value = data.rstrip().split(':')`. If the value should be a number instead of a string, convert it with *float()* or *int()*.
13,893,803
I have a plain text file with some data in it, that I'm trying to open and read using a Python (ver 3.2) program, and trying to load that data into a data structure within the program. Here's what my text file looks like (file is called "data.txt") ``` NAME: Joe Smith CLASS: Fighter STR: 14 DEX: 7 ``` Here's what my program looks like: ``` player_name = None player_class = None player_STR = None player_DEX = None f = open("data.txt") data = f.readlines() for d in data: # parse input, assign values to variables print(d) f.close() ``` **My question is, how do I assign the values to the variables (something like setting player\_STR = 14 within the program)?**
2012/12/15
[ "https://Stackoverflow.com/questions/13893803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348408/" ]
``` import re pattern = re.compile(r'([\w]+): ([\w\s]+)') f = open("data.txt") v = dict(pattern.findall(f.read())) player_name = v.get("name") plater_class = v.get('class') # ... f.close() ```
The most direct way to do it is to assign the variables one at a time: ``` f = open("data.txt") for line in f: # loop over the file directly line = line.rstrip() # remove the trailing newline if line.startswith('NAME: '): player_name = line[6:] elif line.startswith('CLASS: '): player_class = line[7:] elif line.startswith('STR: '): player_strength = int(line[5:]) elif line.startswith('DEX: '): player_dexterity = int(line[5:]) else: raise ValueError('Unknown attribute: %r' % line) f.close() ``` That said, most Python programmers would stored the values in a dictionary rather than in variables. The fields can be stripped (removing the line endings) and split with: `characteristic, value = data.rstrip().split(':')`. If the value should be a number instead of a string, convert it with *float()* or *int()*.
70,692,034
I'm in the middle of a port to the newest c++ Builder 11 (Clang) compiler and I ran into a warning that I don't understand The warning: ``` 'dllimport' attribute only applies to variables, functions and classes ``` The simplified code: ``` class Test { public: Test() ; int __declspec(dllimport) (*DllFunction) (int a, int b) ; } ; ``` And during construction (for instance) I load the dll and find a pointer for `DllFunction` This **is** a function, so .. why the warning ? What am I not getting ?
2022/01/13
[ "https://Stackoverflow.com/questions/70692034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2650419/" ]
As the error message says, `dllimport` cannot be used to import individual class methods. Only *standalone* variables and functions, and *whole* classes. However, `dllimport` is meant for **static linking** only, but you are using **dynamic loading** instead, so there is no need to use `dllimport` in this code at all.
You can't `dllimport` a member function without `dllimport`-ing the whole class - this is where your `dllimport` should be.
2,474,477
I am trying to solve the equation $x^2 + y^2 + z^2 = n$ for $n = 1.2 \times 10^6 $ I have counted 131 solutions, which is certainly wrong. I think: $$ r\_3( 1.2 \times 10^6) = r\_3(2^7) \times r\_3(3) \times r\_3(5^6) $$ Certainly the middle one is easy: $$ r\_3(3) = 1 \text{ e.g. } 3 = 1^2 + 1^2 + 1^2 $$ I don't know how many ways $n = 128$ or $n = 15625$ can be the sum of three squares.
2017/10/16
[ "https://math.stackexchange.com/questions/2474477", "https://math.stackexchange.com", "https://math.stackexchange.com/users/4997/" ]
Hint: For any integer $x,$ $$x^2\equiv0,1\pmod4$$ So, $a,b,c$ must be even Check for $\pmod3,\pmod5$
1488.................................................... ``` 1471. 1040 344 -8 1472. 1040 344 8 1473. 1064 -248 -80 1474. 1064 -248 80 1475. 1064 -80 -248 1476. 1064 -80 248 1477. 1064 80 -248 1478. 1064 80 248 1479. 1064 248 -80 1480. 1064 248 80 1481. 1072 -200 -104 1482. 1072 -200 104 1483. 1072 -104 -200 1484. 1072 -104 200 1485. 1072 104 -200 1486. 1072 104 200 1487. 1072 200 -104 1488. 1072 200 104 jagy@phobeusjunior:~$ ```
2,474,477
I am trying to solve the equation $x^2 + y^2 + z^2 = n$ for $n = 1.2 \times 10^6 $ I have counted 131 solutions, which is certainly wrong. I think: $$ r\_3( 1.2 \times 10^6) = r\_3(2^7) \times r\_3(3) \times r\_3(5^6) $$ Certainly the middle one is easy: $$ r\_3(3) = 1 \text{ e.g. } 3 = 1^2 + 1^2 + 1^2 $$ I don't know how many ways $n = 128$ or $n = 15625$ can be the sum of three squares.
2017/10/16
[ "https://math.stackexchange.com/questions/2474477", "https://math.stackexchange.com", "https://math.stackexchange.com/users/4997/" ]
The number of solutions $(x,y)\in\mathbb{Z}^2$ of $x^2+y^2=m$ is given by $$ 4\left(\chi\_4 \* 1\right)(m) = 4\sum\_{d\mid m}\chi\_4(d) = 4\!\!\!\!\!\!\sum\_{\substack{d\mid m\\ d\equiv 1\!\!\pmod{4}}}\!\!\!\!\!1-4\!\!\!\!\!\!\sum\_{\substack{d\mid m\\ d\equiv 3\!\!\pmod{4}}}\!\!\!\!\!1 $$ hence the number of solutions $(x,y,z)\in\mathbb{Z}^3$ of $x^2+y^2+z^2=1200000$ is given by $$ 4(\chi\_4\*1)(1200000)+2\sum\_{k=1}^{1095} 4(\chi\_4\*1)(1200000-k^2)=\color{red}{1488}. $$
Hint: For any integer $x,$ $$x^2\equiv0,1\pmod4$$ So, $a,b,c$ must be even Check for $\pmod3,\pmod5$
2,474,477
I am trying to solve the equation $x^2 + y^2 + z^2 = n$ for $n = 1.2 \times 10^6 $ I have counted 131 solutions, which is certainly wrong. I think: $$ r\_3( 1.2 \times 10^6) = r\_3(2^7) \times r\_3(3) \times r\_3(5^6) $$ Certainly the middle one is easy: $$ r\_3(3) = 1 \text{ e.g. } 3 = 1^2 + 1^2 + 1^2 $$ I don't know how many ways $n = 128$ or $n = 15625$ can be the sum of three squares.
2017/10/16
[ "https://math.stackexchange.com/questions/2474477", "https://math.stackexchange.com", "https://math.stackexchange.com/users/4997/" ]
The number of solutions $(x,y)\in\mathbb{Z}^2$ of $x^2+y^2=m$ is given by $$ 4\left(\chi\_4 \* 1\right)(m) = 4\sum\_{d\mid m}\chi\_4(d) = 4\!\!\!\!\!\!\sum\_{\substack{d\mid m\\ d\equiv 1\!\!\pmod{4}}}\!\!\!\!\!1-4\!\!\!\!\!\!\sum\_{\substack{d\mid m\\ d\equiv 3\!\!\pmod{4}}}\!\!\!\!\!1 $$ hence the number of solutions $(x,y,z)\in\mathbb{Z}^3$ of $x^2+y^2+z^2=1200000$ is given by $$ 4(\chi\_4\*1)(1200000)+2\sum\_{k=1}^{1095} 4(\chi\_4\*1)(1200000-k^2)=\color{red}{1488}. $$
1488.................................................... ``` 1471. 1040 344 -8 1472. 1040 344 8 1473. 1064 -248 -80 1474. 1064 -248 80 1475. 1064 -80 -248 1476. 1064 -80 248 1477. 1064 80 -248 1478. 1064 80 248 1479. 1064 248 -80 1480. 1064 248 80 1481. 1072 -200 -104 1482. 1072 -200 104 1483. 1072 -104 -200 1484. 1072 -104 200 1485. 1072 104 -200 1486. 1072 104 200 1487. 1072 200 -104 1488. 1072 200 104 jagy@phobeusjunior:~$ ```
52,576,835
I have a matrix as below: ``` array([[1, 0, 1, 1, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0]]) ``` I want to choose randomly 3 position in this matrix, and change labels in those position and the position next to it. The result should be like this: ``` array([[1, 0, 1, 1, 0], [1, 12, 12, 0, 0], [0, 0, 0, 1, 0], [0, 13, 13, 14, 14], [1, 0, 0, 0, 0]]) ``` The labels is choose randomly from list[10, 11, 12, 13, 14, 15]. How can I do this in python? Actually, I tried some methods but it doesn't work properly.
2018/09/30
[ "https://Stackoverflow.com/questions/52576835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6482143/" ]
this can be achieved using a similar & classic problem solving ([Flatten an irregular list of lists](https://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists)), no need to reinvent the wheel, just use some working method & post-process: Flatten the list of lists, then take min & max of it. ``` import collections def flatten(l): # function copied from the link above for el in l: if isinstance(el, collections.Iterable) and not isinstance(el, (str, bytes)): yield from flatten(el) else: yield el lst = [1, 5, [7, 10, []]] new_list = list(flatten(lst)) # create a list cos we'll be iterating twice on it print(max(new_list)) print(min(new_list)) ``` result ``` 10 1 ``` with one iteration with a manual loop: ``` min_value = None max_value = None for v in flatten(lst): if min_value is None or v < min_value: min_value = v if max_value is None or v > max_value: max_value = v print(min_value) print(max_value) ``` the `flatten` method is nice because it doesn't create temporary `list` elements so no unneccesary memory allocations.
You can use the following recursive function that returns the maximum and minimum among the items in the current list and the maximum and minimum of the sublists: ``` def high_low(l): try: l.extend(high_low(l.pop())) except AttributeError: return [l] except IndexError: return [] return max(l), min(l) ``` so that: ``` lst = [1, 5, [7, 10, []]] print(high_low(lst)) ``` outputs: ``` (10, 1) ```
52,576,835
I have a matrix as below: ``` array([[1, 0, 1, 1, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0]]) ``` I want to choose randomly 3 position in this matrix, and change labels in those position and the position next to it. The result should be like this: ``` array([[1, 0, 1, 1, 0], [1, 12, 12, 0, 0], [0, 0, 0, 1, 0], [0, 13, 13, 14, 14], [1, 0, 0, 0, 0]]) ``` The labels is choose randomly from list[10, 11, 12, 13, 14, 15]. How can I do this in python? Actually, I tried some methods but it doesn't work properly.
2018/09/30
[ "https://Stackoverflow.com/questions/52576835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6482143/" ]
Here's one possibility to write the code with only one pass, no need for external library or python's `min/max`: ``` def high_low(list_or_number): if isinstance(list_or_number, list): current_min = float('inf') current_max = float('-inf') for x in list_or_number: x_max, x_min = high_low(x) if x_max > current_max: current_max = x_max if x_min < current_min: current_min = x_min return (current_max, current_min) else: return (list_or_number, list_or_number) ``` As an example: ``` >>> high_low([1, 5, [7, 10, [[12, 16], -10]]]) (16, -10) >>> high_low(3) (3, 3) >>> high_low([3,4,5]) (5, 3) ```
You can use the following recursive function that returns the maximum and minimum among the items in the current list and the maximum and minimum of the sublists: ``` def high_low(l): try: l.extend(high_low(l.pop())) except AttributeError: return [l] except IndexError: return [] return max(l), min(l) ``` so that: ``` lst = [1, 5, [7, 10, []]] print(high_low(lst)) ``` outputs: ``` (10, 1) ```
53,278,552
I have been reading the [Introduction to POM](https://maven.apache.org/pom.html) and don't understand the following. In the pom.xml you can configure dependencies, let's say we configure dependency `maven-embedder`. Then you can exclude a dependencies of your dependency, let's say we want to exclude `maven-core` from the `maven-embedder` dependency. In what cases would you like to do that? Wouldn’t that cause your dependency to stop working if it does not have all it dependencies? I’m obviously missing a puzzle piece here :) ``` <dependencies> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-embedder</artifactId> <version>2.0</version> <exclusions> <exclusion> <groupId>org.apache.maven</groupId> <artifactId>maven-core</artifactId> </exclusion> </exclusions> </dependency> ... </dependencies> ``` Example: <https://maven.apache.org/pom.html#Exclusions>
2018/11/13
[ "https://Stackoverflow.com/questions/53278552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7943988/" ]
So I managed to find what the issue was. The problem lies with CORS. In particular, the middleware works as expected however due to CORS a preflight request is sent which does not have the JWT token which is why I got the error in the first example. I have updated the middleware to skip the preflight requests: ``` if (req.headers['access-control-request-headers'] === 'x-access-token') { return next(); } [...] ```
I'm guessing this to be a problem of `req.headers['x-access-token']`. Once `next()` is called, the control goes to the next endpoint route. You should provide JWT as initials to the token.
8,620,068
I'm writing an Android application that has a scrollview which contains a linearlayout: ``` <ScrollView android:id="@+id/ScrollView01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity=top" android:layout_marginTop="240dip" android:layout_marginRight="0dip" android:layout_marginBottom="60dip"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/centerlayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="top" android:layout_marginRight="20dip" android:layout_marginLeft="10dip" android:layout_marginBottom="120dip"> ``` As you see, scrollview's margin top is "240dip" . I want to be able to change it in my Java code. I tried this: ``` ScrollView scrollView=(ScrollView)findViewById(R.id.ScrollView01); LayoutParams params=scrollView.getLayoutParams(); ``` But I can't do this: params.top=100; Would you please help me how I can do it?
2011/12/23
[ "https://Stackoverflow.com/questions/8620068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1015002/" ]
What do you mean that you "can't do this". You would have to do `params.top=100;` and then `scrollView.setLayoutParams(params);`. But you could change it to: ``` ScrollView scrollView=(ScrollView)findViewById(R.id.ScrollView01); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(scrollView.getLayoutParams()); params.topMargin = 100; scrollView.setLayoutParams(params); ```
Try ``` params.gravity = Gravity.LEFT | Gravity.TOP; ``` without the line you will have problems.
11,633,823
I am trying to run a JSF 2.0 webapp using Apache MyFaces 2.1.7 on a Tomcat 6 webserver. The App uses Tomahawk 1.1.11 and expression language 2.2 (el-impl-2.2.jar). For that purpose I've put the myfaces-api and myfaces-impl into Tomcats lib folder and exchanged Tomcats el-api.jar for the 2.2 variant. When I call the first page of the app I always get the error: ``` java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions! If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml. A typical config looks like this; <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener> javax.faces.FactoryFinder._getFactory(FactoryFinder.java:286) javax.faces.FactoryFinder.getFactory(FactoryFinder.java:206) javax.faces.webapp.FacesServlet.init(FacesServlet.java:116) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Thread.java:679) ``` I definitely have the xml snippet mentioned in my `web.xml`. I tried to debug into the code and found that `registeredFactoryNames` on line 267 of `javax.faces.FactoryFinder` is empty which causes the error. I however do not understand why this is the case. What should be in there and how do I get it there? The funny thing is that the webapp runs perfectly using embedded jetty 8. So it must be some dependency issue. Hope someone with more insight into all of this can help me here.
2012/07/24
[ "https://Stackoverflow.com/questions/11633823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/367391/" ]
Ok I found the problem. The error results from having the myfaces-api.jar twice on your classpath. So for me the problem was I placed the myfaces-api.jar in the tomcat lib folder and in the WEB-INF/lib folder of the webapp. While using an embedded tomcat with maven I had the myfaces-api.jar in the dependencies of the whole application and in the dependencies of the tomcat6-maven-plugin with scope compile both. I changed the scope from compile to provided in the global dependencies section and it worked.
I think it could be solved just adding an empty faces-config.xml file under /WEB-INF/ folder, to indicate the application uses JSF and MyFaces continue the initialization step. See the class org.apache.myfaces.ee6.MyFacesContainerInitializer for details.
47,272
My 3 wall lights are hard wired and have on-off switches on the units. There is no wall switch for any of them. The trouble is they are all different fixtures and all pretty ugly. I'm looking to replace them without spending a fortune (ideally something with a Mission feel for under $100 apiece), but finding a good replacement is hard, with the limitation of an on-off switch on the fixture. Is it possible somehow to convert a non-switched receptacle to a switched one, or is there some kind of piece that you can screw in before you screw in the light bulb that is a switch, or some kind of solution to this problem? Can I take a plug-in lamp with an on-off switch (obviously not inline with the cord, but on the fixture itself), and install that in the wall? I feel like it would be hard to *attach* such a fixture to the wall, though. In addition to ideas for converting the fixtures, I welcome suggestions for places that sell nice-ish switched lights. I have already combed through regular search-engine results without much luck.
2014/08/08
[ "https://diy.stackexchange.com/questions/47272", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/11086/" ]
How about a "smart bulb" product such as an [Insteon LED bulb](http://www.insteon.com/267x-led-bulbs.html)? I've used these to replace old pull-chain ceiling sockets with more attractive fixtures. A single bulb is around $50 and you can buy a [wall mount remote](http://www.insteon.com/2342-x32-mini-remote.html) for around $30.
I would install a wall switch. **Diagnosis.** 1. Turn the lights on. 2. Flip breakers until the lights go off. 3. Find a receptacle near the lights that also went off. Now, chances are, that there is a cord running up the wall from that receptacle that powers the lights. 1. Remove the receptacle. (Power still off!) The wire coming into the box from the bottom is likely your panel connection, and the one running out the top is probably your light power. BUT!!!! it might also be powering other things. 2. Disconnect the upper wires from the receptacle, wire nut the ends so they're safe, and wrap electrical tape right around the screws on the receptacle so you don't accidentally short it out against the box. 3. Turn the power back on. Test the receptacle and the lights, and anything else in the vicinity. If everything is good, the lights are off, and the receptacle works AND everything else in the house works. If not, turn the power off and re-wire everything the way it was. The following is really only applicable if the situation is exactly as I described above. There are many possible configurations. For example, the power could be going to the lights, then to the receptacle. Or, there could be another receptacle or more lights being powered at the end of the chain. In either situation, you'll need to pull more wire and damage more plaster. At this point, I'd call in a professional. The following instructions involve messing around with wiring. If you do not feel 100% confident in your abilities, Call a professional. **Installation:** 1. Turn the power off! 2. Follow the wire up the wall to a good switch height. 3. With a drywall saw, cut a hole for your new switch and box. (Get an OLD WORK box). 4. Tape some 14-2 wire to the disconnected wire in the receptacle hole. Pull it up to the switch hole, leaving a foot or more of excess. (it may be staple to a stud. Yank hard.) 5. Cut the old wire, leaving about a foot or more below the hole. 6. Remove about 8 or more inches of outer sheathing from both the light wire and the new wire. Thread them both into the box and tighten the clamps. Install the box. 7. From the wire you're going to discard, pull out about 4 inches of bare copper. There should be a grounding screw at the back of the box. Screw both grounds and the short piece to this screw. Attach the other end of the short piece to the green screw on the switch. When wrapping around screws, your curl should be clockwise, so the screw doesn't squeeze them out. 8. Strip the whites, and wire nut them together. 9. Strip the blacks, and attach them to the other two screws on the switch. 10. Install the switch and faceplate. 11. Go back down to the receptacle, and wire the new wire back up, the way the old wire was. 12. Reinstall the receptacle and faceplate. 13. Power on. And all 3 lights should be on the switch. If you want 3 switches, then it's a bigger job, and may be impossible without serious wall damage. Essentially you'd get a 3-gang box, pull the wire up from the receptacle, and feed new wires to each light individually. That's better left for another question.
47,272
My 3 wall lights are hard wired and have on-off switches on the units. There is no wall switch for any of them. The trouble is they are all different fixtures and all pretty ugly. I'm looking to replace them without spending a fortune (ideally something with a Mission feel for under $100 apiece), but finding a good replacement is hard, with the limitation of an on-off switch on the fixture. Is it possible somehow to convert a non-switched receptacle to a switched one, or is there some kind of piece that you can screw in before you screw in the light bulb that is a switch, or some kind of solution to this problem? Can I take a plug-in lamp with an on-off switch (obviously not inline with the cord, but on the fixture itself), and install that in the wall? I feel like it would be hard to *attach* such a fixture to the wall, though. In addition to ideas for converting the fixtures, I welcome suggestions for places that sell nice-ish switched lights. I have already combed through regular search-engine results without much luck.
2014/08/08
[ "https://diy.stackexchange.com/questions/47272", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/11086/" ]
How about a "smart bulb" product such as an [Insteon LED bulb](http://www.insteon.com/267x-led-bulbs.html)? I've used these to replace old pull-chain ceiling sockets with more attractive fixtures. A single bulb is around $50 and you can buy a [wall mount remote](http://www.insteon.com/2342-x32-mini-remote.html) for around $30.
One option would be to [go wireless](https://www.google.com/?gws_rd=ssl#q=wireless%20switch&tbm=shop). Find some fixtures that you like that would accommodate a screw in wireless adapter, and just wire them like the existing fixtures: ![enter image description here](https://i.stack.imgur.com/ugnTR.jpg) For some reason, key-chain remotes seem to be more common than wall switches, but there are plenty out there to choose from and a ton of different styles.
48,705,172
Since ResponseBodyAdvice interface is in web.servlet package How could I implement such functions in webflux?
2018/02/09
[ "https://Stackoverflow.com/questions/48705172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435786/" ]
I also have this problem, i found it can be done by HandlerResultHandler. For Example, I extend `ResponseBodyResultHandler` to wrap all my response First, you should write `ResponseWrapper.java` ``` public class ResponseWrapper extends ResponseBodyResultHandler { private static MethodParameter param; static { try { //get new params param = new MethodParameter(ResponseWrapper.class .getDeclaredMethod("methodForParams"), -1); } catch (NoSuchMethodException e) { e.printStackTrace(); } } public ResponseWrapper(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver) { super(writers, resolver); } private static Mono<Response> methodForParams() { return null; } @Override public boolean supports(HandlerResult result) { boolean isMono = result.getReturnType().resolve() == Mono.class; boolean isAlreadyResponse = result.getReturnType().resolveGeneric(0) == Response.class; return isMono && !isAlreadyResponse; } @Override @SuppressWarnings("unchecked") public Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result) { Preconditions.checkNotNull(result.getReturnValue(), "response is null!"); // modify the result as you want Mono<Response> body = ((Mono<Object>) result.getReturnValue()).map(Response::success) .defaultIfEmpty(Response.success()); return writeBody(body, param, exchange); } } ``` Then, add Bean in SpringBootApplication ``` @SpringBootApplication public class SmartApplication { @Autowired ServerCodecConfigurer serverCodecConfigurer; @Autowired RequestedContentTypeResolver requestedContentTypeResolver; @Bean ResponseWrapper responseWrapper() { return new ResponseWrapper(serverCodecConfigurer .getWriters(), requestedContentTypeResolver); } //Spring start public static void main(String[] args) { SpringApplication.run(SmartApplication.class, args); } } ``` My response class, for reference ``` @JsonInclude(JsonInclude.Include.NON_NULL) public class Response<T> { boolean success; T data; Object error; String warning; public Response() { } public static Response success() { return success(null); } public static <T> Response success(T data) { return new Response<T>().setSuccess(true).setData(data); } public static Response error(Throwable e) { LogManager.getLogger(StackLocatorUtil.getCallerClass(2)).info(e); return new Response().setSuccess(false).setError(e); } public static Response error(Object e) { return new Response().setSuccess(false).setError(e); } public static Response error(String e) { return new Response().setSuccess(false).setError(e); } /* get success */ public boolean isSuccess() { return success; } /* set success */ public Response setSuccess(boolean success) { this.success = success; return this; } /* get data */ public Object getData() { return data; } /* set data */ public Response setData(T data) { this.data = data; return this; } /* get error */ public Object getError() { return error; } /* set error */ public Response setError(Object error) { this.error = error; return this; } } ```
i used ResponseBodyAdvise before spring 5.0. i think ResponseBodyResultHandler suport webflux since spring5.0.
7,359,154
I'm writing an IDE for [DWScript](http://code.google.com/p/dwscript/) and have got it stepping through code using the debugger. I now wish to add a display of 'local variables' (i.e those in scope). Can someone give me a pointer to the means of doing this? I can get a list of all symbols but do not understand how to get the current scope part of things. Thanks.
2011/09/09
[ "https://Stackoverflow.com/questions/7359154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47012/" ]
Cast the *IdwsProgramExecution* to *TdwsProgramExecution*, you'll gain access to a "*CurrentProg*", property, a *TdwsProgram* which is either a *TdwsMainProgram* (if you're in the main) or a *TdwsProcedure* (if you're in a proc/func/method). Those will have a *Table* property, which lists the local symbols, that's the most direct scope. That *Table* will have one or more *Parents*, which refers the parent scopes (hierarchically, in terms of source code scope). If in a *TdwsProcedure*, you may also want to look at its *FuncSymbol* property, which will have a table of parameters (useful if you want to directly isolate the parameters from the rest of the local scope)
For any others reading this question, I will show some supplementary info concerned with getting the value of a symbol. The symbol is found as described by Eric above but it is hard to work out how to get the actual value of the symbol. The code below is a procedure that populates a TMemo (memLocalVariables) with local variables each time it is called. There are some features missing like neat formatting of the variable value and access to calling parameters. I call this from the debugger 'dsDebugSuspended' state. The less intuitive bit is the access to the symbol data on the stack and the use of the stack base pointer. A great way to learn how the compiler works! But, maybe there is a utility function somewhere I've not found...? Eric? ``` procedure DrawLocalVariables; var ProgramExecution : TdwsProgramExecution; I : integer; Sym : TSymbol; V : variant; Adr : integer; SymbolTable : TSymbolTable; begin memLocalVariables.Lines.Clear; ProgramExecution := TdwsProgramExecution( dwsDebugger1.Execution ); SymbolTable := ProgramExecution.CurrentProg.Table; For I := 0 to SymbolTable.Count-1 do begin Sym := SymbolTable[I]; if Sym is TDataSymbol then begin Adr := TDataSymbol( Sym).StackAddr + ProgramExecution.Stack.BasePointer; ProgramExecution.Stack.ReadValue( Adr, V ); memLocalVariables.Lines.Add( Format( '%s = %s', [ Sym.Name, VarToStr(V) ] )); end; end; end; ```
47,047,376
I have a Jupyter notebook (python3) which is a batch job -- it runs three separate python3 notebooks using `%run`. I want to invoke a fourth Jupyter R-kernel notebook from my batch. **Is there a way to execute an external R notebook from a Python notebook in Jupyter / iPython?** Current setup: `run_all.ipynb`: (python3 kernel) ``` %run '1_py3.ipynb' %run '2_py3.ipynb' %run '3_py3.ipynb' %run '4_R.ipynb' ``` The three python3 notebooks run correctly. The R notebook runs correctly when opened separately in Jupyter -- however it fails when called using `%run` from `run_all.ipynb`. It is interpreted as python, and the cell gives a python error on the first line: > > > ``` > cacheDir <- "caches" > > ``` > > TypeError: bad operand type for unary -: 'str' > > > I am interested in any solution for running a separate R notebook from a python notebook -- Jupyter magic, shell, python library, et cetera. I would also be interested in a workaround -- e.g. a method (like a shell script) that would run all four notebooks (both python3 and R) even if this can't be done from inside a python3 notebook. (NOTE: I already understand how to embed `%%R` in a cell. This is not what I am trying to do. I want to call a complete separate R notebook.)
2017/11/01
[ "https://Stackoverflow.com/questions/47047376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7207622/" ]
I don't think you can use the `%run` magic command that way as it executes the file in the current kernel. Nbconvert has an execution API that allows you to execute notebooks. So you could create a shell script that executes all your notebooks like so: ``` #!/bin/bash jupyter nbconvert --to notebook --execute 1_py3.ipynb jupyter nbconvert --to notebook --execute 2_py3.ipynb jupyter nbconvert --to notebook --execute 3_py3.ipynb jupyter nbconvert --to notebook --execute 4_R.ipynb ``` Since your notebooks require no shared state this should be fine. Alternatively, if you really wanna do it in a notebook, you use the execute Python API to call nbconvert from your notebook. ``` import nbformat from nbconvert.preprocessors import ExecutePreprocessor with open("1_py3.ipynb") as f1, open("2_py3.ipynb") as f2, open("3_py3.ipynb") as f3, open("4_R.ipynb") as f4: nb1 = nbformat.read(f1, as_version=4) nb2 = nbformat.read(f2, as_version=4) nb3 = nbformat.read(f3, as_version=4) nb4 = nbformat.read(f4, as_version=4) ep_python = ExecutePreprocessor(timeout=600, kernel_name='python3') #Use jupyter kernelspec list to find out what the kernel is called on your system ep_R = ExecutePreprocessor(timeout=600, kernel_name='ir') # path specifies which folder to execute the notebooks in, so set it to the one that you need so your file path references are correct ep_python.preprocess(nb1, {'metadata': {'path': 'notebooks/'}}) ep_python.preprocess(nb2, {'metadata': {'path': 'notebooks/'}}) ep_python.preprocess(nb3, {'metadata': {'path': 'notebooks/'}}) ep_R.preprocess(nb4, {'metadata': {'path': 'notebooks/'}}) with open("1_py3.ipynb", "wt") as f1, open("2_py3.ipynb", "wt") as f2, open("3_py3.ipynb", "wt") as f3, open("4_R.ipynb", "wt") as f4: nbformat.write(nb1, f1) nbformat.write(nb2, f2) nbformat.write(nb3, f3) nbformat.write(nb4, f4) ``` Note that this is pretty much just the example copied from the nbconvert execute API docs: [link](http://nbconvert.readthedocs.io/en/latest/execute_api.html)
I was able to use [the answer](https://stackoverflow.com/a/47053020/7207622) to implement two solutions to running an R notebook from a python3 notebook. ### 1. call nbconvert from `!` shell command Adding a simple `!` shell command to the python3 notebook: `!jupyter nbconvert --to notebook --execute r.ipynb` So the notebook looks like this: 1. `%run '1_py3.ipynb'` 2. `%run '2_py3.ipynb'` 3. `%run '3_py3.ipynb'` 4. `!jupyter nbconvert --to notebook --execute 4_R.ipynb` This seems simple and easy to use. ### 2. invoke nbformat in a cell Add this to a cell in the batch notebook: ``` import nbformat from nbconvert.preprocessors import ExecutePreprocessor rnotebook = "r.ipynb" rnotebook_out = "r_out.ipynb" rnotebook_path = '/home/jovyan/work/' with open(rnotebook) as f1: nb1 = nbformat.read(f1, as_version=4) ep_R = ExecutePreprocessor(timeout=600, kernel_name='ir') ep_R.preprocess(nb1, {'metadata': {'path': rnotebook_path}}) with open(rnotebook_out, "wt") as f1: nbformat.write(nb1, f1) ``` This is based on the answer from Louise Davies (which is based on the nbcovert docs example), but it only processes one file -- the non-R files can be processed in separate cells with `%run`. If the batch notebook is in the same folder as the notebook it is executing then the path variable can be set with the `%pwd` shell magic, which returns the path of the batch notebook. When we use nbformat.write we choose between replacing the original notebook (which is convenient and intuitive, but could corrupt or destroy the file) and creating a new file for output. A third option if the cell output isn't needed (e.g. in a workflow that manipulates files and writes logs) is to just ignore writing the cell output entirely. ### drawbacks One drawback to both methods is that they do not pipe cell results back into the master notebook display -- as opposed to the way that `%run` displays the output of a notebook in its result cell. The `!jupyter nbconvert` method appears to show stdout from nbconvert, while the `import nbconvert` method showed me nothing.
26,300,077
``` string = "@ABlue , @Red , @GYellow, @Yellow, @GGreen" new = re.sub('(@[A-Z][A-Z])', "########" , string) ``` I need a regular expression which is able to check for an @ following by two uppercase letters and than remove the @ and the first uppercase character.cc
2014/10/10
[ "https://Stackoverflow.com/questions/26300077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2631152/" ]
Using capturing group and backreference: ``` >>> import re >>> string = "@ABlue , @Red , @GYellow, @Yellow, @GGreen" >>> re.sub('@[A-Z]([A-Z])', r"\1" , string) 'Blue , @Red , Yellow, @Yellow, Green' ``` `\1` in the substitution string will be replaced with the first capturing group (The second uppercase letter). **NOTE** used a `r"raw string literal"`. Otherwise, you need to escape `\`: `"\\1"` Alternative using [positive lookahead assertion](http://www.regular-expressions.info/lookaround.html): ``` >>> re.sub('@[A-Z](?=[A-Z])', '' , string) 'Blue , @Red , Yellow, @Yellow, Green' ```
``` >>> new = re.sub(r"@[A-Z]([A-Z])", r"\1" , string) >>> new 'Blue , @Red , Yellow, @Yellow, Green' ```
50,806,427
I am parsing python bytecodes (co\_code). For some operation I want to know the length of python opcodes in bytes. Where can I find the length of python opcodes?
2018/06/11
[ "https://Stackoverflow.com/questions/50806427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3425984/" ]
All CPython bytecode opcodes are 1 byte long. On CPython 3.6+, all opcodes additionally take a 1-byte argument, for a total of 2 bytes per instruction. On previous versions, opcodes less than the special value [HAVE\_ARGUMENT](https://docs.python.org/3/library/dis.html#opcode-HAVE_ARGUMENT) take no argument, and opcodes greater than that value take a 2-byte argument, for a total of 1 or 3 bytes per instruction.
A simple function like this may help: ``` def compute_size(opcode): if sys.version_info >= (3, 6): return 2 return (1, 3)[opcode < dis.HAVE_ARGUMENT] ```
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
No, you don't have to cause the green fire to leap to another creature, as of the 2020 errata --------------------------------------------------------------------------------------------- The *green-flame blade* cantrip was updated when it was reprinted in *Tasha's Cauldron of Everything* (p. 107), and the version in the *Sword Coast Adventurer's Guide* (p. 143) received [errata](https://media.wizards.com/2020/dnd/downloads/SCAG-Errata.pdf) to match. The relevant line of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) spell description now reads: > > On a hit, the target suffers the weapon attack’s normal effects, and > **you can cause** green fire to leap from the target to a different > creature of your choice that you can see within 5 feet of it. > > > The use of the word "can" indicates that the green fire does not have to leap to a second creature. Thus, if the only other creatures within 5 feet of the initial target are the caster and their allies (for instance), the caster can choose not to have the green fire leap at all after the damage to the initial target. ### Even pre-errata, designer intent indicated that the caster didn't have to target another creature Pre-errata, it was not directly stated in the spell description whether you had to target yourself with the secondary damage if no other creature was in range, or if you could choose not to have the green fire leap to anybody at all. However, rules designer Jeremy Crawford unofficially answered this question in [a tweet from November 2015](https://twitter.com/JeremyECrawford/status/662433813956444160): > > *What does the leap effect of green-flame blade do if there are no hostile targets nearby? Does it jump to allies?* > > > **The intent is that you can choose no one. If you can't see, you can't choose anyway, and the flame halts** > > > While the wording might have suggested that the spell has to target another creature, Crawford clearly stated that that was not the intent; you could choose not to target anyone if there was no desired secondary target in range. The errata has brought this aspect of the spell in line with the stated intent. This makes sense to me. Given that if the attack hits, the caster could choose what creature the green fire leapt to, it makes sense that the caster could use the same control over targeting to prevent the green fire from jumping to any creature at all (e.g. by having it fizzle harmlessly against the ground, or extinguishing itself).
[Mike Mearls leaves the choice to the caster](https://www.sageadvice.eu/2016/07/04/green-flame-blade-no-target-creatures/). As always, every DM can rule differently. Please note that, while they could make their way into erratas, [tweets should not be treated as RAW](https://rpg.meta.stackexchange.com/questions/6250/are-tweets-an-official-rule-source).
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
No, you don't have to cause the green fire to leap to another creature, as of the 2020 errata --------------------------------------------------------------------------------------------- The *green-flame blade* cantrip was updated when it was reprinted in *Tasha's Cauldron of Everything* (p. 107), and the version in the *Sword Coast Adventurer's Guide* (p. 143) received [errata](https://media.wizards.com/2020/dnd/downloads/SCAG-Errata.pdf) to match. The relevant line of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) spell description now reads: > > On a hit, the target suffers the weapon attack’s normal effects, and > **you can cause** green fire to leap from the target to a different > creature of your choice that you can see within 5 feet of it. > > > The use of the word "can" indicates that the green fire does not have to leap to a second creature. Thus, if the only other creatures within 5 feet of the initial target are the caster and their allies (for instance), the caster can choose not to have the green fire leap at all after the damage to the initial target. ### Even pre-errata, designer intent indicated that the caster didn't have to target another creature Pre-errata, it was not directly stated in the spell description whether you had to target yourself with the secondary damage if no other creature was in range, or if you could choose not to have the green fire leap to anybody at all. However, rules designer Jeremy Crawford unofficially answered this question in [a tweet from November 2015](https://twitter.com/JeremyECrawford/status/662433813956444160): > > *What does the leap effect of green-flame blade do if there are no hostile targets nearby? Does it jump to allies?* > > > **The intent is that you can choose no one. If you can't see, you can't choose anyway, and the flame halts** > > > While the wording might have suggested that the spell has to target another creature, Crawford clearly stated that that was not the intent; you could choose not to target anyone if there was no desired secondary target in range. The errata has brought this aspect of the spell in line with the stated intent. This makes sense to me. Given that if the attack hits, the caster could choose what creature the green fire leapt to, it makes sense that the caster could use the same control over targeting to prevent the green fire from jumping to any creature at all (e.g. by having it fizzle harmlessly against the ground, or extinguishing itself).
It's up to the DM, there is no official ruling ---------------------------------------------- As noted in Sent\_'s answer, [Mike Mearls](http://www.sageadvice.eu/2015/11/09/green-flame-blade-no-target-creatures/) tells us that you needn't target yourself. While Mike Mearls is a lead designer of DnD 5e -- as nitsua60 reminds us -- he is not *the* authority of rules and rulings. [Mike Mearls concedes](https://twitter.com/mikemearls/status/748610510031978497) that there is no printed rule on his ruling. Thus, his ruling is simply that: A ruling. It carries as much weight as your own ruling as far as rules-as-written goes. Until there is an official ruling, this is up to your DM.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
It's up to the DM, there is no official ruling ---------------------------------------------- As noted in Sent\_'s answer, [Mike Mearls](http://www.sageadvice.eu/2015/11/09/green-flame-blade-no-target-creatures/) tells us that you needn't target yourself. While Mike Mearls is a lead designer of DnD 5e -- as nitsua60 reminds us -- he is not *the* authority of rules and rulings. [Mike Mearls concedes](https://twitter.com/mikemearls/status/748610510031978497) that there is no printed rule on his ruling. Thus, his ruling is simply that: A ruling. It carries as much weight as your own ruling as far as rules-as-written goes. Until there is an official ruling, this is up to your DM.
I would say no. PHB p. 204 > > Targeting Yourself > > > If a spell targets a creature of your choice, you can choose yourself, **unless the creature must be hostile** or specifically a creature other than you. If you are in the area of effect of a spell you cast, **you can target yourself**. > > > It seems to me that *Green-Flame Blade* is by definition used against hostile creatures. Further, a caster decides whether he is affected by his own spells when he is in the area of effect. So even if the flame was coming back at him, he would not take the damage if he chose not to.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
As of November 2020, [SCAG has received errata](https://media.wizards.com/2020/dnd/downloads/SCAG-Errata.pdf) to fix this inconsistency. The description of the *green-flame blade* spell now says that you "can" do it (emphasis mine): > > You brandish the weapon used in the spell’s casting and make > a melee attack with it against one creature within 5 feet of you. > On a hit, the target suffers the weapon attack’s normal effects, > and you ***can*** cause green fire to leap from the target to a different > creature of your choice that you can see within 5 feet of it. The > second creature takes fire damage equal to your spellcasting ability modifier. > > >
> > ...and green fire leaps from the target to a different creature of your choice that **you can see** within 5 feet of it. > > > Emphasis mine. Even if your DM rules that it will jump back and hit you against your will, just close your eyes at the right moment so you're unable to see a target; The spell subsequently fails.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
[Mike Mearls leaves the choice to the caster](https://www.sageadvice.eu/2016/07/04/green-flame-blade-no-target-creatures/). As always, every DM can rule differently. Please note that, while they could make their way into erratas, [tweets should not be treated as RAW](https://rpg.meta.stackexchange.com/questions/6250/are-tweets-an-official-rule-source).
It's up to the DM, there is no official ruling ---------------------------------------------- As noted in Sent\_'s answer, [Mike Mearls](http://www.sageadvice.eu/2015/11/09/green-flame-blade-no-target-creatures/) tells us that you needn't target yourself. While Mike Mearls is a lead designer of DnD 5e -- as nitsua60 reminds us -- he is not *the* authority of rules and rulings. [Mike Mearls concedes](https://twitter.com/mikemearls/status/748610510031978497) that there is no printed rule on his ruling. Thus, his ruling is simply that: A ruling. It carries as much weight as your own ruling as far as rules-as-written goes. Until there is an official ruling, this is up to your DM.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
> > ...and green fire leaps from the target to a different creature of your choice that **you can see** within 5 feet of it. > > > Emphasis mine. Even if your DM rules that it will jump back and hit you against your will, just close your eyes at the right moment so you're unable to see a target; The spell subsequently fails.
I would say no. PHB p. 204 > > Targeting Yourself > > > If a spell targets a creature of your choice, you can choose yourself, **unless the creature must be hostile** or specifically a creature other than you. If you are in the area of effect of a spell you cast, **you can target yourself**. > > > It seems to me that *Green-Flame Blade* is by definition used against hostile creatures. Further, a caster decides whether he is affected by his own spells when he is in the area of effect. So even if the flame was coming back at him, he would not take the damage if he chose not to.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
No, you don't have to cause the green fire to leap to another creature, as of the 2020 errata --------------------------------------------------------------------------------------------- The *green-flame blade* cantrip was updated when it was reprinted in *Tasha's Cauldron of Everything* (p. 107), and the version in the *Sword Coast Adventurer's Guide* (p. 143) received [errata](https://media.wizards.com/2020/dnd/downloads/SCAG-Errata.pdf) to match. The relevant line of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) spell description now reads: > > On a hit, the target suffers the weapon attack’s normal effects, and > **you can cause** green fire to leap from the target to a different > creature of your choice that you can see within 5 feet of it. > > > The use of the word "can" indicates that the green fire does not have to leap to a second creature. Thus, if the only other creatures within 5 feet of the initial target are the caster and their allies (for instance), the caster can choose not to have the green fire leap at all after the damage to the initial target. ### Even pre-errata, designer intent indicated that the caster didn't have to target another creature Pre-errata, it was not directly stated in the spell description whether you had to target yourself with the secondary damage if no other creature was in range, or if you could choose not to have the green fire leap to anybody at all. However, rules designer Jeremy Crawford unofficially answered this question in [a tweet from November 2015](https://twitter.com/JeremyECrawford/status/662433813956444160): > > *What does the leap effect of green-flame blade do if there are no hostile targets nearby? Does it jump to allies?* > > > **The intent is that you can choose no one. If you can't see, you can't choose anyway, and the flame halts** > > > While the wording might have suggested that the spell has to target another creature, Crawford clearly stated that that was not the intent; you could choose not to target anyone if there was no desired secondary target in range. The errata has brought this aspect of the spell in line with the stated intent. This makes sense to me. Given that if the attack hits, the caster could choose what creature the green fire leapt to, it makes sense that the caster could use the same control over targeting to prevent the green fire from jumping to any creature at all (e.g. by having it fizzle harmlessly against the ground, or extinguishing itself).
I would say no. PHB p. 204 > > Targeting Yourself > > > If a spell targets a creature of your choice, you can choose yourself, **unless the creature must be hostile** or specifically a creature other than you. If you are in the area of effect of a spell you cast, **you can target yourself**. > > > It seems to me that *Green-Flame Blade* is by definition used against hostile creatures. Further, a caster decides whether he is affected by his own spells when he is in the area of effect. So even if the flame was coming back at him, he would not take the damage if he chose not to.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
[Mike Mearls leaves the choice to the caster](https://www.sageadvice.eu/2016/07/04/green-flame-blade-no-target-creatures/). As always, every DM can rule differently. Please note that, while they could make their way into erratas, [tweets should not be treated as RAW](https://rpg.meta.stackexchange.com/questions/6250/are-tweets-an-official-rule-source).
I would say no. PHB p. 204 > > Targeting Yourself > > > If a spell targets a creature of your choice, you can choose yourself, **unless the creature must be hostile** or specifically a creature other than you. If you are in the area of effect of a spell you cast, **you can target yourself**. > > > It seems to me that *Green-Flame Blade* is by definition used against hostile creatures. Further, a caster decides whether he is affected by his own spells when he is in the area of effect. So even if the flame was coming back at him, he would not take the damage if he chose not to.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
As of November 2020, [SCAG has received errata](https://media.wizards.com/2020/dnd/downloads/SCAG-Errata.pdf) to fix this inconsistency. The description of the *green-flame blade* spell now says that you "can" do it (emphasis mine): > > You brandish the weapon used in the spell’s casting and make > a melee attack with it against one creature within 5 feet of you. > On a hit, the target suffers the weapon attack’s normal effects, > and you ***can*** cause green fire to leap from the target to a different > creature of your choice that you can see within 5 feet of it. The > second creature takes fire damage equal to your spellcasting ability modifier. > > >
It's up to the DM, there is no official ruling ---------------------------------------------- As noted in Sent\_'s answer, [Mike Mearls](http://www.sageadvice.eu/2015/11/09/green-flame-blade-no-target-creatures/) tells us that you needn't target yourself. While Mike Mearls is a lead designer of DnD 5e -- as nitsua60 reminds us -- he is not *the* authority of rules and rulings. [Mike Mearls concedes](https://twitter.com/mikemearls/status/748610510031978497) that there is no printed rule on his ruling. Thus, his ruling is simply that: A ruling. It carries as much weight as your own ruling as far as rules-as-written goes. Until there is an official ruling, this is up to your DM.
83,157
The description of the [*green-flame blade*](https://www.dndbeyond.com/spells/green-flame-blade) cantrip (SCAG, p. 143) reads: > > As part of the action used to cast this spell, you must make a melee attack with a weapon against one creature within the spell’s range, otherwise the spell fails. On a hit, the target suffers the attack’s normal effects, **and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it**. The second creature takes fire damage equal to your spellcasting modifier. > > > Since the caster fits the bolded criteria, does this mean he must target himself if no other creatures are available?
2016/06/25
[ "https://rpg.stackexchange.com/questions/83157", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29608/" ]
As of November 2020, [SCAG has received errata](https://media.wizards.com/2020/dnd/downloads/SCAG-Errata.pdf) to fix this inconsistency. The description of the *green-flame blade* spell now says that you "can" do it (emphasis mine): > > You brandish the weapon used in the spell’s casting and make > a melee attack with it against one creature within 5 feet of you. > On a hit, the target suffers the weapon attack’s normal effects, > and you ***can*** cause green fire to leap from the target to a different > creature of your choice that you can see within 5 feet of it. The > second creature takes fire damage equal to your spellcasting ability modifier. > > >
I would say no. PHB p. 204 > > Targeting Yourself > > > If a spell targets a creature of your choice, you can choose yourself, **unless the creature must be hostile** or specifically a creature other than you. If you are in the area of effect of a spell you cast, **you can target yourself**. > > > It seems to me that *Green-Flame Blade* is by definition used against hostile creatures. Further, a caster decides whether he is affected by his own spells when he is in the area of effect. So even if the flame was coming back at him, he would not take the damage if he chose not to.
28,952,218
I am building an application that uses a child process to make mathematical calculations: ``` var child = exec('get_hrv -M -R rr.txt', function(error, stdout) { if (error !== null) { console.log('exec error: ' + error); } else { res.send(stdout); } }); ``` The output (stdout) looks like this: ``` NN/RR = 0.992424 AVNN = 789.443 SDNN = 110.386 SDANN = 0 SDNNIDX = 110.386 rMSSD = 73.5775 pNN50 = 36.9231 TOT PWR = 12272.8 ULF PWR = 788.161 VLF PWR = 4603.59 LF PWR = 4221.97 HF PWR = 2659.05 LF/HF = 1.58777 ``` Everything is working as it should, however, **this output is a string and I need the values it contains assigned to separate integer variables**, e.g. like this: ``` var extractedVars = { NN/RR: 0.992424 AVNN: 789.443 SDNN: 110.386 SDANN: 0 SDNNIDX: 110.386 rMSSD: 73.5775 pNN50: 36.9231 TOT PWR: 12272.8 ULF PWR: 788.161 VLF PWR: 4603.59 LF PWR: 4221.97 HF PWR: 2659.05 LF/HF: 1.58777 } ``` How can this be done? Regex?
2015/03/09
[ "https://Stackoverflow.com/questions/28952218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2607404/" ]
I solved this issue by editing a method "ResideMenu.java" in ResideMenu library. I made a few changes in a method called "fitSystemWindows" before I made changes: ``` @Override protected boolean fitSystemWindows(Rect insets) { this.setPadding(viewActivity.getPaddingLeft() + insets.left, viewActivity.getPaddingTop() + insets.top, viewActivity.getPaddingRight() + insets.right, viewActivity.getPaddingBottom() + insets.bottom); insets.left = insets.top = insets.right = insets.bottom = 0; return true; } ``` after I made changes: ``` @Override protected boolean fitSystemWindows(Rect insets) { int bottomPadding=insets.bottom; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Resources resources = getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { bottomPadding += resources.getDimensionPixelSize(resourceId); } } this.setPadding(viewActivity.getPaddingLeft() + insets.left, viewActivity.getPaddingTop() + insets.top, viewActivity.getPaddingRight() + insets.right, viewActivity.getPaddingBottom() + bottomPadding); insets.left = insets.top = insets.right = insets.bottom = 0; return true; } ``` This change solve my issue, part of the bottom screen hidden under native navigation bar. I hope this solution be helpful anyone who encounter this kind of issue. Cheers.
I had this same issue and I solved this by editing a method in ResideMenu library. Inside the library, you can acess a java class named "ResideMenu.java". Edit the method as like this. ``` private void setScaleDirection(int direction){ int screenWidth = getScreenWidth(); float pivotX; float pivotY = getScreenHeight() * 0.5f; if (direction == DIRECTION_LEFT){ scrollViewMenu = scrollViewLeftMenu; pivotX = screenWidth * 2.2f; }else{ scrollViewMenu = scrollViewRightMenu; pivotX = screenWidth * -0.5f; } ViewHelper.setPivotX(viewActivity, pivotX); ViewHelper.setPivotY(viewActivity, pivotY); ViewHelper.setPivotX(imageViewShadow, pivotX); ViewHelper.setPivotY(imageViewShadow, pivotY); scaleDirection = direction; } ``` Here i made changes to > > pivot x = (screenWidth \* 2.2f) instead of (screenWidth \* 0.5f). > > > try to manage the float value, it will solve your issue. Thank you, Happy Coding
28,952,218
I am building an application that uses a child process to make mathematical calculations: ``` var child = exec('get_hrv -M -R rr.txt', function(error, stdout) { if (error !== null) { console.log('exec error: ' + error); } else { res.send(stdout); } }); ``` The output (stdout) looks like this: ``` NN/RR = 0.992424 AVNN = 789.443 SDNN = 110.386 SDANN = 0 SDNNIDX = 110.386 rMSSD = 73.5775 pNN50 = 36.9231 TOT PWR = 12272.8 ULF PWR = 788.161 VLF PWR = 4603.59 LF PWR = 4221.97 HF PWR = 2659.05 LF/HF = 1.58777 ``` Everything is working as it should, however, **this output is a string and I need the values it contains assigned to separate integer variables**, e.g. like this: ``` var extractedVars = { NN/RR: 0.992424 AVNN: 789.443 SDNN: 110.386 SDANN: 0 SDNNIDX: 110.386 rMSSD: 73.5775 pNN50: 36.9231 TOT PWR: 12272.8 ULF PWR: 788.161 VLF PWR: 4603.59 LF PWR: 4221.97 HF PWR: 2659.05 LF/HF: 1.58777 } ``` How can this be done? Regex?
2015/03/09
[ "https://Stackoverflow.com/questions/28952218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2607404/" ]
Found Most stable solution ``` public Point getNavigationBarSize(Context context) { Point appUsableSize = getAppUsableScreenSize(context); Point realScreenSize = getRealScreenSize(context); // navigation bar on the right if (appUsableSize.x < realScreenSize.x) { return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y); } // navigation bar at the bottom if (appUsableSize.y < realScreenSize.y) { return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y); } // navigation bar is not present return new Point(); } public Point getAppUsableScreenSize(Context context) { WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size; } public Point getRealScreenSize(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= 17) { display.getRealSize(size); } else if (Build.VERSION.SDK_INT >= 14) { try { size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display); size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display); } catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {} } return size; } ``` And set padding of main layout ``` setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getNavigationBarSize(getContext()).y); ``` Edit : Keep this code inside attachToActivity() method of ResideMenu.java ``` if (getNavigationBarSize(getContext()).x > 0 && getNavigationBarSize(getContext()).y > 0) { this.postDelayed(new Runnable() { @Override public void run() { setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getNavigationBarSize(getContext()).y); } }, 100); } ```
I had this same issue and I solved this by editing a method in ResideMenu library. Inside the library, you can acess a java class named "ResideMenu.java". Edit the method as like this. ``` private void setScaleDirection(int direction){ int screenWidth = getScreenWidth(); float pivotX; float pivotY = getScreenHeight() * 0.5f; if (direction == DIRECTION_LEFT){ scrollViewMenu = scrollViewLeftMenu; pivotX = screenWidth * 2.2f; }else{ scrollViewMenu = scrollViewRightMenu; pivotX = screenWidth * -0.5f; } ViewHelper.setPivotX(viewActivity, pivotX); ViewHelper.setPivotY(viewActivity, pivotY); ViewHelper.setPivotX(imageViewShadow, pivotX); ViewHelper.setPivotY(imageViewShadow, pivotY); scaleDirection = direction; } ``` Here i made changes to > > pivot x = (screenWidth \* 2.2f) instead of (screenWidth \* 0.5f). > > > try to manage the float value, it will solve your issue. Thank you, Happy Coding
28,952,218
I am building an application that uses a child process to make mathematical calculations: ``` var child = exec('get_hrv -M -R rr.txt', function(error, stdout) { if (error !== null) { console.log('exec error: ' + error); } else { res.send(stdout); } }); ``` The output (stdout) looks like this: ``` NN/RR = 0.992424 AVNN = 789.443 SDNN = 110.386 SDANN = 0 SDNNIDX = 110.386 rMSSD = 73.5775 pNN50 = 36.9231 TOT PWR = 12272.8 ULF PWR = 788.161 VLF PWR = 4603.59 LF PWR = 4221.97 HF PWR = 2659.05 LF/HF = 1.58777 ``` Everything is working as it should, however, **this output is a string and I need the values it contains assigned to separate integer variables**, e.g. like this: ``` var extractedVars = { NN/RR: 0.992424 AVNN: 789.443 SDNN: 110.386 SDANN: 0 SDNNIDX: 110.386 rMSSD: 73.5775 pNN50: 36.9231 TOT PWR: 12272.8 ULF PWR: 788.161 VLF PWR: 4603.59 LF PWR: 4221.97 HF PWR: 2659.05 LF/HF: 1.58777 } ``` How can this be done? Regex?
2015/03/09
[ "https://Stackoverflow.com/questions/28952218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2607404/" ]
I solved this issue by editing a method "ResideMenu.java" in ResideMenu library. I made a few changes in a method called "fitSystemWindows" before I made changes: ``` @Override protected boolean fitSystemWindows(Rect insets) { this.setPadding(viewActivity.getPaddingLeft() + insets.left, viewActivity.getPaddingTop() + insets.top, viewActivity.getPaddingRight() + insets.right, viewActivity.getPaddingBottom() + insets.bottom); insets.left = insets.top = insets.right = insets.bottom = 0; return true; } ``` after I made changes: ``` @Override protected boolean fitSystemWindows(Rect insets) { int bottomPadding=insets.bottom; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Resources resources = getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { bottomPadding += resources.getDimensionPixelSize(resourceId); } } this.setPadding(viewActivity.getPaddingLeft() + insets.left, viewActivity.getPaddingTop() + insets.top, viewActivity.getPaddingRight() + insets.right, viewActivity.getPaddingBottom() + bottomPadding); insets.left = insets.top = insets.right = insets.bottom = 0; return true; } ``` This change solve my issue, part of the bottom screen hidden under native navigation bar. I hope this solution be helpful anyone who encounter this kind of issue. Cheers.
Found Most stable solution ``` public Point getNavigationBarSize(Context context) { Point appUsableSize = getAppUsableScreenSize(context); Point realScreenSize = getRealScreenSize(context); // navigation bar on the right if (appUsableSize.x < realScreenSize.x) { return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y); } // navigation bar at the bottom if (appUsableSize.y < realScreenSize.y) { return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y); } // navigation bar is not present return new Point(); } public Point getAppUsableScreenSize(Context context) { WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size; } public Point getRealScreenSize(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= 17) { display.getRealSize(size); } else if (Build.VERSION.SDK_INT >= 14) { try { size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display); size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display); } catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {} } return size; } ``` And set padding of main layout ``` setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getNavigationBarSize(getContext()).y); ``` Edit : Keep this code inside attachToActivity() method of ResideMenu.java ``` if (getNavigationBarSize(getContext()).x > 0 && getNavigationBarSize(getContext()).y > 0) { this.postDelayed(new Runnable() { @Override public void run() { setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getNavigationBarSize(getContext()).y); } }, 100); } ```
53,715,077
I am working on a asp page and I would like to override "meta http-equiv="X-UA-Compatible" content="IE=8"" with "meta http-equiv="X-UA-Compatible" content="IE=10"" in one of the pages using JavaScript. Is it possible? I have tried the following with no success. ``` window.onload = function(e){ $('meta[http-equiv="X-UA-Compatible"]').remove(); $('head').append('<meta http-equiv="X-UA-Compatible" content="IE=10">') } ```
2018/12/10
[ "https://Stackoverflow.com/questions/53715077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9808783/" ]
Keep track of the enum object, not its label ============================================ Keep a reference to the [enum object](https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html) selected by the user, rather than a reference to the string of the enum object’s display name. ``` // Display combobox // User picks an item. // Your event-handling code reacts by remembering which *object* not *string* was select. Ford fordSelectedByUser = … ; // You pull reference from the data model backing your widget. ``` I do not know what combobox widget you are using. In the [Vaadin](https://en.wikipedia.org/wiki/Vaadin) framework, for example, a [combobox](https://vaadin.com/docs/v8/framework/components/components-combobox.html) is backed by a data model of objects. Perhaps you are using Swing? I no longer recall the details of how Swing works, but glancing at [this documentation](https://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html#renderer), it looks like you can back the combobox with objects and use a custom renderer. `JComboBox< Ford >`, not `JComboBox< String >` ---------------------------------------------- **Make a `JComboBox` that holds `Ford` objects**, not `String` objects. You can get an array of all your enum values by calling `values()`. That method is a strange one, not listed on the JavaDoc of [`Enum`](https://docs.oracle.com/javase/10/docs/api/java/lang/Enum.html) though mentioned in [`Enum.valueOf`](https://docs.oracle.com/javase/10/docs/api/java/lang/Enum.html#valueOf(java.lang.Class,java.lang.String)) method doc – it is an “implicit” method, but I don’t think we care about the gory technical details there. ``` Ford[] fords = Ford.values() ; // Get array of all the objects defined by this enum. JComboBox< Ford > fordsComboBox = new JComboBox( fords ); ``` Track the selected `Ford` object selected, not its display name. ``` public void actionPerformed( ActionEvent e ) { JComboBox cb = ( JComboBox )e.getSource() ; Ford selectedFord = ( Ford )cb.getSelectedItem() ; // Is casting still needed, or is Swing Generics-aware? Maybe: Ford selectedFord = ( JComboBox< Ford > )e.getSource().getSelectedItem() ; updateLabel( selectedFord.getDisplayName() ) ; } ``` Your custom renderer calls the enum `Ford` object’s `getDisplayName` method that you will write. ``` package com.basilbourque.example; public enum Ford { FOCUS( "Ford" , 26 ), MONDEO( "Mondeo" , 6 ), FIESTA( "Fiesta" , 13 ); private final String displayName; private final int id; // Constructor Ford ( String name , int carId ) { this.displayName = name; this.id = carId; } // Getters public String getDisplayName ( ) { return this.displayName; } public int getId ( ) { return this.id; } // `Object` methods @Override public String toString ( ) { return "Ford{ " + "id=" + id + ", displayName='" + displayName + '\'' + " }"; } } ``` Tips: * Throughout your code base, use `Ford` objects, not a mere integer of its ID number nor a mere string of its display name. This makes your code more self-documenting, provides [type-safety](https://en.wikipedia.org/wiki/Type_safety), and ensures valid values. * To collect a subset of `Enum` objects, use [`EnumSet`](https://docs.oracle.com/javase/10/docs/api/java/util/EnumSet.html) or [`EnumMap`](https://docs.oracle.com/javase/10/docs/api/java/util/EnumMap.html) classes. These are high-performance low-memory implementations of the `Set` and `Map` interfaces. * Remember an `Enum` is only appropriate if the domain, the set of all possible values, is known at compile-time. Adding or eliminating any of the cars means editing your `Ford` enum class and re-compiling. + In contrast, if your app can add more `Ford` cars during runtime, or eliminate any, then you cannot use an `Enum`. You would make `Ford` a regular class rather than a subclass of `Enum`, and would instantiate them as we do any [POJO](https://en.wikipedia.org/wiki/Plain_old_Java_object) and [collect them](https://en.wikipedia.org/wiki/Java_collections_framework).
You don't need to iterate on all the values because you can easily get the enum value in O(1) with [Enum.valueOf(String name)](https://docs.oracle.com/javase/10/docs/api/java/lang/Enum.html#valueOf(java.lang.Class,java.lang.String)). In your case, `Ford.valueOf(comboBox1.getSelectedItem().toString()).getCarId()` should work.
53,715,077
I am working on a asp page and I would like to override "meta http-equiv="X-UA-Compatible" content="IE=8"" with "meta http-equiv="X-UA-Compatible" content="IE=10"" in one of the pages using JavaScript. Is it possible? I have tried the following with no success. ``` window.onload = function(e){ $('meta[http-equiv="X-UA-Compatible"]').remove(); $('head').append('<meta http-equiv="X-UA-Compatible" content="IE=10">') } ```
2018/12/10
[ "https://Stackoverflow.com/questions/53715077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9808783/" ]
Keep track of the enum object, not its label ============================================ Keep a reference to the [enum object](https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html) selected by the user, rather than a reference to the string of the enum object’s display name. ``` // Display combobox // User picks an item. // Your event-handling code reacts by remembering which *object* not *string* was select. Ford fordSelectedByUser = … ; // You pull reference from the data model backing your widget. ``` I do not know what combobox widget you are using. In the [Vaadin](https://en.wikipedia.org/wiki/Vaadin) framework, for example, a [combobox](https://vaadin.com/docs/v8/framework/components/components-combobox.html) is backed by a data model of objects. Perhaps you are using Swing? I no longer recall the details of how Swing works, but glancing at [this documentation](https://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html#renderer), it looks like you can back the combobox with objects and use a custom renderer. `JComboBox< Ford >`, not `JComboBox< String >` ---------------------------------------------- **Make a `JComboBox` that holds `Ford` objects**, not `String` objects. You can get an array of all your enum values by calling `values()`. That method is a strange one, not listed on the JavaDoc of [`Enum`](https://docs.oracle.com/javase/10/docs/api/java/lang/Enum.html) though mentioned in [`Enum.valueOf`](https://docs.oracle.com/javase/10/docs/api/java/lang/Enum.html#valueOf(java.lang.Class,java.lang.String)) method doc – it is an “implicit” method, but I don’t think we care about the gory technical details there. ``` Ford[] fords = Ford.values() ; // Get array of all the objects defined by this enum. JComboBox< Ford > fordsComboBox = new JComboBox( fords ); ``` Track the selected `Ford` object selected, not its display name. ``` public void actionPerformed( ActionEvent e ) { JComboBox cb = ( JComboBox )e.getSource() ; Ford selectedFord = ( Ford )cb.getSelectedItem() ; // Is casting still needed, or is Swing Generics-aware? Maybe: Ford selectedFord = ( JComboBox< Ford > )e.getSource().getSelectedItem() ; updateLabel( selectedFord.getDisplayName() ) ; } ``` Your custom renderer calls the enum `Ford` object’s `getDisplayName` method that you will write. ``` package com.basilbourque.example; public enum Ford { FOCUS( "Ford" , 26 ), MONDEO( "Mondeo" , 6 ), FIESTA( "Fiesta" , 13 ); private final String displayName; private final int id; // Constructor Ford ( String name , int carId ) { this.displayName = name; this.id = carId; } // Getters public String getDisplayName ( ) { return this.displayName; } public int getId ( ) { return this.id; } // `Object` methods @Override public String toString ( ) { return "Ford{ " + "id=" + id + ", displayName='" + displayName + '\'' + " }"; } } ``` Tips: * Throughout your code base, use `Ford` objects, not a mere integer of its ID number nor a mere string of its display name. This makes your code more self-documenting, provides [type-safety](https://en.wikipedia.org/wiki/Type_safety), and ensures valid values. * To collect a subset of `Enum` objects, use [`EnumSet`](https://docs.oracle.com/javase/10/docs/api/java/util/EnumSet.html) or [`EnumMap`](https://docs.oracle.com/javase/10/docs/api/java/util/EnumMap.html) classes. These are high-performance low-memory implementations of the `Set` and `Map` interfaces. * Remember an `Enum` is only appropriate if the domain, the set of all possible values, is known at compile-time. Adding or eliminating any of the cars means editing your `Ford` enum class and re-compiling. + In contrast, if your app can add more `Ford` cars during runtime, or eliminate any, then you cannot use an `Enum`. You would make `Ford` a regular class rather than a subclass of `Enum`, and would instantiate them as we do any [POJO](https://en.wikipedia.org/wiki/Plain_old_Java_object) and [collect them](https://en.wikipedia.org/wiki/Java_collections_framework).
You are using it correctly enough already, just some minor changes ``` public enum Ford { FOCUS("Ford", 26), MONDEO("Mondeo", 6), FIESTA("Fiesta", 13); private final String name; //Good private final int carId; //Good /** This is a constructor for the enum variable */ Ford(String name, int carId) { this.name = name; //stores the name variable for the enum this.carId = carId; } public int getCarId() { return this.carId; //gets the carID from the enum variable } public String getCarName() { return this.name; //gets the car name from the enum variable } } ``` To use this enum class, and its values here is an example ``` public static void main(String[] args) { /** This is how you reference an enum value directly */ System.out.println("Type: " + Ford.FOCUS + ", Name: " + Ford.FOCUS.getCarName() + ", ID: " + Ford.FOCUS.getCarId()); /** This is how you can cycle through all of the values in this enum class */ for (final Ford f : Ford.values()) System.out.println("Type: " + f + ", Name: " + f.getCarName() + ", ID: " + f.getCarId()); } ``` Also, note that in java, the keyword "this" is used to reference a global variable that is a member of the class/enum that "this" is being used in. It means "this class's member"
70,263
Does Blizzard allow one user to play multiple accounts simultaneously? I know it is hard to verify if one or two players are currently playing, but would Blizzard ban my accounts if they knew I am multiboxing?
2012/05/27
[ "https://gaming.stackexchange.com/questions/70263", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/10933/" ]
If you're looking for a clear-cut yes-or-no answer from Blizzard, unfortunately you won't be able to get it at the present time; every recent inquiry about the subject on the official forums has been met with a generic "read the ToS" response. There *was*, however, a post earlier this month by Blizzard representative Omrakos (in a forum thread that has since been deleted) that stated the following: > > Multiple copies from the same number of multiple computers with the same number of multiple accounts will be fine. You can't, to my knowledge, run more than 1 copy per pc simultaneously though. - Omrakos > > > Therefore, I think the best stance to take is such: there's no guarantee that multiboxing won't get you in trouble, but as long as you're using separate computers and not running multiple copies on a single machine, you're probably somewhat safe. That's still not a guarantee, however, and Blizzard could change their minds at any time.
From a World of Warcraft and Starcraft 2 perspective, Blizzard has long allowed multiple accounts to play simultaneously. The only concern is that you are careful if you are using software to play multiple characters at once simultaneously. Anything that emulates botting (keyboard emulation, packet duplicating, etc) will most likely result in bad times.
21,117,048
I have made this database. It looks like it is working fine, except that I was told that my table "event" is not in third normal form. I do not see why it is not in the third normal form. I thought it is maybe because of the city and the zip code, which should be always the same, but large cities can have multiple zip codes and I do not see the point in creating another table just for the cities and their zip codes, related to the event table. Also sorry if some of the names or attributes are named incorrectly by using some of the names reserved by the system. I had to translate the code to english, because I wrote it in my home language :). Thanks for your help. ``` Create table [article] ( [id_article] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [id_category] Integer NOT NULL, [title] Nvarchar(50) NOT NULL, [content] Text NOT NULL, [date] Datetime NOT NULL, Primary Key ([id_article]) ) go Create table [author] ( [id_author] Integer Identity(1,1) NOT NULL, [name] Nvarchar(25) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), [passwd] Nvarchar(50) NOT NULL, [acc_number] Integer NOT NULL, UNIQUE ([acc_number]), Primary Key ([id_author]) ) go Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [date] Datetime NOT NULL, UNIQUE ([date]), [city] Nvarchar(50) NOT NULL, [street] Nvarchar(50) NOT NULL, [zip] Integer NOT NULL, [house_number] Integer NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [user] ( [id_user] Integer Identity(1,1) NOT NULL, [name] Nvarchar(15) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [passwd] Nvarchar(50) NOT NULL, [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), Primary Key ([id_user]) ) go Create table [commentary] ( [id_commentary] Integer Identity(1,1) NOT NULL, [content] Text NOT NULL, [id_article] Integer NOT NULL, [id_author] Integer NULL, [id_user] Integer NULL, Primary Key ([id_commentary]) ) go Create table [category] ( [id_category] Integer Identity(1,1) NOT NULL, [name] Nvarchar(30) NOT NULL, Primary Key ([id_category]) ) go Create table [registration] ( [id_user] Integer NOT NULL, [id_event] Integer NOT NULL, Primary Key ([id_user],[id_event]) ) go Alter table [commentary] add foreign key([id_article]) references [article] ([id_article]) on update no action on delete no action go Alter table [article] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [event] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [commentary] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [registration] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go Alter table [commentary] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [registration] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [article] add foreign key([id_category]) references [category] ([id_category]) on update no action on delete no action go ``` EDIT: Do you think it could work like this? I made another table called location with all the address infos which were previously in event table and made the id\_event PFK. ``` Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [datr] Datetime NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [location] ( [city] Char(1) NOT NULL, [id_event] Integer NOT NULL, [street] Char(1) NOT NULL, [house_number] Char(1) NOT NULL, [zip] Char(1) NOT NULL, Primary Key ([id_event]) ) go Alter table [event] add foreign key([id_auhtor]) references [author] ([id_author]) on update no action on delete no action go Alter table [location] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go ```
2014/01/14
[ "https://Stackoverflow.com/questions/21117048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3137926/" ]
If you want to keep using that design, you're gonna run into all sorts of problems. * What if the translated word doesn't have the letter shortcut you applied to your other language? * If a user gets used to a set of shortcuts and changes the language, are all the shortcuts he is used to going to change? For example, Ctrl+S is a widely used shortcut for Save, even if some languages don't have a S in their translation of 'Save'. Change that letter to W, which is the common shortcut for Quit, and you're in for an unpleasant user experience. I suggest you change your markup to ``` (R) Run (J) Jump (O) Jog ``` That way you only need to translate the word part, and leave the shortcut as it is.
It seems that you would have to use a little bit of RegEx (regular expressions) and .split to be able to grab that letter, store it in a variable and then style it with jquery's .css method.
21,117,048
I have made this database. It looks like it is working fine, except that I was told that my table "event" is not in third normal form. I do not see why it is not in the third normal form. I thought it is maybe because of the city and the zip code, which should be always the same, but large cities can have multiple zip codes and I do not see the point in creating another table just for the cities and their zip codes, related to the event table. Also sorry if some of the names or attributes are named incorrectly by using some of the names reserved by the system. I had to translate the code to english, because I wrote it in my home language :). Thanks for your help. ``` Create table [article] ( [id_article] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [id_category] Integer NOT NULL, [title] Nvarchar(50) NOT NULL, [content] Text NOT NULL, [date] Datetime NOT NULL, Primary Key ([id_article]) ) go Create table [author] ( [id_author] Integer Identity(1,1) NOT NULL, [name] Nvarchar(25) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), [passwd] Nvarchar(50) NOT NULL, [acc_number] Integer NOT NULL, UNIQUE ([acc_number]), Primary Key ([id_author]) ) go Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [date] Datetime NOT NULL, UNIQUE ([date]), [city] Nvarchar(50) NOT NULL, [street] Nvarchar(50) NOT NULL, [zip] Integer NOT NULL, [house_number] Integer NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [user] ( [id_user] Integer Identity(1,1) NOT NULL, [name] Nvarchar(15) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [passwd] Nvarchar(50) NOT NULL, [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), Primary Key ([id_user]) ) go Create table [commentary] ( [id_commentary] Integer Identity(1,1) NOT NULL, [content] Text NOT NULL, [id_article] Integer NOT NULL, [id_author] Integer NULL, [id_user] Integer NULL, Primary Key ([id_commentary]) ) go Create table [category] ( [id_category] Integer Identity(1,1) NOT NULL, [name] Nvarchar(30) NOT NULL, Primary Key ([id_category]) ) go Create table [registration] ( [id_user] Integer NOT NULL, [id_event] Integer NOT NULL, Primary Key ([id_user],[id_event]) ) go Alter table [commentary] add foreign key([id_article]) references [article] ([id_article]) on update no action on delete no action go Alter table [article] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [event] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [commentary] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [registration] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go Alter table [commentary] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [registration] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [article] add foreign key([id_category]) references [category] ([id_category]) on update no action on delete no action go ``` EDIT: Do you think it could work like this? I made another table called location with all the address infos which were previously in event table and made the id\_event PFK. ``` Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [datr] Datetime NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [location] ( [city] Char(1) NOT NULL, [id_event] Integer NOT NULL, [street] Char(1) NOT NULL, [house_number] Char(1) NOT NULL, [zip] Char(1) NOT NULL, Primary Key ([id_event]) ) go Alter table [event] add foreign key([id_auhtor]) references [author] ([id_author]) on update no action on delete no action go Alter table [location] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go ```
2014/01/14
[ "https://Stackoverflow.com/questions/21117048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3137926/" ]
What letter is "active" is language-dependent, so this info has to be stored in each language specific config file (translation table file): ``` English: RUN: "Run" RUN_ACTION: "R" French: RUN: "Courir" RUN_ACTION: "C" ``` Then use this information (and meta-infromation) to generate your HTML: ``` function buildAction(label, letter) { return label.replace(letter, '<u id="action-' + letter + '">' + letter + '</u>'); } var html = '<p>menu: ' + buildAction(RUN, RUN_ACTION) + ', ...</p>'; document.write(html); ``` Then you can `$('#action-' + RUN_ACTION).css` and `$('#action-' + RUN_ACTION).click`. With this you only need to switch between translation table files. I'd generate the HTML server-side though.
It seems that you would have to use a little bit of RegEx (regular expressions) and .split to be able to grab that letter, store it in a variable and then style it with jquery's .css method.
21,117,048
I have made this database. It looks like it is working fine, except that I was told that my table "event" is not in third normal form. I do not see why it is not in the third normal form. I thought it is maybe because of the city and the zip code, which should be always the same, but large cities can have multiple zip codes and I do not see the point in creating another table just for the cities and their zip codes, related to the event table. Also sorry if some of the names or attributes are named incorrectly by using some of the names reserved by the system. I had to translate the code to english, because I wrote it in my home language :). Thanks for your help. ``` Create table [article] ( [id_article] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [id_category] Integer NOT NULL, [title] Nvarchar(50) NOT NULL, [content] Text NOT NULL, [date] Datetime NOT NULL, Primary Key ([id_article]) ) go Create table [author] ( [id_author] Integer Identity(1,1) NOT NULL, [name] Nvarchar(25) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), [passwd] Nvarchar(50) NOT NULL, [acc_number] Integer NOT NULL, UNIQUE ([acc_number]), Primary Key ([id_author]) ) go Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [date] Datetime NOT NULL, UNIQUE ([date]), [city] Nvarchar(50) NOT NULL, [street] Nvarchar(50) NOT NULL, [zip] Integer NOT NULL, [house_number] Integer NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [user] ( [id_user] Integer Identity(1,1) NOT NULL, [name] Nvarchar(15) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [passwd] Nvarchar(50) NOT NULL, [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), Primary Key ([id_user]) ) go Create table [commentary] ( [id_commentary] Integer Identity(1,1) NOT NULL, [content] Text NOT NULL, [id_article] Integer NOT NULL, [id_author] Integer NULL, [id_user] Integer NULL, Primary Key ([id_commentary]) ) go Create table [category] ( [id_category] Integer Identity(1,1) NOT NULL, [name] Nvarchar(30) NOT NULL, Primary Key ([id_category]) ) go Create table [registration] ( [id_user] Integer NOT NULL, [id_event] Integer NOT NULL, Primary Key ([id_user],[id_event]) ) go Alter table [commentary] add foreign key([id_article]) references [article] ([id_article]) on update no action on delete no action go Alter table [article] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [event] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [commentary] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [registration] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go Alter table [commentary] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [registration] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [article] add foreign key([id_category]) references [category] ([id_category]) on update no action on delete no action go ``` EDIT: Do you think it could work like this? I made another table called location with all the address infos which were previously in event table and made the id\_event PFK. ``` Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [datr] Datetime NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [location] ( [city] Char(1) NOT NULL, [id_event] Integer NOT NULL, [street] Char(1) NOT NULL, [house_number] Char(1) NOT NULL, [zip] Char(1) NOT NULL, Primary Key ([id_event]) ) go Alter table [event] add foreign key([id_auhtor]) references [author] ([id_author]) on update no action on delete no action go Alter table [location] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go ```
2014/01/14
[ "https://Stackoverflow.com/questions/21117048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3137926/" ]
If you want to keep using that design, you're gonna run into all sorts of problems. * What if the translated word doesn't have the letter shortcut you applied to your other language? * If a user gets used to a set of shortcuts and changes the language, are all the shortcuts he is used to going to change? For example, Ctrl+S is a widely used shortcut for Save, even if some languages don't have a S in their translation of 'Save'. Change that letter to W, which is the common shortcut for Quit, and you're in for an unpleasant user experience. I suggest you change your markup to ``` (R) Run (J) Jump (O) Jog ``` That way you only need to translate the word part, and leave the shortcut as it is.
It is an admirable goal to separate data from presentation. I don't think pure CSS will get you all the way there, without also having some supporting HTML markup. You actually need the hotkey information in two places: 1. In the UI markup 2. In the code that processes key presses I would suggest that you store the information about the hotkey in a format similar to: ``` // Word Hotkey Offset Function Language // Sichern S 0 Save DE // Springe p 1 Jump DE ``` (example above uses German). Use that data to drive 1. Rendering of the UI (e.g. when rendering to HTML markup, wrap the character position designated by Offset with a tag of your choice that matches your CSS rules. 2. Have the code that captures key clicks and executes functionality use the same data.
21,117,048
I have made this database. It looks like it is working fine, except that I was told that my table "event" is not in third normal form. I do not see why it is not in the third normal form. I thought it is maybe because of the city and the zip code, which should be always the same, but large cities can have multiple zip codes and I do not see the point in creating another table just for the cities and their zip codes, related to the event table. Also sorry if some of the names or attributes are named incorrectly by using some of the names reserved by the system. I had to translate the code to english, because I wrote it in my home language :). Thanks for your help. ``` Create table [article] ( [id_article] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [id_category] Integer NOT NULL, [title] Nvarchar(50) NOT NULL, [content] Text NOT NULL, [date] Datetime NOT NULL, Primary Key ([id_article]) ) go Create table [author] ( [id_author] Integer Identity(1,1) NOT NULL, [name] Nvarchar(25) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), [passwd] Nvarchar(50) NOT NULL, [acc_number] Integer NOT NULL, UNIQUE ([acc_number]), Primary Key ([id_author]) ) go Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [date] Datetime NOT NULL, UNIQUE ([date]), [city] Nvarchar(50) NOT NULL, [street] Nvarchar(50) NOT NULL, [zip] Integer NOT NULL, [house_number] Integer NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [user] ( [id_user] Integer Identity(1,1) NOT NULL, [name] Nvarchar(15) NOT NULL, [lastname] Nvarchar(25) NOT NULL, [email] Nvarchar(50) NOT NULL, UNIQUE ([email]), [phone] Integer NOT NULL, UNIQUE ([phone]), [passwd] Nvarchar(50) NOT NULL, [nick] Nvarchar(20) NOT NULL, UNIQUE ([nick]), Primary Key ([id_user]) ) go Create table [commentary] ( [id_commentary] Integer Identity(1,1) NOT NULL, [content] Text NOT NULL, [id_article] Integer NOT NULL, [id_author] Integer NULL, [id_user] Integer NULL, Primary Key ([id_commentary]) ) go Create table [category] ( [id_category] Integer Identity(1,1) NOT NULL, [name] Nvarchar(30) NOT NULL, Primary Key ([id_category]) ) go Create table [registration] ( [id_user] Integer NOT NULL, [id_event] Integer NOT NULL, Primary Key ([id_user],[id_event]) ) go Alter table [commentary] add foreign key([id_article]) references [article] ([id_article]) on update no action on delete no action go Alter table [article] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [event] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [commentary] add foreign key([id_author]) references [author] ([id_author]) on update no action on delete no action go Alter table [registration] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go Alter table [commentary] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [registration] add foreign key([id_user]) references [user] ([id_user]) on update no action on delete no action go Alter table [article] add foreign key([id_category]) references [category] ([id_category]) on update no action on delete no action go ``` EDIT: Do you think it could work like this? I made another table called location with all the address infos which were previously in event table and made the id\_event PFK. ``` Create table [event] ( [id_event] Integer Identity(1,1) NOT NULL, [id_author] Integer NOT NULL, [name] Nvarchar(50) NOT NULL, [datr] Datetime NOT NULL, [number_registered] Integer Default 0 NOT NULL Constraint [number_registered] Check (number_registered <= 20), Primary Key ([id_event]) ) go Create table [location] ( [city] Char(1) NOT NULL, [id_event] Integer NOT NULL, [street] Char(1) NOT NULL, [house_number] Char(1) NOT NULL, [zip] Char(1) NOT NULL, Primary Key ([id_event]) ) go Alter table [event] add foreign key([id_auhtor]) references [author] ([id_author]) on update no action on delete no action go Alter table [location] add foreign key([id_event]) references [event] ([id_event]) on update no action on delete no action go ```
2014/01/14
[ "https://Stackoverflow.com/questions/21117048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3137926/" ]
What letter is "active" is language-dependent, so this info has to be stored in each language specific config file (translation table file): ``` English: RUN: "Run" RUN_ACTION: "R" French: RUN: "Courir" RUN_ACTION: "C" ``` Then use this information (and meta-infromation) to generate your HTML: ``` function buildAction(label, letter) { return label.replace(letter, '<u id="action-' + letter + '">' + letter + '</u>'); } var html = '<p>menu: ' + buildAction(RUN, RUN_ACTION) + ', ...</p>'; document.write(html); ``` Then you can `$('#action-' + RUN_ACTION).css` and `$('#action-' + RUN_ACTION).click`. With this you only need to switch between translation table files. I'd generate the HTML server-side though.
It is an admirable goal to separate data from presentation. I don't think pure CSS will get you all the way there, without also having some supporting HTML markup. You actually need the hotkey information in two places: 1. In the UI markup 2. In the code that processes key presses I would suggest that you store the information about the hotkey in a format similar to: ``` // Word Hotkey Offset Function Language // Sichern S 0 Save DE // Springe p 1 Jump DE ``` (example above uses German). Use that data to drive 1. Rendering of the UI (e.g. when rendering to HTML markup, wrap the character position designated by Offset with a tag of your choice that matches your CSS rules. 2. Have the code that captures key clicks and executes functionality use the same data.
339,071
I have Windows 7 Professional. I would like to see the users that have administrative access on my PC. But I do not have administrative access to my PC.
2011/09/23
[ "https://superuser.com/questions/339071", "https://superuser.com", "https://superuser.com/users/67858/" ]
Open the command prompt and type: > > net user > > > It will display a list of all the users who are present. To see if a user is a administrator, type > > net user [username] > > > and look at the Local Group Memberships.
<http://www.sevenforums.com/tutorials/7539-local-users-groups-manager-open.html> mmc compmgmt.msc Who is member of Administrators groups that users has administrative access.
339,071
I have Windows 7 Professional. I would like to see the users that have administrative access on my PC. But I do not have administrative access to my PC.
2011/09/23
[ "https://superuser.com/questions/339071", "https://superuser.com", "https://superuser.com/users/67858/" ]
To get the list of local administrators from the command line: ``` net localgroup administrators ``` You don't need to have administrator rights to execute this command.
<http://www.sevenforums.com/tutorials/7539-local-users-groups-manager-open.html> mmc compmgmt.msc Who is member of Administrators groups that users has administrative access.
339,071
I have Windows 7 Professional. I would like to see the users that have administrative access on my PC. But I do not have administrative access to my PC.
2011/09/23
[ "https://superuser.com/questions/339071", "https://superuser.com", "https://superuser.com/users/67858/" ]
Open the command prompt and type: > > net user > > > It will display a list of all the users who are present. To see if a user is a administrator, type > > net user [username] > > > and look at the Local Group Memberships.
To get the list of local administrators from the command line: ``` net localgroup administrators ``` You don't need to have administrator rights to execute this command.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
`$.load()` **works** in IE8. My guess is you have a previous JS error, triggered only in IE8-, which prevents it from functioning properly, or being called altogether.
The problem is some functions are supported in one and not the others. For example one of my personal hates is how innertext is only supported in ie7,8 but not fox or chrome. Here is the compatability chart if you are interested <http://www.quirksmode.org/dom/w3c_html.html> . Bottom line, unless you plan on changing the plugin yourself and you've already tried modernizer and that didn't help, you are going ot have to use another method of loading data. My suggestion is to use .html, you can not go wrong with that, or append and hand form the html yourself in the js. Simpler is always the best solution.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
The only thing I can see wrong with this code is you are missing a closing bracket ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); } // <-- this one }); ```
The problem is some functions are supported in one and not the others. For example one of my personal hates is how innertext is only supported in ie7,8 but not fox or chrome. Here is the compatability chart if you are interested <http://www.quirksmode.org/dom/w3c_html.html> . Bottom line, unless you plan on changing the plugin yourself and you've already tried modernizer and that didn't help, you are going ot have to use another method of loading data. My suggestion is to use .html, you can not go wrong with that, or append and hand form the html yourself in the js. Simpler is always the best solution.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
I had the same problem and I noticed that if the url returns invalid HTML (eg. extra end tag) it can stop it from loading or finding the correct element. In my example all I had to do was correct the HTML from the URL and then it worked correctly.
The problem is some functions are supported in one and not the others. For example one of my personal hates is how innertext is only supported in ie7,8 but not fox or chrome. Here is the compatability chart if you are interested <http://www.quirksmode.org/dom/w3c_html.html> . Bottom line, unless you plan on changing the plugin yourself and you've already tried modernizer and that didn't help, you are going ot have to use another method of loading data. My suggestion is to use .html, you can not go wrong with that, or append and hand form the html yourself in the js. Simpler is always the best solution.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
ajax requests are cached in IE8, so just a little magic of $.ajaxSettings.cache = false; before the using load function <http://zacster.blogspot.in/2008/10/jquery-ie7-load-url-problem.html> <http://api.jquery.com/jQuery.ajax/> cache (default: true, false for dataType 'script' and 'jsonp') Type: Boolean If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "\_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
The problem is some functions are supported in one and not the others. For example one of my personal hates is how innertext is only supported in ie7,8 but not fox or chrome. Here is the compatability chart if you are interested <http://www.quirksmode.org/dom/w3c_html.html> . Bottom line, unless you plan on changing the plugin yourself and you've already tried modernizer and that didn't help, you are going ot have to use another method of loading data. My suggestion is to use .html, you can not go wrong with that, or append and hand form the html yourself in the js. Simpler is always the best solution.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
The only thing I can see wrong with this code is you are missing a closing bracket ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); } // <-- this one }); ```
`$.load()` **works** in IE8. My guess is you have a previous JS error, triggered only in IE8-, which prevents it from functioning properly, or being called altogether.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
I had the same problem and I noticed that if the url returns invalid HTML (eg. extra end tag) it can stop it from loading or finding the correct element. In my example all I had to do was correct the HTML from the URL and then it worked correctly.
`$.load()` **works** in IE8. My guess is you have a previous JS error, triggered only in IE8-, which prevents it from functioning properly, or being called altogether.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
ajax requests are cached in IE8, so just a little magic of $.ajaxSettings.cache = false; before the using load function <http://zacster.blogspot.in/2008/10/jquery-ie7-load-url-problem.html> <http://api.jquery.com/jQuery.ajax/> cache (default: true, false for dataType 'script' and 'jsonp') Type: Boolean If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "\_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
`$.load()` **works** in IE8. My guess is you have a previous JS error, triggered only in IE8-, which prevents it from functioning properly, or being called altogether.
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
I had the same problem and I noticed that if the url returns invalid HTML (eg. extra end tag) it can stop it from loading or finding the correct element. In my example all I had to do was correct the HTML from the URL and then it worked correctly.
The only thing I can see wrong with this code is you are missing a closing bracket ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); } // <-- this one }); ```
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
ajax requests are cached in IE8, so just a little magic of $.ajaxSettings.cache = false; before the using load function <http://zacster.blogspot.in/2008/10/jquery-ie7-load-url-problem.html> <http://api.jquery.com/jQuery.ajax/> cache (default: true, false for dataType 'script' and 'jsonp') Type: Boolean If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "\_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
The only thing I can see wrong with this code is you are missing a closing bracket ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); } // <-- this one }); ```
8,927,910
I've been looking for a solution all day, but I'm still seeing this error. It's a Expression Engine setup for a client of ours and we want to implement ajax-navigation. For this we are using the default $.load() function and this works perfectly in ie9, FF, Safari, Chrome, Opera... but it doesn't work in ie8 and below. I've tested the callback function, that one IS being called, the data is send, I can read it in the console when logging it. But for some odd reason the data isn't inserted. Here is the code: ``` load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } ``` There was a whole bunch of extra code in the callback function but I've been cleaning out the whole javascript/css everything. In search of bugs but nothing to be found. **Based on the comments I decided to add the url and a download:** * The site this problem is found in: <http://www.track.be/devo_9836/nl/ee.php> * A packet of files, with the problem: <http://stijnd.be/ie8_load.zip> **Another piece of the puzzle:** There is something weird going on in the javascript. Even the google maps api doesn't function properly, that's the first time this happened to me when using the google maps api. **EDIT : Answered** I finally found the answer to this question, thanks to @epascarello. It is in fact the fault of the data I was trying to import. Because IE8 & below don't understand HTML5 they will try to import the elements into the dom, but when alerting the data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement],... When I changed the markup of the data to use good old div's instead of article-elements, everything worked fine!
2012/01/19
[ "https://Stackoverflow.com/questions/8927910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383731/" ]
I had the same problem and I noticed that if the url returns invalid HTML (eg. extra end tag) it can stop it from loading or finding the correct element. In my example all I had to do was correct the HTML from the URL and then it worked correctly.
ajax requests are cached in IE8, so just a little magic of $.ajaxSettings.cache = false; before the using load function <http://zacster.blogspot.in/2008/10/jquery-ie7-load-url-problem.html> <http://api.jquery.com/jQuery.ajax/> cache (default: true, false for dataType 'script' and 'jsonp') Type: Boolean If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "\_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
33,571,312
I have a class `K` and I am constructing an object in a call to function `test`. So I believe that the constructed `K` is called an *r-value*. (Is that true?) But I am puzzled, and bothered that the `K` object is apparently *const*, not *mutable*. I don't want it to be. Simple test program: ==================== ``` #include <iostream> class K {}; std::string test (K &k) {return "mutable";} std::string test (const K &k) {return "const";} int main (int argc, const char **argv) { std::cerr << "K constructed for function argument is " << test(K{}) << "\n"; K k; std::cerr << "K constructed for local variable is " << test(k) << "\n"; } ``` Output: ======= > > K constructed for function argument is const > > > K constructed for local variable is mutable > > > Note that when I create the `K` on the fly for passing as function argument I get a const object, whereas when I create it as a local variable I get a mutable. For my purposes I really want a mutable for both cases. Can you tell me how to do that, or else convince me why I shouldn't?
2015/11/06
[ "https://Stackoverflow.com/questions/33571312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3918508/" ]
A reference cannot bind to a temporary object but a `const T&` can. Since `K{}` is a temporary `std::string test (const K &k) {return "const";}` is chosen. If you really want to be able to modify the temporary then you can use and r-value reference ``` std::string test (K &&k) {return "r-value";} ``` `[Live Example](http://coliru.stacked-crooked.com/a/d620922f0e445eba)`
In standard C++, you can not bind temporary object to non-const reference. You can bind it to rvalue references, though. Users of MSVC enjoy the 'extension' of binding temporaries to non-const references.
33,571,312
I have a class `K` and I am constructing an object in a call to function `test`. So I believe that the constructed `K` is called an *r-value*. (Is that true?) But I am puzzled, and bothered that the `K` object is apparently *const*, not *mutable*. I don't want it to be. Simple test program: ==================== ``` #include <iostream> class K {}; std::string test (K &k) {return "mutable";} std::string test (const K &k) {return "const";} int main (int argc, const char **argv) { std::cerr << "K constructed for function argument is " << test(K{}) << "\n"; K k; std::cerr << "K constructed for local variable is " << test(k) << "\n"; } ``` Output: ======= > > K constructed for function argument is const > > > K constructed for local variable is mutable > > > Note that when I create the `K` on the fly for passing as function argument I get a const object, whereas when I create it as a local variable I get a mutable. For my purposes I really want a mutable for both cases. Can you tell me how to do that, or else convince me why I shouldn't?
2015/11/06
[ "https://Stackoverflow.com/questions/33571312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3918508/" ]
A reference cannot bind to a temporary object but a `const T&` can. Since `K{}` is a temporary `std::string test (const K &k) {return "const";}` is chosen. If you really want to be able to modify the temporary then you can use and r-value reference ``` std::string test (K &&k) {return "r-value";} ``` `[Live Example](http://coliru.stacked-crooked.com/a/d620922f0e445eba)`
It looks like you got your syntax mixed up between l-value references and r-value references. `K& k` : this is a non-const l-value reference. It can usually only be bound to variables that have names. This syntax implies (typically) you are taking in `k` and *modifying inside your function*, such that `k` is also the *output* of the function. Doing this with a temporary doesn't actually make sense, because the temporary will be gone. It only really makes sense to do for variables (esoteric compiler extensions aside). `const K& k` : const reference. This can bind to l or r-values. This means you are using `k` within your function, but (generally) don't need to copy it, and certainly won't modify it. It's safe-enough, because you can't modify the temporary (so there's no implicit assumption that it will be used later), and the temporary will exist for the life of the function. `K&& k` : This is an r-value reference. It implies move semantics, namely that the function using `k` will only accept a temporary value (or one made movable with `std::move`), and it will *take ownership* of said temporary. In practice, the only place I've personally found necessary (or really even appropriate) to use r-value references is: 1. class constructors for containers. These should have a move constructor/move assigner, so that they can take ownership when created with temporary values. 2. forwarding functions. I.e. wrapper functions which only call lower-level class functions. If those low-level class functions support r-values, a *universal reference* can be used to make sure that support doesn't get messed up. Your first instinct should probably be to avoid r-values in function calls. On the other hand, if you were *actually* trying to bind the temporary to a non-const reference I think this question/answer has a better explanation as to why it's not allowed: [How come a non-const reference cannot bind to a temporary object?](https://stackoverflow.com/questions/1565600/how-come-a-non-const-reference-cannot-bind-to-a-temporary-object)
33,571,312
I have a class `K` and I am constructing an object in a call to function `test`. So I believe that the constructed `K` is called an *r-value*. (Is that true?) But I am puzzled, and bothered that the `K` object is apparently *const*, not *mutable*. I don't want it to be. Simple test program: ==================== ``` #include <iostream> class K {}; std::string test (K &k) {return "mutable";} std::string test (const K &k) {return "const";} int main (int argc, const char **argv) { std::cerr << "K constructed for function argument is " << test(K{}) << "\n"; K k; std::cerr << "K constructed for local variable is " << test(k) << "\n"; } ``` Output: ======= > > K constructed for function argument is const > > > K constructed for local variable is mutable > > > Note that when I create the `K` on the fly for passing as function argument I get a const object, whereas when I create it as a local variable I get a mutable. For my purposes I really want a mutable for both cases. Can you tell me how to do that, or else convince me why I shouldn't?
2015/11/06
[ "https://Stackoverflow.com/questions/33571312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3918508/" ]
In standard C++, you can not bind temporary object to non-const reference. You can bind it to rvalue references, though. Users of MSVC enjoy the 'extension' of binding temporaries to non-const references.
It looks like you got your syntax mixed up between l-value references and r-value references. `K& k` : this is a non-const l-value reference. It can usually only be bound to variables that have names. This syntax implies (typically) you are taking in `k` and *modifying inside your function*, such that `k` is also the *output* of the function. Doing this with a temporary doesn't actually make sense, because the temporary will be gone. It only really makes sense to do for variables (esoteric compiler extensions aside). `const K& k` : const reference. This can bind to l or r-values. This means you are using `k` within your function, but (generally) don't need to copy it, and certainly won't modify it. It's safe-enough, because you can't modify the temporary (so there's no implicit assumption that it will be used later), and the temporary will exist for the life of the function. `K&& k` : This is an r-value reference. It implies move semantics, namely that the function using `k` will only accept a temporary value (or one made movable with `std::move`), and it will *take ownership* of said temporary. In practice, the only place I've personally found necessary (or really even appropriate) to use r-value references is: 1. class constructors for containers. These should have a move constructor/move assigner, so that they can take ownership when created with temporary values. 2. forwarding functions. I.e. wrapper functions which only call lower-level class functions. If those low-level class functions support r-values, a *universal reference* can be used to make sure that support doesn't get messed up. Your first instinct should probably be to avoid r-values in function calls. On the other hand, if you were *actually* trying to bind the temporary to a non-const reference I think this question/answer has a better explanation as to why it's not allowed: [How come a non-const reference cannot bind to a temporary object?](https://stackoverflow.com/questions/1565600/how-come-a-non-const-reference-cannot-bind-to-a-temporary-object)
3,460,251
> > Let $f \in \mathbb{Z}[X]$ be a monic irreducible polynomial, n its degree, $\alpha$ a zero of $f$ in some extension field of $\mathbb{Q}$, and $p$ a prime number not dividing the discriminant $\Delta(f)$ of $f$. Denote by $t$ the number of prime ideals $\mathfrak{p}$ of $\mathbb{Z}[\alpha]$ with $p \in \mathfrak{p}$. Prove that $\left( \dfrac{\Delta(f)}{p} \right) = (-1)^{n-t}$. > > > It is a generalization of a result in quadratic number field > > **Proposition:** Let $d \neq 1$ be squarefree and $p$ an odd prime. Then $p$ is split in $\mathbb{Z}[\sqrt{d}]$ for $\left(\dfrac{d}{p}\right)=1$, inert for $\left(\dfrac{d}{p}\right)=-1$ and ramified for $\left(\dfrac{d}{p}\right)=0$. > > > The proposition can be deduced from Kummer-Dedekind theorem and explicit description of $\mathcal{O}\_{\mathbb{Z}[\sqrt{d}]}$ that $\mathcal{O}\_{\mathbb{Z}[\sqrt{d}]}=\mathbb{Z}[\sqrt{d}]$ for $d \equiv 2,3 \;(mod \;4)$ and $\mathcal{O}\_{\mathbb{Z}[\sqrt{d}]}=\mathbb{Z}\left[\dfrac{1+\sqrt{d}}{2} \right]$ for $d \equiv 1 \; (mod \;4)$. However I have stuck since we don't have explicit description of ring of integer of $\mathbb{Q}[\alpha]$ in general.
2019/12/02
[ "https://math.stackexchange.com/questions/3460251", "https://math.stackexchange.com", "https://math.stackexchange.com/users/424581/" ]
This is known as Stickelberger's Theorem, and the proof is not exactly straightforward. Here is how it goes: by Dedekind criterion the number of primes above $p$ is exactly the number of irreducible factors of $f$ modulo $p$, because $p$ does not divide $\Delta(f)$. So write $f=g\_1\ldots g\_r$ in $\mathbb F\_p[x]$. If $r=1$, the claim holds because on the one hand the Galois group of $g\_1$ over $\mathbb F\_p$ is $C\_{\deg g\_1}$, and on the other hand the Galois group of an irreducible polynomial of degree $n$ is contained in $A\_n$ if and only if the discriminant is a square. To get the general case, just use the fact that $\Delta(f)$ is $\prod \Delta(g\_i)$ up to a square.
Factoring $f\in \Bbb{F}\_p[x]$ we have $$f(x)= \prod\_{k\le t} g\_k(x)=\prod\_{k \le t} \prod\_{l=1}^{d\_k} (x-a\_k^{p^l}), \qquad \qquad a\_k^{p^{d\_k}} =a\_k$$ Put an ordering on the set of roots : $a\_k^{p^l} <a\_{k\_2}^{p^{l\_2}}$ if $k< k\_2$ or $k=k\_2,1\le l<l\_2\le d\_k$, we obtain $$\Delta(f)^{1/2} = \prod\_{a\_k^{p^l} <a\_{k\_2}^{p^{l\_2}}} (a\_k^{p^l} -a\_{k\_2}^{p^{l\_2}})$$ Let $\phi$ be the Frobenius of $f$'s splitting field, since $\Delta(f)\in\Bbb{F}\_p^\*$ then $\Delta(f)$ is a square iff $\frac{\phi(\Delta(f)^{1/2})}{\Delta(f)^{1/2}}=1$. Since $\phi(\Delta(f)^{1/2})=\prod\_{a\_k^{p^l} <a\_{k\_2}^{p^{l\_2}}}(a\_k^{p^{l+1}} -a\_{k\_2}^{p^{l\_2+1}})$ then $$\frac{\phi(\Delta(f)^{1/2})}{\Delta(f)^{1/2}}=\prod\_{a\_k^{p^l} <a\_{k\_2}^{p^{l\_2}},a\_k^{p^{l+1}} >a\_{k\_2}^{p^{l\_2+1}}} (-1)$$ Given $a\_k^{p^l} <a\_{k\_2}^{p^{l\_2}}$, * If $k<k\_2$ then $a\_k^{p^{l+1}} <a\_{k\_2}^{p^{l\_2+1}}$, * otherwise $k=k\_2$ and $a\_k^{p^{l+1}} >a\_k^{p^{l\_2+1}}$ iff $l\_2=d\_k$ which gives $$\left( \dfrac{\Delta(f)}{p} \right) =\frac{\phi(\Delta(f)^{1/2})}{\Delta(f)^{1/2}}= \prod\_{k \le t}\prod\_{l=1}^{d\_k-1} (-1)= (-1)^{n-t}$$
37,440,097
I want to create the same thing as **Uber** did with seek bar [![enter image description here](https://i.stack.imgur.com/HfbtJ.jpg)](https://i.stack.imgur.com/HfbtJ.jpg) Is there any library that can help me achieve this?
2016/05/25
[ "https://Stackoverflow.com/questions/37440097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4966197/" ]
Try implementing a custom `Seekbar` with your own "`progressDrawable`" and "`thumb`" drawable. Then manage the specific behaviors programatically. That's what i'm using to achieve something similar: ``` <SeekBar android:id="@+id/seekbar_task" android:layout_width="330dp" android:layout_height="40dp" android:layout_alignParentBottom="true" android:max="100" android:maxHeight="4dip" android:minHeight="4dip" android:progress="10" android:progressDrawable="@drawable/progress_task" android:splitTrack="false" android:thumb="@drawable/tumb_task" /> ``` Implement SeekBar.OnSeekBarChangeListener in your Activity/Fragment to handle the different states ``` @Override public void onStopTrackingTouch(SeekBar seekBar) { int mProgress = seekBar.getProgress(); if (mProgress > 0 & mProgress < 21) { mSeekBar.setProgress(10); sendStateResponse("TODO"); setBoldText(0); } else if (mProgress > 20 & mProgress < 41) { mSeekBar.setProgress(30); sendStateResponse("START"); setBoldText(1); } else if (mProgress > 40 & mProgress < 61) { mSeekBar.setProgress(50); sendStateResponse("STOP"); setBoldText(2); } else if (mProgress > 60 & mProgress < 81) { mSeekBar.setProgress(70); sendStateResponse("CONTINUE"); setBoldText(3); } else { mSeekBar.setProgress(90); sendStateResponse("FINISHED"); setBoldText(4); } } ```
Have a look [**here**](https://android-arsenal.com/search?q=seek) there are a lot of different libraries. [This one](https://android-arsenal.com/details/1/919) might be similar to what you are searching for.
19,311,535
I want to write the data from my `DataGridView` to a textfile. The following code writes the data but it is not formatted correctly. ``` StreamWriter sW = new StreamWriter(dirLocationString); string lines = ""; for (int row = 0; row< numRows1; row++){ for (int col = 0; col < 4; col++) { lines = lines + " " + dataGridView1.Rows[row].Cells[col].Value.ToString(); } sW.WriteLine(lines); } sW.Close(); ``` I want the output format to be like: ``` AAAA, BBBB, CCCC, DDDD ``` But instead it displays the following: ``` AAAA BBBB CCCC DDDD AAAA BBBB CCCC DDDD AAAA BBBB CCCC DDDD AAAA BBBB CCCC DDDD AAAA BBBB CCCC DDDD AAAA BBBB CCCC DDDD and so on.. ```
2013/10/11
[ "https://Stackoverflow.com/questions/19311535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1731312/" ]
Init `lines` in first loop : ``` StreamWriter sW = new StreamWriter(dirLocationString); for (int row = 0; row< numRows1; row++){ string lines = ""; for (int col = 0; col < 4; col++) { lines += (string.IsNullOrEmpty(lines) ? " " : ", ") + dataGridView1.Rows[row].Cells[col].Value.ToString(); } sW.WriteLine(lines); } sW.Close(); ```
Unfortunately looping through rows and columns is prone to errors and not very succinct. Here is a little hack that takes advantage of `Windows.Forms.Clipboard` and `DataGridView.GetClipboardContent()` to do all the dirty work for you. `DataGridView.GetClipboardContent()` returns all the selected data cells as a DataObject, which is how the Clipboard class is able to store different types of data and formatting. The contents of the clipboard are then written to a file using the File class. You say you want a text file, but I see commas the example of your desired output, so I am assuming you would like a CSV file. You can also write out a text file by changing the `Clipboard.GetText` parameter. ``` void SaveDataGridViewToCSV(string Filename) { // Choose whether to write header. Use EnableWithoutHeaderText instead to omit header. dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText; // Select all the cells dataGridView1.SelectAll(); // Copy (set clipboard) Clipboard.SetDataObject(dataGridView1.GetClipboardContent()); // Paste (get the clipboard and serialize it to a file) File.WriteAllText(Filename,Clipboard.GetText(TextDataFormat.CommaSeparatedValue)); } ``` Please note that an object must be serializable for it to be put on the Clipboard. For a tab-delimited file, use the `TextDataFormat.Text` enum in your call to `Clipboard.GetText()`. You can also output your DataGridView as HTML by using `TextDataFormat.Html` instead of `TextDataFormat.CommaSeparatedValue`, but there is extra header data you have to parse out. Hope this helps.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
I have dealt with 'clients' like this in the past. As others have said, first **get a contract**. But in my experience, for clients that behave this way, the contract still doesn't guarentee prompt payment. It just gets you the privilege of spending months in various legal processes to get your money (maybe). So for these types of people, I always require **payment up front!** (at least in part) No work is done until payment is received. If they have an out-stading bill from previous work, then no new work is started until all past due accounts are settled *and* payment for new work is received. It's amazing how a "super critical, needs to be finished yesterday" task turns into "we can wait till next quarter" once *their* money is on the line. --- Be aware: When you start demanding this from him, he *will* fire back at you. > > You can trust me to pay! > > > How do I know you won't just take the money and run? > > > ... > > > He will have a thousand and one reasons *not* to pay like this. You have one response to all of these: > > If you want the *quality* of product and *speed* of delivery that I have *already delivered* to you and will *continue to deliver*. I will be paid up front and in full for my time and expertise. > > > If he doesn't agree to this arrangement, then you take your time and expertise to another client who will value what you can deliver. Then you watch one of three things happen to him: 1. His business slowly implodes as he makes poorer and poorer choices about how he sources his business solutions. 2. He realizes just how valuable you are, returns a few months to years later and agrees to whatever you demand of him. 3. He learns his lesson and works with someone else of equal skill to you, and pays *them* upfront (and probably more than you were charging him)
Question: You are OK (or seemed to have been OK in the past) with your friend delaying your payment due to personal issues. What would your friend say if you were to delay construction of his project due to your own personal issues? I'd try that. Just say to him one day something like "I understand how important this project is to you, and I promise I'll get it done, but this week is just a rough week for me at work so I need time to myself when I'm not working on other things". See what he says. * If he's OK with that, then you have an understanding: He doesn't have to pay you promptly, but you also don't have to get the work done promptly. You are essentially "volunteering" (until the money materializes that is functionally what you are doing), and your friend is getting what he paid for (i.e. he paid nothing, so he's getting as much as you are willing to provide, provided him paying nothing). * If he's not OK with that, then explain to him that your time is valuable. You are having a rough time at work, it's very stressful working 2 jobs (because functionally you are), and he should give you a good reason to continue stressing yourself out (even if you're not stressing yourself out, pretend like you are). Then he can either say "Sorry you're stressing yourself out, I promise I'll compensate you by X day in Y amount", in which case you hold him to that, or he'll give you another excuse. In the former case, ask for the compensation **in writing**. In the latter case, he's not really your friend and he's just taking advantage of you, so throw him to the wind.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
Business is business, friendship is friendship. Don't mix them up. You do the work for him. You get paid from him. Simple as that. The things you need to do? Get him sign a contract which states the rate, how much time you work every week, when you get paid after delivery, etc. **Insist on** him signing the contract before continue the work. If you don't get a contract before continuing, I am afraid you'll lose both the pay/time and the friendship. Many small business/startup run by friends failed the way you described in your question.
Point out to him that you have a family to feed and a mortgage to pay (or rent, or board, or whatever). If he doesn't enable you to feed your family and pay your mortgage, then you'll need to find a job that *does* enable you to do those things. In short, if he doesn't pay you, then stop working. If he needs the work do be done as quickly as possible, then he'll have to choose whether to * start paying you, or * find another victim who will work for him for free.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
You're about to be ripped off. And because you don't have a contract, you'll have a hard fight to get paid. Your 'friend' is putting a 'business manager' between you and he. The usual reason for that is to provide someone else to blame - "I'd love to pay you, but the business manager says that the work was not to spec"... It's been seen far too many times. You need to STOP work right now, and insist on payment to date, and a valid contract and deposit for all work moving forward. Whether he gets agitated at this is not your problem. You don't have any shares in this company; if it's successful, all you'll ever (maybe) get is paid for your work. He has a big house and a business manager that are all being paid for, but the poor sop in the corner who's doing a lot of the real work is not even getting the scraps from the table. You need to get paid fairly for your work, or you need to get out as soon as possible so that you can put your efforts towards getting a real job.
Point out to him that you have a family to feed and a mortgage to pay (or rent, or board, or whatever). If he doesn't enable you to feed your family and pay your mortgage, then you'll need to find a job that *does* enable you to do those things. In short, if he doesn't pay you, then stop working. If he needs the work do be done as quickly as possible, then he'll have to choose whether to * start paying you, or * find another victim who will work for him for free.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
> > we do not have any contract or anything written down on paper > > > This is not just the context, **it's part of the problem**. Don't get me wrong, not every favor you do a friend should be documented. But what you're doing now is much more than just a favor. You need to reevaluate what "friend" means in this context. > > As you know I keep most of my funds in cryptocurrencies so often it's not that easy to just get the money out > > > Not your circus, not your monkeys. Your friend can have his money stuffed under his mattress, in a bank account or invested in cryptocurrency. It doesn't matter. When he needs to pay a bill, that bill needs to be paid. End of story. However, I do understand that you're lenient towards a friend. Even if you're eventually okay with a delayed payment, there is a dramatic shift in your involvement here. **Currently**, you are at your friend's mercy. He pays you when he sees fit (and he clearly isn't bothered to solve this quickly). You have no way of forcing him to pay you, since there is nothing that documents his requirement to pay you. What you should do, is draft a contractual agreement of the amount to be paid, and by when it should be paid. If your friend needs a delay, **and you agree to it**, then you're still free to grant him that delay. But this way, **you get a say in things**. You need to agree to that delay. If your friend delays too long, or it becomes clear that his delayed payments are unwarranted, then you have the contract to force him to pay. **Don't wait until an issue arises. Document everything in cases an issue arises in the future**. > > He got very agitated and started asking me if I don't trust him > > > "Trust me" is not a valid justification. If anything, it is cause for concern if he has nothing to reassure you with other than asking for your blind trust. > > and telling me he always keeps his word but I didn't get any unequivocal response. > > > The fact that he didn't pay you by the agreed upon date proves that he doesn't keep his word. The cause for the delay might not be his *fault* (e.g. unexpected circumstances), but he still didn't keep his word. Your friend is essentially arguing that just because he didn't *knowingly* lie to you, he's not responsible for failing to deliver on something he said he'd deliver. > > he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly > > > This is a major red flag. He's expanding the business (adding a business manager layer between him and you) yet still not paying the initial costs of the business. He is effectively insulating himself from you and your outstanding bills. > > **Question**: > > > What can I do to make sure I will get paid in a reasonable amount of time. I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary. > > > For the future, **always draft a contract**. For the existing payment, you're not guaranteed to get it. If the relationship deteriorates, he's liable to outright refuse any future payment that he's not legally obligated to pay (which is why the contract is so important). Though I doubt there is much you can do legally, you could consult with a lawyer to see if there is enough documentation (e.g. emails or records) that justify a verbal agreement. --- **Speculation** This is just a re-framing of your story. What I say is not objectively more correct than what you say, but I'm showing you a different interpretation of the same story: > > You've done work for a *startup* focused on a *recently created* business sector which has a tendency to attract people who try their luck at *easy money*. The company has *failed to pay its bills*, claiming that its capital is tied up in its own business, but is *still asking you to continue work* and even *increase the work* (since you're talking about a higher price). > > Repeated requests for payment are *dismissed as a lack of trust* in the company's financial future. After repeated dismissal of your request for payment you are now *redirected to a third party*. > > > It seems to me that your "friend" is treating you like a salaried investor to his company. If it succeeds, you **might** get your money (if he wants to pay, but it won't be proportional to the financial success achieved). If it fails, you won't see any money. He has effectively borrowed your money and is intending to either not pay it back (because of bankruptcy, or because he outright refuses and you have no contract to prove anything) or pay it back **without interest**. This is highly unethical. If he is genuine and has no ill intentions, you could argue that the outstanding bills can be converted to an investment; which would entitle you to a share of the profits rather than a fixed amount. I doubt he'll ever go for it, and I have my doubts about the viability of his company (given the way he runs it), but if: 1. You believe that the company is going to succeed (enough to want to invest in it), 2. You don't need the money right now, and 3. Your friend is genuinely short on money and well-intentioned this is a possible way out of the situation. But I'm highly skeptical.
Business is business, friendship is friendship. Don't mix them up. You do the work for him. You get paid from him. Simple as that. The things you need to do? Get him sign a contract which states the rate, how much time you work every week, when you get paid after delivery, etc. **Insist on** him signing the contract before continue the work. If you don't get a contract before continuing, I am afraid you'll lose both the pay/time and the friendship. Many small business/startup run by friends failed the way you described in your question.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
> > we do not have any contract or anything written down on paper > > > This is not just the context, **it's part of the problem**. Don't get me wrong, not every favor you do a friend should be documented. But what you're doing now is much more than just a favor. You need to reevaluate what "friend" means in this context. > > As you know I keep most of my funds in cryptocurrencies so often it's not that easy to just get the money out > > > Not your circus, not your monkeys. Your friend can have his money stuffed under his mattress, in a bank account or invested in cryptocurrency. It doesn't matter. When he needs to pay a bill, that bill needs to be paid. End of story. However, I do understand that you're lenient towards a friend. Even if you're eventually okay with a delayed payment, there is a dramatic shift in your involvement here. **Currently**, you are at your friend's mercy. He pays you when he sees fit (and he clearly isn't bothered to solve this quickly). You have no way of forcing him to pay you, since there is nothing that documents his requirement to pay you. What you should do, is draft a contractual agreement of the amount to be paid, and by when it should be paid. If your friend needs a delay, **and you agree to it**, then you're still free to grant him that delay. But this way, **you get a say in things**. You need to agree to that delay. If your friend delays too long, or it becomes clear that his delayed payments are unwarranted, then you have the contract to force him to pay. **Don't wait until an issue arises. Document everything in cases an issue arises in the future**. > > He got very agitated and started asking me if I don't trust him > > > "Trust me" is not a valid justification. If anything, it is cause for concern if he has nothing to reassure you with other than asking for your blind trust. > > and telling me he always keeps his word but I didn't get any unequivocal response. > > > The fact that he didn't pay you by the agreed upon date proves that he doesn't keep his word. The cause for the delay might not be his *fault* (e.g. unexpected circumstances), but he still didn't keep his word. Your friend is essentially arguing that just because he didn't *knowingly* lie to you, he's not responsible for failing to deliver on something he said he'd deliver. > > he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly > > > This is a major red flag. He's expanding the business (adding a business manager layer between him and you) yet still not paying the initial costs of the business. He is effectively insulating himself from you and your outstanding bills. > > **Question**: > > > What can I do to make sure I will get paid in a reasonable amount of time. I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary. > > > For the future, **always draft a contract**. For the existing payment, you're not guaranteed to get it. If the relationship deteriorates, he's liable to outright refuse any future payment that he's not legally obligated to pay (which is why the contract is so important). Though I doubt there is much you can do legally, you could consult with a lawyer to see if there is enough documentation (e.g. emails or records) that justify a verbal agreement. --- **Speculation** This is just a re-framing of your story. What I say is not objectively more correct than what you say, but I'm showing you a different interpretation of the same story: > > You've done work for a *startup* focused on a *recently created* business sector which has a tendency to attract people who try their luck at *easy money*. The company has *failed to pay its bills*, claiming that its capital is tied up in its own business, but is *still asking you to continue work* and even *increase the work* (since you're talking about a higher price). > > Repeated requests for payment are *dismissed as a lack of trust* in the company's financial future. After repeated dismissal of your request for payment you are now *redirected to a third party*. > > > It seems to me that your "friend" is treating you like a salaried investor to his company. If it succeeds, you **might** get your money (if he wants to pay, but it won't be proportional to the financial success achieved). If it fails, you won't see any money. He has effectively borrowed your money and is intending to either not pay it back (because of bankruptcy, or because he outright refuses and you have no contract to prove anything) or pay it back **without interest**. This is highly unethical. If he is genuine and has no ill intentions, you could argue that the outstanding bills can be converted to an investment; which would entitle you to a share of the profits rather than a fixed amount. I doubt he'll ever go for it, and I have my doubts about the viability of his company (given the way he runs it), but if: 1. You believe that the company is going to succeed (enough to want to invest in it), 2. You don't need the money right now, and 3. Your friend is genuinely short on money and well-intentioned this is a possible way out of the situation. But I'm highly skeptical.
You're about to be ripped off. And because you don't have a contract, you'll have a hard fight to get paid. Your 'friend' is putting a 'business manager' between you and he. The usual reason for that is to provide someone else to blame - "I'd love to pay you, but the business manager says that the work was not to spec"... It's been seen far too many times. You need to STOP work right now, and insist on payment to date, and a valid contract and deposit for all work moving forward. Whether he gets agitated at this is not your problem. You don't have any shares in this company; if it's successful, all you'll ever (maybe) get is paid for your work. He has a big house and a business manager that are all being paid for, but the poor sop in the corner who's doing a lot of the real work is not even getting the scraps from the table. You need to get paid fairly for your work, or you need to get out as soon as possible so that you can put your efforts towards getting a real job.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
I have dealt with 'clients' like this in the past. As others have said, first **get a contract**. But in my experience, for clients that behave this way, the contract still doesn't guarentee prompt payment. It just gets you the privilege of spending months in various legal processes to get your money (maybe). So for these types of people, I always require **payment up front!** (at least in part) No work is done until payment is received. If they have an out-stading bill from previous work, then no new work is started until all past due accounts are settled *and* payment for new work is received. It's amazing how a "super critical, needs to be finished yesterday" task turns into "we can wait till next quarter" once *their* money is on the line. --- Be aware: When you start demanding this from him, he *will* fire back at you. > > You can trust me to pay! > > > How do I know you won't just take the money and run? > > > ... > > > He will have a thousand and one reasons *not* to pay like this. You have one response to all of these: > > If you want the *quality* of product and *speed* of delivery that I have *already delivered* to you and will *continue to deliver*. I will be paid up front and in full for my time and expertise. > > > If he doesn't agree to this arrangement, then you take your time and expertise to another client who will value what you can deliver. Then you watch one of three things happen to him: 1. His business slowly implodes as he makes poorer and poorer choices about how he sources his business solutions. 2. He realizes just how valuable you are, returns a few months to years later and agrees to whatever you demand of him. 3. He learns his lesson and works with someone else of equal skill to you, and pays *them* upfront (and probably more than you were charging him)
You will never get paid what you are owed. This guy is trying to build a cryptocurrencies business with very little capital. Cryptocurrencies start-ups are all over the place at the moment, so to make a go of this without any investment he has to be very smart and be a very good business person. From reading your story, he is neither, so this is going to fall apart soon.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
You're about to be ripped off. And because you don't have a contract, you'll have a hard fight to get paid. Your 'friend' is putting a 'business manager' between you and he. The usual reason for that is to provide someone else to blame - "I'd love to pay you, but the business manager says that the work was not to spec"... It's been seen far too many times. You need to STOP work right now, and insist on payment to date, and a valid contract and deposit for all work moving forward. Whether he gets agitated at this is not your problem. You don't have any shares in this company; if it's successful, all you'll ever (maybe) get is paid for your work. He has a big house and a business manager that are all being paid for, but the poor sop in the corner who's doing a lot of the real work is not even getting the scraps from the table. You need to get paid fairly for your work, or you need to get out as soon as possible so that you can put your efforts towards getting a real job.
You will never get paid what you are owed. This guy is trying to build a cryptocurrencies business with very little capital. Cryptocurrencies start-ups are all over the place at the moment, so to make a go of this without any investment he has to be very smart and be a very good business person. From reading your story, he is neither, so this is going to fall apart soon.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
I have dealt with 'clients' like this in the past. As others have said, first **get a contract**. But in my experience, for clients that behave this way, the contract still doesn't guarentee prompt payment. It just gets you the privilege of spending months in various legal processes to get your money (maybe). So for these types of people, I always require **payment up front!** (at least in part) No work is done until payment is received. If they have an out-stading bill from previous work, then no new work is started until all past due accounts are settled *and* payment for new work is received. It's amazing how a "super critical, needs to be finished yesterday" task turns into "we can wait till next quarter" once *their* money is on the line. --- Be aware: When you start demanding this from him, he *will* fire back at you. > > You can trust me to pay! > > > How do I know you won't just take the money and run? > > > ... > > > He will have a thousand and one reasons *not* to pay like this. You have one response to all of these: > > If you want the *quality* of product and *speed* of delivery that I have *already delivered* to you and will *continue to deliver*. I will be paid up front and in full for my time and expertise. > > > If he doesn't agree to this arrangement, then you take your time and expertise to another client who will value what you can deliver. Then you watch one of three things happen to him: 1. His business slowly implodes as he makes poorer and poorer choices about how he sources his business solutions. 2. He realizes just how valuable you are, returns a few months to years later and agrees to whatever you demand of him. 3. He learns his lesson and works with someone else of equal skill to you, and pays *them* upfront (and probably more than you were charging him)
Point out to him that you have a family to feed and a mortgage to pay (or rent, or board, or whatever). If he doesn't enable you to feed your family and pay your mortgage, then you'll need to find a job that *does* enable you to do those things. In short, if he doesn't pay you, then stop working. If he needs the work do be done as quickly as possible, then he'll have to choose whether to * start paying you, or * find another victim who will work for him for free.
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
> > we do not have any contract or anything written down on paper > > > This is not just the context, **it's part of the problem**. Don't get me wrong, not every favor you do a friend should be documented. But what you're doing now is much more than just a favor. You need to reevaluate what "friend" means in this context. > > As you know I keep most of my funds in cryptocurrencies so often it's not that easy to just get the money out > > > Not your circus, not your monkeys. Your friend can have his money stuffed under his mattress, in a bank account or invested in cryptocurrency. It doesn't matter. When he needs to pay a bill, that bill needs to be paid. End of story. However, I do understand that you're lenient towards a friend. Even if you're eventually okay with a delayed payment, there is a dramatic shift in your involvement here. **Currently**, you are at your friend's mercy. He pays you when he sees fit (and he clearly isn't bothered to solve this quickly). You have no way of forcing him to pay you, since there is nothing that documents his requirement to pay you. What you should do, is draft a contractual agreement of the amount to be paid, and by when it should be paid. If your friend needs a delay, **and you agree to it**, then you're still free to grant him that delay. But this way, **you get a say in things**. You need to agree to that delay. If your friend delays too long, or it becomes clear that his delayed payments are unwarranted, then you have the contract to force him to pay. **Don't wait until an issue arises. Document everything in cases an issue arises in the future**. > > He got very agitated and started asking me if I don't trust him > > > "Trust me" is not a valid justification. If anything, it is cause for concern if he has nothing to reassure you with other than asking for your blind trust. > > and telling me he always keeps his word but I didn't get any unequivocal response. > > > The fact that he didn't pay you by the agreed upon date proves that he doesn't keep his word. The cause for the delay might not be his *fault* (e.g. unexpected circumstances), but he still didn't keep his word. Your friend is essentially arguing that just because he didn't *knowingly* lie to you, he's not responsible for failing to deliver on something he said he'd deliver. > > he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly > > > This is a major red flag. He's expanding the business (adding a business manager layer between him and you) yet still not paying the initial costs of the business. He is effectively insulating himself from you and your outstanding bills. > > **Question**: > > > What can I do to make sure I will get paid in a reasonable amount of time. I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary. > > > For the future, **always draft a contract**. For the existing payment, you're not guaranteed to get it. If the relationship deteriorates, he's liable to outright refuse any future payment that he's not legally obligated to pay (which is why the contract is so important). Though I doubt there is much you can do legally, you could consult with a lawyer to see if there is enough documentation (e.g. emails or records) that justify a verbal agreement. --- **Speculation** This is just a re-framing of your story. What I say is not objectively more correct than what you say, but I'm showing you a different interpretation of the same story: > > You've done work for a *startup* focused on a *recently created* business sector which has a tendency to attract people who try their luck at *easy money*. The company has *failed to pay its bills*, claiming that its capital is tied up in its own business, but is *still asking you to continue work* and even *increase the work* (since you're talking about a higher price). > > Repeated requests for payment are *dismissed as a lack of trust* in the company's financial future. After repeated dismissal of your request for payment you are now *redirected to a third party*. > > > It seems to me that your "friend" is treating you like a salaried investor to his company. If it succeeds, you **might** get your money (if he wants to pay, but it won't be proportional to the financial success achieved). If it fails, you won't see any money. He has effectively borrowed your money and is intending to either not pay it back (because of bankruptcy, or because he outright refuses and you have no contract to prove anything) or pay it back **without interest**. This is highly unethical. If he is genuine and has no ill intentions, you could argue that the outstanding bills can be converted to an investment; which would entitle you to a share of the profits rather than a fixed amount. I doubt he'll ever go for it, and I have my doubts about the viability of his company (given the way he runs it), but if: 1. You believe that the company is going to succeed (enough to want to invest in it), 2. You don't need the money right now, and 3. Your friend is genuinely short on money and well-intentioned this is a possible way out of the situation. But I'm highly skeptical.
You will never get paid what you are owed. This guy is trying to build a cryptocurrencies business with very little capital. Cryptocurrencies start-ups are all over the place at the moment, so to make a go of this without any investment he has to be very smart and be a very good business person. From reading your story, he is neither, so this is going to fall apart soon.