qid
int64
1
74.7M
question
stringlengths
17
39.2k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
41.1k
response_k
stringlengths
2
47.9k
54,559,751
I have this tables: timelines ``` id | post_id | group_id ``` post\_views ``` id | post_id | user_id ``` My query is like: ``` SELECT distinct on (t.post_id) post_id, t.group_id, t.id, t.created_at FROM timelines t join post_views pv USING(post_id) WHERE t.group_id IN (1, 2, 78) ``` It's "working", but I need to get other field named 'seen', and that field will receive true if has t.post\_id = pv.post\_id AND user\_id = 100, or else return false or NULL I can't do the `WHERE` in `JOIN` clause. Thanks --- Example: <https://www.db-fiddle.com/f/m2HdHrZD5fY98tpGa1Eqsw/0> Guys, I made the example above to help you to help me :D
2019/02/06
[ "https://Stackoverflow.com/questions/54559751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10240618/" ]
I have found a solution to the problem which works 100% of the time, however it's slightly inconvenient. When trying to open the VBA > References, it will crash therefore I cannot find the missing reference. My workaround is to clear all trusted documents, which brings the 'Enable Content' pop up. Before enabling content, I will go back to VBA > References, remove and re-add OLE Automation. The next step is to save the file, enable content and you're good to go!
Try opening it in the Mac version of Excel. I tried this in last ditch desperation after no other recommendations worked (I couldn't try opening in online version because the file is password protected which isn't supported there). Mac Excel was able to open it without any complaints. I was then able to save it out just fine, and Windows (10, 64 bit- where the file was originally created) Excel was then able to read like normal. Using the various recovery methods with Windows Excel, the best I could get was a version that preserved the formulas but lost all of the VBA and all of the named ranges. BTW, one other feature of my problem: I was working on the file for about a week. In that time, I never closed and reopened it. I did, however, save many, many times. Including saving versions in new files. I discovered the problem when I finally did close & reopen. And I discovered that every single version I had saved in the past five days was also corrupt.
54,559,751
I have this tables: timelines ``` id | post_id | group_id ``` post\_views ``` id | post_id | user_id ``` My query is like: ``` SELECT distinct on (t.post_id) post_id, t.group_id, t.id, t.created_at FROM timelines t join post_views pv USING(post_id) WHERE t.group_id IN (1, 2, 78) ``` It's "working", but I need to get other field named 'seen', and that field will receive true if has t.post\_id = pv.post\_id AND user\_id = 100, or else return false or NULL I can't do the `WHERE` in `JOIN` clause. Thanks --- Example: <https://www.db-fiddle.com/f/m2HdHrZD5fY98tpGa1Eqsw/0> Guys, I made the example above to help you to help me :D
2019/02/06
[ "https://Stackoverflow.com/questions/54559751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10240618/" ]
When all else failed, this worked for me. I opened my workbook in Excel online (Office 365, in the browser, which doesn't support macros anyway), saved it with a new file name (still using .xlsm file extension), and reopened in the desktop software. It worked.
Try opening it in the Mac version of Excel. I tried this in last ditch desperation after no other recommendations worked (I couldn't try opening in online version because the file is password protected which isn't supported there). Mac Excel was able to open it without any complaints. I was then able to save it out just fine, and Windows (10, 64 bit- where the file was originally created) Excel was then able to read like normal. Using the various recovery methods with Windows Excel, the best I could get was a version that preserved the formulas but lost all of the VBA and all of the named ranges. BTW, one other feature of my problem: I was working on the file for about a week. In that time, I never closed and reopened it. I did, however, save many, many times. Including saving versions in new files. I discovered the problem when I finally did close & reopen. And I discovered that every single version I had saved in the past five days was also corrupt.
42,123,607
This question is the exact opposite of [SQL: Select columns with NULL values only](https://stackoverflow.com/questions/63291/sql-select-columns-with-null-values-only). Given a table with 1024 columns, how to find all columns WITHOUT null values? Input:`a table with 1024 columns` Output:`col1_name(no null values) col2_name(no null values)...`
2017/02/08
[ "https://Stackoverflow.com/questions/42123607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1349141/" ]
If you want to avoid using a CURSOR, this method will simply list out the column names of any columns that have no NULL values in them anywhere in the table... just set the @TableName at the top: ``` DECLARE @tableName sysname; DECLARE @sql nvarchar(max); SET @sql = N''; SET @tableName = N'Reports_table'; SELECT @sql += 'SELECT CASE WHEN EXISTS (SELECT 1 FROM ' + @tableName + ' WHERE '+ COLUMN_NAME + ' IS NULL) THEN NULL ELSE ''' + COLUMN_NAME + ''' END AS ColumnsWithNoNulls UNION ALL ' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @tableName SELECT @sql = SUBSTRING(@sql, 0, LEN(@sql) - 10); IF OBJECT_ID('tempdb..#Results') IS NOT NULL DROP TABLE #Results; CREATE TABLE #Results (ColumnsWithNoNulls sysname NULL); INSERT INTO #Results EXEC(@sql); SELECT * FROM #Results WHERE ColumnsWithNoNulls IS NOT NULL ``` As a bonus, the results are in a temp table, #Results, so you can query to get any information you want... counts, etc.
i modified the [Select columns with NULL values only.](https://stackoverflow.com/questions/63291/sql-select-columns-with-null-values-only) to work for your case : ``` SET ANSI_WARNINGS OFF declare @col varchar(255), @cmd varchar(max) DECLARE getinfo cursor for SELECT c.name FROM sys.tables t JOIN sys.columns c ON t.Object_ID = c.Object_ID WHERE t.Name = 'Reports_table' OPEN getinfo FETCH NEXT FROM getinfo into @col WHILE @@FETCH_STATUS = 0 BEGIN SELECT @cmd = 'IF (SELECT sum(iif([' + @col + '] is null,1,null)) FROM Reports_table) is null BEGIN print ''' + @col + ''' end' exec(@cmd) FETCH NEXT FROM getinfo into @col END CLOSE getinfo DEALLOCATE getinfo SET ANSI_WARNINGS on ```
116,515
I believe I have followed the template exactly but as this following MWE shows I am getting an asterisk on both authors and not just the corresponding author. Do I have something in the wrong order somewhere? ``` \documentclass[preprint,12pt]{elsarticle} \begin{document} \begin{frontmatter} \title{Title} \author{Author One\corref{cor1}\fnref{fn1}} \ead{[email protected]} \cortext[cor1]{Corresponding author} \fntext[fn1]{Student} \author{Author Two\fnref{fn2}} \ead{[email protected]} \fntext[fn2]{Lecturer} \address{Address Here} \begin{abstract} Abstract abstract abstract \end{abstract} \end{frontmatter} \section{Section1} Start typing... \end{document} ``` Thanks
2013/05/28
[ "https://tex.stackexchange.com/questions/116515", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/31396/" ]
It is a bug in the 2009 version, which is the one in the 2012 TeXlive. When no address label is specified the correspondng `\@author` command forgets to reset the `\@corref` variable. You can fix this by adding in such a reset as follows: ![Sample output](https://i.stack.imgur.com/o4QNt.png) ``` \documentclass[preprint,12pt]{elsarticle} \makeatletter \def\@author#1{\g@addto@macro\elsauthors{\normalsize% \def\baselinestretch{1}% \upshape\authorsep#1\unskip\textsuperscript{% \ifx\@fnmark\@empty\else\unskip\sep\@fnmark\let\sep=,\fi \ifx\@corref\@empty\else\unskip\sep\@corref\let\sep=,\fi }% \def\authorsep{\unskip,\space}% \global\let\@fnmark\@empty \global\let\@corref\@empty %% Added \global\let\sep\@empty}% \@eadauthor={#1} } \makeatother \begin{document} \begin{frontmatter} \title{Title} \author{Author One\corref{cor1}\fnref{fn1}} \ead{[email protected]} \cortext[cor1]{Corresponding author} \fntext[fn1]{Student} \author{Author Two\fnref{fn2}} \ead{[email protected]} \fntext[fn2]{Lecturer} \address{Address Here} \begin{abstract} Abstract abstract abstract \end{abstract} \end{frontmatter} \section{Section1} Start typing... \end{document} ```
Just add a \corrref to every author (with different labels) and just call the author you need. ``` \author{J.~Martinez} \author{F.~Julio\corref{cor1}} \ead{[email protected]} \author{N.~Vasquez\corref{cor2}} \author{H.~Cardenas\corref{cor2}} \cortext[cor1]{Corresponding author} ```
116,515
I believe I have followed the template exactly but as this following MWE shows I am getting an asterisk on both authors and not just the corresponding author. Do I have something in the wrong order somewhere? ``` \documentclass[preprint,12pt]{elsarticle} \begin{document} \begin{frontmatter} \title{Title} \author{Author One\corref{cor1}\fnref{fn1}} \ead{[email protected]} \cortext[cor1]{Corresponding author} \fntext[fn1]{Student} \author{Author Two\fnref{fn2}} \ead{[email protected]} \fntext[fn2]{Lecturer} \address{Address Here} \begin{abstract} Abstract abstract abstract \end{abstract} \end{frontmatter} \section{Section1} Start typing... \end{document} ``` Thanks
2013/05/28
[ "https://tex.stackexchange.com/questions/116515", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/31396/" ]
It is a bug in the 2009 version, which is the one in the 2012 TeXlive. When no address label is specified the correspondng `\@author` command forgets to reset the `\@corref` variable. You can fix this by adding in such a reset as follows: ![Sample output](https://i.stack.imgur.com/o4QNt.png) ``` \documentclass[preprint,12pt]{elsarticle} \makeatletter \def\@author#1{\g@addto@macro\elsauthors{\normalsize% \def\baselinestretch{1}% \upshape\authorsep#1\unskip\textsuperscript{% \ifx\@fnmark\@empty\else\unskip\sep\@fnmark\let\sep=,\fi \ifx\@corref\@empty\else\unskip\sep\@corref\let\sep=,\fi }% \def\authorsep{\unskip,\space}% \global\let\@fnmark\@empty \global\let\@corref\@empty %% Added \global\let\sep\@empty}% \@eadauthor={#1} } \makeatother \begin{document} \begin{frontmatter} \title{Title} \author{Author One\corref{cor1}\fnref{fn1}} \ead{[email protected]} \cortext[cor1]{Corresponding author} \fntext[fn1]{Student} \author{Author Two\fnref{fn2}} \ead{[email protected]} \fntext[fn2]{Lecturer} \address{Address Here} \begin{abstract} Abstract abstract abstract \end{abstract} \end{frontmatter} \section{Section1} Start typing... \end{document} ```
Or more simply just download the newest elsarticle.cls from Elsevier ([here](https://www.elsevier.com/__data/assets/text_file/0005/56903/elsarticle.cls)) and explicitly reference it at the beginning of the doc, *ala* ``` \documentclass[review]{./style/elsarticle} ``` Worked perfectly for me.
116,515
I believe I have followed the template exactly but as this following MWE shows I am getting an asterisk on both authors and not just the corresponding author. Do I have something in the wrong order somewhere? ``` \documentclass[preprint,12pt]{elsarticle} \begin{document} \begin{frontmatter} \title{Title} \author{Author One\corref{cor1}\fnref{fn1}} \ead{[email protected]} \cortext[cor1]{Corresponding author} \fntext[fn1]{Student} \author{Author Two\fnref{fn2}} \ead{[email protected]} \fntext[fn2]{Lecturer} \address{Address Here} \begin{abstract} Abstract abstract abstract \end{abstract} \end{frontmatter} \section{Section1} Start typing... \end{document} ``` Thanks
2013/05/28
[ "https://tex.stackexchange.com/questions/116515", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/31396/" ]
Just add a \corrref to every author (with different labels) and just call the author you need. ``` \author{J.~Martinez} \author{F.~Julio\corref{cor1}} \ead{[email protected]} \author{N.~Vasquez\corref{cor2}} \author{H.~Cardenas\corref{cor2}} \cortext[cor1]{Corresponding author} ```
Or more simply just download the newest elsarticle.cls from Elsevier ([here](https://www.elsevier.com/__data/assets/text_file/0005/56903/elsarticle.cls)) and explicitly reference it at the beginning of the doc, *ala* ``` \documentclass[review]{./style/elsarticle} ``` Worked perfectly for me.
31,630,596
So when given two lists, how do I remove elements in one list from another using only map, filter or foldr? I can't use explicit recursion or lambda either. The lists consist of only numbers that are sorted in ascending order. For example, if given (list 1 2 3) and (list 1 3 5), I want to remove all of the second list's elements from the first list. The output I want is (list 2). If given (list 4 5 6) and (list 2 3 5), I would get (list 4 6). I'm guessing the final code would be something like: ``` (define (fn-name list-one list-two) (filter ... list-one)) ``` Thanks!
2015/07/25
[ "https://Stackoverflow.com/questions/31630596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5156104/" ]
Given that you're using Racket, we can write a simple solution in terms of some of the built-in abstract list functions and without using explicit `lambda`s, we only need a little help from [`SRFI-26`](http://docs.racket-lang.org/srfi/srfi-std/srfi-26.html). Try this: ``` (require srfi/26) (define (difference lst1 lst2) (filter-not (cut member <> lst2) lst1)) ``` It works as expected: ``` (difference (list 1 2 3) (list 1 3 5)) => '(2) (difference (list 4 5 6) (list 2 3 5)) => '(4 6) ```
You use filter, but you have to curry and invert `member` so you cannot do it without `lambda`. ```scheme (define (remove-elements needles haystack) (filter (lambda (x) (not (member ...))) haystack)) (define (remove-elements needles haystack) (define (not-in-needles x) (not (member ...))) (filter not-in-needles haystack)) ``` Both of these use `lambda` twice! Once for the `define` of `remove-elements` and once explicit / in `not-in-needles`. In your own example you use `lambda` once too since `(define (name . args) . body)` is the same as `(define name (lambda args . body))`
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
Updating the config.yml with a dumb character (newline, white space) remove that error. It seems that by doing that, we force the cache do be re-generated. (Symfony 3.0.0)
maybe is too late but... what worked for me: ``` php composer.phar install php app/console cache:clear php app/console cache:warmup ```
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
If clearing the cache or dumping the assets doesn't work. Try noisebleed's comment: ``` // app/config_dev.yml assetic: use_controller: true bundles: ['FooBarBundle'] ```
maybe is too late but... what worked for me: ``` php composer.phar install php app/console cache:clear php app/console cache:warmup ```
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
Faced with the same issue but reason was I name template as "something.twig", not "something.html.twig". Its seems assetic not scan templates without .html in extension. As result - template work, but assetic not perform dumping/adding routes for assets from it. Adding .html solve the problem.
maybe is too late but... what worked for me: ``` php composer.phar install php app/console cache:clear php app/console cache:warmup ```
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
Updating the config.yml with a dumb character (newline, white space) remove that error. It seems that by doing that, we force the cache do be re-generated. (Symfony 3.0.0)
After trying all the suggested solutions here, to me it was simply the issue with the name of the template. I had `.twig` but not `.html.twig` extension, that's all.
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
Faced with the same issue but reason was I name template as "something.twig", not "something.html.twig". Its seems assetic not scan templates without .html in extension. As result - template work, but assetic not perform dumping/adding routes for assets from it. Adding .html solve the problem.
I encountered this issue in Symfony 3.3 after trying to override my Twig templates directory. Not sure how to fix the issue, but reverting to default templates directory config resolved the issue for now. ``` # config.yml twig: paths: ["%kernel.project_dir%/templates"] # Remove this line to use default dir ```
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
I had this problem just one minute ago. Clean up the cache worked for me: ``` app/console cache:clear --env=prod ``` Hope this helps.
Updating the config.yml with a dumb character (newline, white space) remove that error. It seems that by doing that, we force the cache do be re-generated. (Symfony 3.0.0)
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
Maybe you have removed the assetic routing from the app/routing\_dev.yml ``` _assetic: resource: . type: assetic ```
I encountered this issue in Symfony 3.3 after trying to override my Twig templates directory. Not sure how to fix the issue, but reverting to default templates directory config resolved the issue for now. ``` # config.yml twig: paths: ["%kernel.project_dir%/templates"] # Remove this line to use default dir ```
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
Faced with the same issue but reason was I name template as "something.twig", not "something.html.twig". Its seems assetic not scan templates without .html in extension. As result - template work, but assetic not perform dumping/adding routes for assets from it. Adding .html solve the problem.
Like @Marcus said, if you tried: ``` php bin/console cache:clear ``` and it didn't help, please clear the `your_project_root/var/cache` folder manually (remove all folders and files). If you use unix/linux systems, and receive a system message like "Error removing file: Permission denied", you need to change accesses to dir first, for example you can use console command ``` sudo chmod -R 0777 /your_site_directory/var/cache/ ``` and after this you can clear cache dir.
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
If clearing the cache or dumping the assets doesn't work. Try noisebleed's comment: ``` // app/config_dev.yml assetic: use_controller: true bundles: ['FooBarBundle'] ```
Like @Marcus said, if you tried: ``` php bin/console cache:clear ``` and it didn't help, please clear the `your_project_root/var/cache` folder manually (remove all folders and files). If you use unix/linux systems, and receive a system message like "Error removing file: Permission denied", you need to change accesses to dir first, for example you can use console command ``` sudo chmod -R 0777 /your_site_directory/var/cache/ ``` and after this you can clear cache dir.
11,462,673
This question seems to have been asked multiple times but none of the solutions work for me. I'm in my prod environment, here is what I've done: * cleared cache before/after doing anything * attempted commenting out the \_assetic stuff in config\_dev and ensure it isn't anywhere else (not that this should matter in prod env) * set use\_controller to both true and false (obviously works with true but doesn't use the compiled files) Is there anything else I'm missing? The files are generating completely fine from `php app/console assetic:dump --env=prod --no-debug` the file name matches that of in the error minus the route stuff.
2012/07/13
[ "https://Stackoverflow.com/questions/11462673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062936/" ]
I had this problem just one minute ago. Clean up the cache worked for me: ``` app/console cache:clear --env=prod ``` Hope this helps.
Like @Marcus said, if you tried: ``` php bin/console cache:clear ``` and it didn't help, please clear the `your_project_root/var/cache` folder manually (remove all folders and files). If you use unix/linux systems, and receive a system message like "Error removing file: Permission denied", you need to change accesses to dir first, for example you can use console command ``` sudo chmod -R 0777 /your_site_directory/var/cache/ ``` and after this you can clear cache dir.
37,741,945
I am getting strange issue while loading image using universal image loader. I want to display image with all corners rounded, but output image is not displaying as per requirement. Below is my code in adapter item xml - ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:id="@+id/container_rl" android:background="@color/transparent_color" android:layout_height="300dp"> <ImageView android:id="@+id/object_iv" android:scaleType="fitXY" android:adjustViewBounds="true" android:layout_width="match_parent" android:layout_height="match_parent" /> <View android:background="@drawable/rounded_corner_bg" android:layout_width="match_parent" android:layout_height="match_parent"/> <TextView android:id="@+id/name_tv" android:layout_centerInParent="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="@dimen/space_20" android:layout_marginRight="@dimen/space_20" android:text="@string/app_name" android:textColor="@color/white" android:textSize="@dimen/size_18"/> </RelativeLayout> ``` Here is code in adapter - ``` ImageLoaderUniversal.ImageLoadWithRoundedCorners(mContext,ImageURI, mFeedIV); ``` and at last code for load image - ``` public static void ImageLoadWithRoundedCorners(Context mContext,final String URl, final ImageView imageView){ DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.mipmap.ic_default_media) .showImageForEmptyUri(R.mipmap.ic_default_media) .showImageOnFail(R.mipmap.ic_default_media) .cacheOnDisk(true) .displayer(new RoundedBitmapDisplayer(25)) .build(); ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(mContext).defaultDisplayImageOptions( options).memoryCache(new WeakMemoryCache()); ImageLoaderConfiguration config = builder.build(); imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) { imageLoader.init(config.createDefault(mContext)); } imageLoader.displayImage(URl, imageView, options); } ``` Add here is scrren shot attached of how images are displaying using above code. Please provide your solution on my problem. TIA
2016/06/10
[ "https://Stackoverflow.com/questions/37741945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2254262/" ]
There is no need to delete with the new consumer. Here is what the script outputs when attempting to delete: > > Note that there's no need to delete group metadata for the new consumer as it is automatically deleted when the last member leaves > > > That's the short answer. More details: By "metadata", two things are meant. First, just the information about the consumers and consumer groups that is stored as part of the group membership coordinator. That is automatically removed if all consumers in the group are gone. Second, the consumer group has stored the committed offsets in a Kafka topic (when the new consumer is used. Previously these used to be stored with Zookeeper). That topic is not immediately deleted when the consumer group disappears. If the consumer group reappears again, it will find the previous offsets automatically in this topic. It can choose to use them or ignore them. If the consumer group never reappears, these stored offsets are eventually garbage collected automatically. So in a nutshell, there is no need to delete anything when using the new consumer.
In Kafka 2.5.0, there is a Java API in the `AdminClient` called `deleteConsumerGroups` which can be used to delete individual ConsumerGroups. You can use it as shown below: ```java import java.util.Arrays; import java.util.Properties; import java.util.concurrent.ExecutionException; import org.apache.kafka.clients.admin.*; import org.apache.kafka.common.KafkaFuture; public class DeleteConsumerGroups { public static void main(String[] args) { System.out.println("*** Starting AdminClient to delete a Consumer Group ***"); final Properties properties = new Properties(); properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); properties.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, "1000"); properties.put(AdminClientConfig.DEFAULT_API_TIMEOUT_MS_CONFIG, "5000"); AdminClient adminClient = AdminClient.create(properties); String consumerGroupToBeDeleted = "console-consumer-65092"; DeleteConsumerGroupsResult deleteConsumerGroupsResult = adminClient.deleteConsumerGroups(Arrays.asList(consumerGroupToBeDeleted)); KafkaFuture<Void> resultFuture = deleteConsumerGroupsResult.all(); try { resultFuture.get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } adminClient.close(); } } ```
22,016
I always encounter such a position: ``` [FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"] [StartPly "11"] 1. d4 d5 2. Nf3 e6 3. h3 Nf6 4. e3 Be7 5. Bd3 O-O 6. c4 Nbd7 7. c5 c6 8. b4 b6 9. Bd2 a5 10. bxa5 bxa5 11. O-O Ne4 12. Bxe4 dxe4 13. Nh2 Nf6 14. Qe1 a4 15. Bb4 Ba6 16. Nc3 Bxf1 17. Nxf1 Rb8 18. a3 Ra8 19. Qd1 Qc7 20. Nxa4 Rfd8 21. Nb6 Ra7 22. Nd2 Nd5 23. Nxe4 Nxb4 24. axb4 Rxa1 25. Qxa1 f5 26. Nc3 Bf6 27. Qa2 Kf7 28. g3 g6 29. Kg2 Qb7 30. Ne2 Qc7 31. Nf4 Rb8 32. Qxe6+ Kg7 33. g4 fxg4 34. hxg4 Bxd4 35. exd4 Qxf4 36. Qd7+ Kh6 37. f3 Qd2+ 38. Kg3 Qxb4 39. Kf4 Rf8+ 40. Kg3 Qe1+ 41. Kg2 Qe2+ 42. Kg1 Rxf3 43. Qxc6 Rf1# ``` Stockfish recommends 6.. dxc4, while I played Nbd7. Why makes dxc4 better?
2018/07/10
[ "https://chess.stackexchange.com/questions/22016", "https://chess.stackexchange.com", "https://chess.stackexchange.com/users/13544/" ]
It is really a matter of taste over "better". I like the tempo gain that dxc4 gives. Usually the pawn is on c4 before Bf1-d3, but when Bf1 develops, as in your game, it loses time capturing on c4. Additionally, the Bishop sucks on c4 and will likely move yet again. Black will have time to play c5 with a nice game.
I agree with Ywapom's answer. Will only add that it's better to keep the tension for a while and only take once you think white can favorably go c4-c5 or cxd5. Thus I'd prefer going ...c5 first and only later taking on c4.
22,016
I always encounter such a position: ``` [FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"] [StartPly "11"] 1. d4 d5 2. Nf3 e6 3. h3 Nf6 4. e3 Be7 5. Bd3 O-O 6. c4 Nbd7 7. c5 c6 8. b4 b6 9. Bd2 a5 10. bxa5 bxa5 11. O-O Ne4 12. Bxe4 dxe4 13. Nh2 Nf6 14. Qe1 a4 15. Bb4 Ba6 16. Nc3 Bxf1 17. Nxf1 Rb8 18. a3 Ra8 19. Qd1 Qc7 20. Nxa4 Rfd8 21. Nb6 Ra7 22. Nd2 Nd5 23. Nxe4 Nxb4 24. axb4 Rxa1 25. Qxa1 f5 26. Nc3 Bf6 27. Qa2 Kf7 28. g3 g6 29. Kg2 Qb7 30. Ne2 Qc7 31. Nf4 Rb8 32. Qxe6+ Kg7 33. g4 fxg4 34. hxg4 Bxd4 35. exd4 Qxf4 36. Qd7+ Kh6 37. f3 Qd2+ 38. Kg3 Qxb4 39. Kf4 Rf8+ 40. Kg3 Qe1+ 41. Kg2 Qe2+ 42. Kg1 Rxf3 43. Qxc6 Rf1# ``` Stockfish recommends 6.. dxc4, while I played Nbd7. Why makes dxc4 better?
2018/07/10
[ "https://chess.stackexchange.com/questions/22016", "https://chess.stackexchange.com", "https://chess.stackexchange.com/users/13544/" ]
It is really a matter of taste over "better". I like the tempo gain that dxc4 gives. Usually the pawn is on c4 before Bf1-d3, but when Bf1 develops, as in your game, it loses time capturing on c4. Additionally, the Bishop sucks on c4 and will likely move yet again. Black will have time to play c5 with a nice game.
If you're going to take on c4, wait until White's moved his light-squared bishop. This forces White to waste a tempo taking back since he'll be moving the bishop twice. So in that position, what Stockfish says to do is fine. After taking, you'd aim to follow up with ...c5 soon, with the aim of liquidating the centre. That being said, you don't have to take on c4 in the first place. Another move in the position you posted is playing 6...b6, stopping any c5 ideas from White and preparing to push ...c5 yourself. A sample line: 6...b6 7.0-0 Bb7 8.Nc3 Nbd7 9.b3 c5! with a level position.
29,527,363
I would like to save an object from one schema to the array in another one. What I have is User schema and Events schema. User schema has, for example, a property "joined" which is array. When making put request, meeting should be pushed to "joined" array. At the moment I have this code on clientside: ``` <div ng-repeat="event in events"> ... <button ng-click="joinEvent(event)">Join</button> </div> $scope.joinEvent = function(event){ $http.put('/join', event) .success(function (data) { $scope.users = data; }) .error(function (data) { console.log('Error: ' + data); }) }; ``` and this this in express.js routes: ``` app.put('/join', function (req, res){ var user = req.user; // logged in user var id = req.user._id; var update = { $addToSet: {joined: req.event} }; User.findByIdAndUpdate(id, update, {upsert: true}, function (err, user) { if (!err) { console.log("joined"); //return all users from db User.find(function(err, users) { if (err) res.send(err) res.json(users); }); } else { if(err.name == 'ValidationError') { res.statusCode = 400; res.send({ error: 'Validation error' }); } else { res.statusCode = 500; res.send({ error: 'Server error' }); } console.log('Internal error(%d): %s',res.statusCode,err.message); } }); }); ``` After all, I see 'null' in user.joined. What's wrong with my approach?
2015/04/08
[ "https://Stackoverflow.com/questions/29527363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3423690/" ]
If you are only experiencing this with using the Get-WmiObject cmdlet and Win32\_\* objects, then check out the link below. It's a quick read. <http://powershell.com/cs/blogs/tips/archive/2013/11/26/getting-wmi-intellisense.aspx> One of the comments links to a tool from Microsoft that may add IntelliSense for WMI, but I haven't tested this.
Please download and install following from <http://www.microsoft.com/en-us/download/details.aspx?id=34595>: 1.If your OS is windows 7 x64 - select - Windows6.1-KB2506143-x64.msu file. Else download as per your os version After installation please restart your computer and run PowerShell again. Ctrl + Space will work for intellisense. Cheers!
14,516
In a last round tie between 2 players fighting for top seed in a competition, here is what happened. White had 18 seconds on his clock and black had 26 seconds. Black was winning. At move 56, black made a pawn push which exposed his king to a check by a dark square bishop, thus making the pawn push an illegal move. White did not take note so he raised the bishop and was about to play then he saw that the king was in check, so before he could call 'illegal' black quickly called the 'touch move rule'. Thus implying that white had to move the bishop. According to FIDE rules which call should supersede: Black's 'touch move' or white's 'illegal move'?
2016/05/29
[ "https://chess.stackexchange.com/questions/14516", "https://chess.stackexchange.com", "https://chess.stackexchange.com/users/10397/" ]
In standard play (each player has at least 60 minutes for all the moves) it makes no difference when the illegal moves is spotted the position must be restored to the one before the illegal move even if that was several moves ago. In rapid or blitz Appendix A4 part 2b applies: > > b. An illegal move is completed once the player has pressed his clock. > If the arbiter observes this he shall declare the game lost by the > player, provided the opponent has not made his next move. If the > arbiter does not intervene, the opponent is entitled to claim a win, > provided the opponent has not made his next move. > > > Provided white has not released the bishop on a different square the claim for an illegal move stands and white wins the game. EDIT: As of 1st January 2018 the rules for rapid and blitz have been brought into line with standard rate. In all 3 cases there is a time penalty for the first illegal move (1 minute for blitz and rapid, 2 minutes for standard) and only the second illegal move loses you the game.
From [FIDE's Laws of Chess](http://www.fide.com/component/handbook/?view=article&id=171) 7.5 > > a. If during a game it is found that an illegal move has been > completed, the position immediately before the irregularity shall be > reinstated. If the position immediately before the irregularity cannot > be determined, the game shall continue from the last identifiable > position prior to the irregularity. Articles 4.3 and 4.7 apply to the > move replacing the illegal move. The game shall then continue from > this reinstated position. If the player has moved a pawn to the > furthest distant rank, pressed the clock, but not replaced the pawn > with a new piece, the move is illegal. The pawn shall be replaced by a > queen of the same colour as the pawn. > > > b. After the action taken under Article 7.5.a, for the first completed > illegal move by a player the arbiter shall give two minutes extra time > to his opponent; for the second completed illegal move by the same > player the arbiter shall declare the game lost by this player. > However, the game is drawn if the position is such that the opponent > cannot checkmate the player’s king by any possible series of legal > moves. > > > Since the illegal move reverts the position back to before the "touch move" would be activated, White never touched the Bishop.
3,269,404
I'm coding a templating system that is supposed to support easily converting any old html/xhtml form into a format that can be used with my system (it's a template system for my cms). Here's what I'm aiming for: 1. The user clicks a "Zone Define" button for example: "Content", "Sidebar", etc 2. When the user hovers any elements they become get a border or are highlighted somehow 3. If the user clicks that element it is modified to have a class like 'zone-content' 4. The page sends the new html to the script via ajax Is there any already existing libraries that would facilitate something like this? UPDATE: I ended up using the answers below and hacking together a jquery solution (we're going to use jquery in the rest of the project). It's a bit ugly and hacky but it works <http://ilsken.com/labs/template/>
2010/07/16
[ "https://Stackoverflow.com/questions/3269404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148766/" ]
I personally am a fan of [ExtJS (now Sencha)](http://www.sencha.com/), and this is fairly simple and straightforward to do using that framework. This is how I'd do it: ``` <body> <button id="content_define" class="zone_define">Content</button> <button id="sidebar_define" class="zone_define">Sidebar</button> <div id="template"> <!-- put your template here --> </div> </body> <script type="text/javascript"> Ext.onReady(function() { Ext.select('button.zone_define').on('click', function(ev, target) { ev.stopEvent(); // this listener is bound to two buttons, determine which one was pressed var zone = target.id.split('_')[0]; // 'content' or 'sidebar' // add a click listener listener to the template so that when an element within is clicked, // an Ajax request is initiated var template = Ext.get('template'); template.addClass('targetable').on('click', function(ev, target) { template.removeClass('targetable'); // this part is optional, in case the user clicks an <a> or <img> element, // you may want to get the block element containing the clicked element var target = ev.getTarget('div'); // or ul, table, p, whatever // invoke zone_capture on the click target (or containing block element) zone_capture(zone, target); }, window, {single: true}); // the {single: true} part removes this listener after one click, // so the user has to go back and press the button again if they want to redefine }); // this is the code to do the ajax request // and also add a class to the target element function zone_capture(zone, target) { // first, remove the class from elements which are already defined as this zone Ext.select(String.format('#template .{0}_zone', zone)).removeClass(zone + '_zone'); // now add that class to the target target.addClass(zone + '_zone'); // do the POST Ext.Ajax.request({ method: 'POST', url: '/region/define', params: { // these are the params POSTed to your script template: Ext.get('template').dom.innerHTML } }); } }); </script> ``` I would also add the following CSS rules for hovering effects, etc. ``` #template.targetable:hover div { /* add div, p, table, whatever */ border: 1px solid #f00; } #template.targetable { cursor: crosshair; } ``` I would call this pseduo-code, but the idea should be enough to get you started. Since you are dealing with user input, you will have a lot of corner cases to check for before you can call this production-ready. It sounds like a cool way to define the template, good luck!
its simple to implement it in jQuery : this simple example how to change an element class when its clicked by the users ``` <script type="text/javascript"> $('a').click(function(){ $(this).attr('class','newClass'); }); //mouseover $('a').mouseover(function(){ $(this).attr('class','newClass'); }); </script> ```
3,269,404
I'm coding a templating system that is supposed to support easily converting any old html/xhtml form into a format that can be used with my system (it's a template system for my cms). Here's what I'm aiming for: 1. The user clicks a "Zone Define" button for example: "Content", "Sidebar", etc 2. When the user hovers any elements they become get a border or are highlighted somehow 3. If the user clicks that element it is modified to have a class like 'zone-content' 4. The page sends the new html to the script via ajax Is there any already existing libraries that would facilitate something like this? UPDATE: I ended up using the answers below and hacking together a jquery solution (we're going to use jquery in the rest of the project). It's a bit ugly and hacky but it works <http://ilsken.com/labs/template/>
2010/07/16
[ "https://Stackoverflow.com/questions/3269404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148766/" ]
I personally am a fan of [ExtJS (now Sencha)](http://www.sencha.com/), and this is fairly simple and straightforward to do using that framework. This is how I'd do it: ``` <body> <button id="content_define" class="zone_define">Content</button> <button id="sidebar_define" class="zone_define">Sidebar</button> <div id="template"> <!-- put your template here --> </div> </body> <script type="text/javascript"> Ext.onReady(function() { Ext.select('button.zone_define').on('click', function(ev, target) { ev.stopEvent(); // this listener is bound to two buttons, determine which one was pressed var zone = target.id.split('_')[0]; // 'content' or 'sidebar' // add a click listener listener to the template so that when an element within is clicked, // an Ajax request is initiated var template = Ext.get('template'); template.addClass('targetable').on('click', function(ev, target) { template.removeClass('targetable'); // this part is optional, in case the user clicks an <a> or <img> element, // you may want to get the block element containing the clicked element var target = ev.getTarget('div'); // or ul, table, p, whatever // invoke zone_capture on the click target (or containing block element) zone_capture(zone, target); }, window, {single: true}); // the {single: true} part removes this listener after one click, // so the user has to go back and press the button again if they want to redefine }); // this is the code to do the ajax request // and also add a class to the target element function zone_capture(zone, target) { // first, remove the class from elements which are already defined as this zone Ext.select(String.format('#template .{0}_zone', zone)).removeClass(zone + '_zone'); // now add that class to the target target.addClass(zone + '_zone'); // do the POST Ext.Ajax.request({ method: 'POST', url: '/region/define', params: { // these are the params POSTed to your script template: Ext.get('template').dom.innerHTML } }); } }); </script> ``` I would also add the following CSS rules for hovering effects, etc. ``` #template.targetable:hover div { /* add div, p, table, whatever */ border: 1px solid #f00; } #template.targetable { cursor: crosshair; } ``` I would call this pseduo-code, but the idea should be enough to get you started. Since you are dealing with user input, you will have a lot of corner cases to check for before you can call this production-ready. It sounds like a cool way to define the template, good luck!
In plain old jQuery, let's see if I get your question. First, some markup: ``` <div id="header"></div> <div id="sidebar"></div> <div id="main"> <div class="moveable-element"> <ul class="content-panel"> <li><a href="#" id="header">Header</a></li> <li><a href="#" id="sidebar">Sidebar</a></li> <li><a href="#" id="main">Main</a></li> <li><a href="#" id="footer">Footer</a></li> </ul> <p>This is content in the moveable-element.</p> </div> </div> <div id="footer"></div> ``` And the jQuery script (something like this): ``` $(function() { $('.moveable-element').hover(function() { $(this).find('.content-panel').show(); $(this).css('border', '1px solid red'); }, function() { $(this).find('.content-panel').hide(); $(this).css('border', '1px solid black'); } $('.content-panel a').click(function() { var class_name = $(this).attr("id"); $(this).parents('.moveable-element').appendTo($('#'+class_name)); } } ``` And some parts of the CSS: ``` .content-panel {display: none; position: absolute;} .moveable-element {border: 1px solid black; position: relative} ``` **NOTE**: I don't see the purpose of the AJAX in your question, please clarify. Also, this is very rough and for informational purposes, please don't expect it to work out of the box as is. If you want me to revise it though, I'd be happy to, just ask.
3,269,404
I'm coding a templating system that is supposed to support easily converting any old html/xhtml form into a format that can be used with my system (it's a template system for my cms). Here's what I'm aiming for: 1. The user clicks a "Zone Define" button for example: "Content", "Sidebar", etc 2. When the user hovers any elements they become get a border or are highlighted somehow 3. If the user clicks that element it is modified to have a class like 'zone-content' 4. The page sends the new html to the script via ajax Is there any already existing libraries that would facilitate something like this? UPDATE: I ended up using the answers below and hacking together a jquery solution (we're going to use jquery in the rest of the project). It's a bit ugly and hacky but it works <http://ilsken.com/labs/template/>
2010/07/16
[ "https://Stackoverflow.com/questions/3269404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148766/" ]
In plain old jQuery, let's see if I get your question. First, some markup: ``` <div id="header"></div> <div id="sidebar"></div> <div id="main"> <div class="moveable-element"> <ul class="content-panel"> <li><a href="#" id="header">Header</a></li> <li><a href="#" id="sidebar">Sidebar</a></li> <li><a href="#" id="main">Main</a></li> <li><a href="#" id="footer">Footer</a></li> </ul> <p>This is content in the moveable-element.</p> </div> </div> <div id="footer"></div> ``` And the jQuery script (something like this): ``` $(function() { $('.moveable-element').hover(function() { $(this).find('.content-panel').show(); $(this).css('border', '1px solid red'); }, function() { $(this).find('.content-panel').hide(); $(this).css('border', '1px solid black'); } $('.content-panel a').click(function() { var class_name = $(this).attr("id"); $(this).parents('.moveable-element').appendTo($('#'+class_name)); } } ``` And some parts of the CSS: ``` .content-panel {display: none; position: absolute;} .moveable-element {border: 1px solid black; position: relative} ``` **NOTE**: I don't see the purpose of the AJAX in your question, please clarify. Also, this is very rough and for informational purposes, please don't expect it to work out of the box as is. If you want me to revise it though, I'd be happy to, just ask.
its simple to implement it in jQuery : this simple example how to change an element class when its clicked by the users ``` <script type="text/javascript"> $('a').click(function(){ $(this).attr('class','newClass'); }); //mouseover $('a').mouseover(function(){ $(this).attr('class','newClass'); }); </script> ```
5,557,650
How can I get a `pchart` in a specific location on my HTML page? right now when I follow the example and use ``` $myPicture->autoOutput(); ``` It just overwrites my entire page and just shows the graph. Looking at the `pChart` source I found inside `pImage.class.php` a relevant function ``` function stroke() { if ( $this->TransparentBackground ) { imagealphablending($this->Picture,false); imagesavealpha($this->Picture,true); } header('Content-type: image/png'); imagepng($this->Picture); } ``` I tried to change it to this but it seems to return null and I'm getting a bunch of errors about > > Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename in\*\* > > > ``` function stroke() { ob_start(NULL,4096); $this->Picture; header('Content-type: text/html'); return base64_encode(ob_get_clean(); } ```
2011/04/05
[ "https://Stackoverflow.com/questions/5557650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/391986/" ]
the easiest way is to split your project into 2 seperate files. One file holds your webpage and the other creates the image (chart). Let's name the second files chart.php As you mentioned, it outputs only an image. What you need to do, is to embed this file into the first one, which holds the webpage. Add `<img src="chart.php" width="x" height="y" />` within your html code. HtH, Thor
I got it working, I extended the pImage class so I added the following function: ``` function strokeToBase64() { ob_start(); imagepng($this->Picture); $contents = ob_get_contents(); ob_end_clean(); return base64_encode($contents); } ``` Then the PHP code that uses the pChart lib invokes the function like this: ``` echo $myPicture->strokeToBase64(); ``` In this way I can easily invoke Ajax calls using jQuery in the client side without having to create image files in the server as in the above posts is mentioned.
66,844,013
I have installed PHPUnit globally and set up an environment variable "path" by, so it runs by command `phpunit.phar` I created a file with a custom function in the "app" folder: ``` function is_id_term(string $q, &$id = null, string $name = 'id'): bool { ... ... ... ... ... } ``` After that I added at the autoload section in the composer.json file in the following line: ``` "files": [ "./app/functions.php" ] ``` Then I ran the command: ``` composer dump-autoload ``` Then created unit test in a `tests/unit/` folder: ``` namespace Tests\Unit; use PHPUnit\Framework\TestCase; class IsIdTermTest extends TestCase { public function testOne() { $res = is_id_term('id: 1'); $this->assertTrue($res); } public function testString() { $res = is_id_term('id:lucas'); $this->assertFalse($res); } } ``` If I run these tests using the green button in the upper right corner of PhpStorm, I get the following error: ``` C:\localserver\php8.0.2\php.exe C:\Users\webgr\AppData\Roaming\Composer\vendor\laravel\installer\bin\phpunit.phar --no-configuration C:\Users\webgr\projects\my-blog\tests --teamcity --cache-result-file=C:\Users\webgr\projects\my-blog\.phpunit.result.cache Testing started at 19:00 ... PHPUnit 9.5.4 by Sebastian Bergmann and contributors. Error : Call to undefined function Tests\Unit\is_id_term() C:\Users\webgr\projects\my-blog\tests\Unit\IsIdTermTest.php:11 ``` After starting the test using the green button, file appears in the root folder of the project .phpunit.result.cache with this content ``` C:37:"PHPUnit\Runner\DefaultTestResultCache":230:{a:2:{s:7:"defects";a:2:{s:32:"Tests\Unit\IsIdTermTest::testOne";i:4;s:35:"Tests\Unit\IsIdTermTest::testString";i:4;}s:5:"times";a:2:{s:32:"Tests\Unit\IsIdTermTest::testOne";d:0.004;s:35:"Tests\Unit\IsIdTermTest::testString";d:0;}}} ``` But, if I execute the command in terminal: ``` phpunit.phar ``` then all tests pass without errors. In the same way, PhpStorm finds this function without problems if I click on its name while in some other file. Can you please tell me how to set up PhpStorm? And what is my mistake?
2021/03/28
[ "https://Stackoverflow.com/questions/66844013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11299996/" ]
`robots` is a `list` of `dictionaries`, so try the following 1. Iterate over dictionaries in the list `robots` 2. Iterate over keys in each `dictionary` 3. Get value of each `key` in dictionary, convert them to lowercase using `.lower()` 4. Save key and value in a new dictionary, append it to the new list This should do it: ```py robots = [ {'name': 'ABB', 'short': 'ABB'}, {'name': 'Techman Robots', 'short': 'TM'}, {'name': 'Mobile Industry Robots', 'short': 'MIR'}, ] new_robots = [] for mdict in robots: new_dict = {} for key, value in mdict.items(): new_dict[key] = value.lower() new_robots.append(new_dict) print(robots) ``` **or in one line** ``` new_robots = [{key: value.lower() for key, value in mdict.items()} for mdict in robots] ``` **Output:** ``` [{'name': 'abb', 'short': 'abb'}, {'name': 'techman robots', 'short': 'tm'}, {'name': 'mobile industry robots', 'short': 'mir'}] ```
Got this working with ast: ``` import ast @app.get('/robots') def get_courses(lower: Optional[int] = None): cs = robots if lower == 1: cs = [] for c in robots: finallyWorking= ast.literal_eval(str(c).lower()) cs.append(finallyWorking) return {'Robots': cs} ```
5,941,771
Hy! The DateTime.toString() gives 12 hours more back as in the debugger written. Do i need CultureInfo? (in austria we are used to count from 0 - 24 for the hours) thx My Code: ``` DateTime dtime = new DateTime(1900, 1, 1, Convert.ToInt32(tim2.hour), Convert.ToInt32(tim2.minute), Convert.ToInt32(tim2.second)); label2.Text = dtime.ToString ("hh:mm:ss.F"); ``` Debugger: ``` + dtime {01.01.1900 00:05:48} System.DateTime + label2.Text "12:05:48" string ```
2011/05/09
[ "https://Stackoverflow.com/questions/5941771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547995/" ]
`hh` is a 12 hour format (i.e. 0:05 is 12:05 AM). It sounds like you want to use `HH` instead, which is a 24 hour format: `label2.Text = dtime.ToString ("HH:mm:ss.F");` Relevant documentation for the formatters can be found [here](http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx).
In [custom date format string](http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx), `hh` displays the hour using 12-hour clock. If you want to have 24-hour clock, use `HH`.
5,941,771
Hy! The DateTime.toString() gives 12 hours more back as in the debugger written. Do i need CultureInfo? (in austria we are used to count from 0 - 24 for the hours) thx My Code: ``` DateTime dtime = new DateTime(1900, 1, 1, Convert.ToInt32(tim2.hour), Convert.ToInt32(tim2.minute), Convert.ToInt32(tim2.second)); label2.Text = dtime.ToString ("hh:mm:ss.F"); ``` Debugger: ``` + dtime {01.01.1900 00:05:48} System.DateTime + label2.Text "12:05:48" string ```
2011/05/09
[ "https://Stackoverflow.com/questions/5941771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547995/" ]
`hh` is a 12 hour format (i.e. 0:05 is 12:05 AM). It sounds like you want to use `HH` instead, which is a 24 hour format: `label2.Text = dtime.ToString ("HH:mm:ss.F");` Relevant documentation for the formatters can be found [here](http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx).
00:05:48 would be 12 Midnight. If you want your time formated with a 24 hour time, then you should use `dtime.ToString('HH:mm:ss.F");`
5,941,771
Hy! The DateTime.toString() gives 12 hours more back as in the debugger written. Do i need CultureInfo? (in austria we are used to count from 0 - 24 for the hours) thx My Code: ``` DateTime dtime = new DateTime(1900, 1, 1, Convert.ToInt32(tim2.hour), Convert.ToInt32(tim2.minute), Convert.ToInt32(tim2.second)); label2.Text = dtime.ToString ("hh:mm:ss.F"); ``` Debugger: ``` + dtime {01.01.1900 00:05:48} System.DateTime + label2.Text "12:05:48" string ```
2011/05/09
[ "https://Stackoverflow.com/questions/5941771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547995/" ]
In [custom date format string](http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx), `hh` displays the hour using 12-hour clock. If you want to have 24-hour clock, use `HH`.
00:05:48 would be 12 Midnight. If you want your time formated with a 24 hour time, then you should use `dtime.ToString('HH:mm:ss.F");`
39,560,299
I have the following query from a podetail table where I calculate the average price for "one" unique item at a time. I need to create a list of "avgUnitCost".Is there a way to use this existing query in a subquery to produce the list of avgUnitCost? ``` SELECT items.`itemName`, SUM(podetails.`qtyReceived`) AS qtyRcvd, SUM(podetails.`qtyReceived` * podetails.`unitCost`) AS totalUnitCost, SUM(podetails.`qtyReceived` * podetails.`unitCost`) / SUM(podetails.`qtyReceived`) AS avgUnitCost FROM podetails, items, purchaseorders WHERE purchaseorders.`poID` = podetails.`poID` AND podetails.`itemID` = items.`itemID` AND podetails.`itemID` = 3;> ```
2016/09/18
[ "https://Stackoverflow.com/questions/39560299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6845864/" ]
[`numericUpAndDown1.Value`](https://msdn.microsoft.com/en-us/library/system.windows.forms.numericupdown.value(v=vs.110).aspx) is of `decimal` type and thus you can't directly store it to `INT` and need a explicit cast ``` private int counter = (int)numericUpAndDown1.Value; ```
Without knowning what the type of numericUpAndDown1.Value property is, you could accomplish this with int.Parse as a quick & dirty solution: ``` private int counter = int.Parse(numericUpAndDown1.Value.ToString()); ``` As suggested in Rahul's answer, you can also try a direct cast in the case where numericUpAndDown1.Value is another numeric type. This can however result in run-time exceptions when the source value is outside of the acceptable range of integer values (less/greater than 2,147,483,647). ``` private int counter = (int)numericUpAndDown1.Value; ``` Since both of these can thrown an exception, you could use the int.TryParse method for safety: ``` private int counter = 0; int.TryParse(numericUpAndDown1.Value.ToString(), out counter); ``` If you can post more code to provide some context, then there may be a better suggestion. **Edit:** The following app demonstrates that a direct-cast from decimal to int will in this case throw an exception: ``` using System; namespace DecimalToIntTest { class Program { static void Main(string[] args) { decimal x = 3000000000; int y = (int)x; Console.WriteLine(y); Console.Read(); } } } ```
11,241,286
While I can access several data using fbgraph api, I couldn't find way to read the "recommendations" data. For example: For the facebook page www.facebook.com/cozycaterers , its recommendation content appearing on right side below cover photo. Could someone please help me. Thanks in advance.
2012/06/28
[ "https://Stackoverflow.com/questions/11241286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361142/" ]
I faced a similar situation now for txt files and did this. ``` File downloadedFile= new File( context.getFilesDir(), "simple.txt" ); downloadedFile.setReadable( true, false ); downloadedFile.setWritable( true, false ); //set read/write for others Uri downloadFileUri = Uri.fromFile( downloadedFile ); Intent intentToEditFile = new Intent( Intent.ACTION_EDIT ); intentToEditFile.setDataAndType( downloadFileUri, "text/plain" ); context.startActivity( intentToEditFile ); ``` Now the 'Document 2 Go' editor will be launched to edit the file and will be able to edit simple.txt Note 1: Uri should be created from same file object that was set with `setReadable()/setWritable`. Note 2: Read/Write permission for other users might not be reflected in file system. Some times I cannot see rw-rw-rw- in adb shell
I believe [ContentProviders](http://developer.android.com/guide/topics/providers/content-providers.html) is your solution. Its the Android recommended method for sharing application data between different apps.
11,241,286
While I can access several data using fbgraph api, I couldn't find way to read the "recommendations" data. For example: For the facebook page www.facebook.com/cozycaterers , its recommendation content appearing on right side below cover photo. Could someone please help me. Thanks in advance.
2012/06/28
[ "https://Stackoverflow.com/questions/11241286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361142/" ]
I faced a similar situation now for txt files and did this. ``` File downloadedFile= new File( context.getFilesDir(), "simple.txt" ); downloadedFile.setReadable( true, false ); downloadedFile.setWritable( true, false ); //set read/write for others Uri downloadFileUri = Uri.fromFile( downloadedFile ); Intent intentToEditFile = new Intent( Intent.ACTION_EDIT ); intentToEditFile.setDataAndType( downloadFileUri, "text/plain" ); context.startActivity( intentToEditFile ); ``` Now the 'Document 2 Go' editor will be launched to edit the file and will be able to edit simple.txt Note 1: Uri should be created from same file object that was set with `setReadable()/setWritable`. Note 2: Read/Write permission for other users might not be reflected in file system. Some times I cannot see rw-rw-rw- in adb shell
<https://stackoverflow.com/a/6708681/804447> Sharing data between apps is what ContentProviders are for. Assuming that you know how to write a ContentProvider and access it, you can access files via ParcelFileDescriptor, which includes constants for the mode in which you create the files. What you need now is to limit access so that not everybody can read the files through the content provider, and you do that via android permissions. In the manifest of one your apps, the one that will host the files and the content provider, write something like this: ``` <permission android:name="com.example.android.provider.ACCESS" android:protectionLevel="signature"/> ``` and in both apps add this: ``` <uses-permission android:name="com.example.android.provider.ACCESS" /> ``` by using protectionLevel="signature", only apps signed by you can access your content provider, and thus your files.
58,316,128
The following code is to count the number of emails in a particular `SharedMailbox` or its `subfolder`. I am having trouble selecting a subfolder in SharedMailbox. I have read a number of resources on GetSharedDefaultFolder including [this one](https://stackoverflow.com/questions/27851850/outlook-selecting-a-subfolder-in-the-sharedmailbox-using-getshareddefaultfolder). However, struggling to put it together correctly. Would be really great if you could help with this. I am experiencing the following error while running the code. > > Run-time error '-2147221233 (80040010f)' Automation error > > > ``` Sub CountInboxSubjects() Dim olApp As Outlook.Application Dim olNs As Outlook.Namespace Dim olFldr As Outlook.MAPIFolder Dim MyFolder1 As Outlook.MAPIFolder Dim MyFolder2 As Outlook.MAPIFolder Dim MyFolder3 As Outlook.MAPIFolder Dim olMailItem As Outlook.MailItem Dim propertyAccessor As Outlook.propertyAccessor Dim olItem As Object Dim dic As Dictionary Dim i As Long Dim Subject As String Dim val1 As Variant Dim val2 As Variant val1 = ThisWorkbook.Worksheets("Data").Range("I2") val2 = ThisWorkbook.Worksheets("Data").Range("I3") Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") 'Set olFldr = olNs.GetDefaultFolder(olFolderInbox) Set olShareName = olNs.CreateRecipient("Shared_MailBox") Set olFldr = olNs.GetSharedDefaultFolder(olShareName, olFolderInbox) MsgBox (olFldr) Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) Set MyFolder2 = MyFolder1.Folders("Sub_Sub_Folder") MsgBox (MyFolder2) Set MyFolder3 = MyFolder1.Folders("Sub_Sub_Folder2") MsgBox (MyFolder3) If ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Inbox" Then MyFolder = olFldr ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Folder" Then MyFolder = MyFolder1 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder2 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder3 End If Set olItem = MyFolder.Items 'Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$("01/01/2019 00:00AM", "General Date") & "' And [ReceivedTime]<'" & Format$("01/02/2019 00:00AM", "General Date") & "'") Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$(val1, "General Date") & "' And [ReceivedTime]<'" & Format$(val2, "General Date") & "'") For Each olItem In myRestrictItems If olItem.Class = olMail Then Set propertyAccessor = olItem.propertyAccessor Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") If dic.Exists(Subject) Then dic(Subject) = dic(Subject) + 1 Else dic(Subject) = 1 End If Next olItem With ActiveSheet .Columns("A:B").Clear .Range("A1:B1").Value = Array("Count", "Subject") For i = 0 To dic.Count - 1 .Cells(i + 2, "A") = dic.Items()(i) .Cells(i + 2, "B") = dic.Keys()(i) Next End With End Sub ``` After trouble-shooting, I am aware the following step has issues. ``` Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) ``` I expect the msgbox will return the subfolder name but it's reporting error. > > Run-time error '-2147221233 (80040010f)' Automation error > > > I couldn't find out why. can anyone please help..
2019/10/10
[ "https://Stackoverflow.com/questions/58316128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12192891/" ]
I've just run into a similar situation. It seemed that `yarn` was only looking in the main Yarn package registry for my organization's private package. I had copied the examples from GitHub's Packages documentation for constructing your `.npmrc` file directly to the `.yarnrc` file in the project that will be consuming the app, not knowing that the formats were different (I've never had to deal with `.yarnrc` files before). However, after updating the `.yarnrc` file with the correct format that you've mentioned above (which I also found in googling around), `yarn` successfully found the private package and installed it correctly. As a heads up, my `yarn` version: **1.17.3** Steps I Took ------------ 1. Start new terminal session 2. `cd` to the project 3. `nvm use` (if you have a specific node version to use) 4. Add the correctly-formatted `.yarnrc` file to the project. See below for what it looks like. 5. Manually add the package and version range to the `package.json` for my private package 6. Run `npm login --registry=https://npm.pkg.github.com --scope=@MyOrg` * See the note below on scope / org gotcha's 7. Run `yarn` That worked for me. ### .yarnrc ``` "@myorg:registry" "https://npm.pkg.github.com" ``` **Note**: See below for a note on the org / scope name gotcha's ### Other Notes I know that it appears that you don't have any issues with this, given your GH username / scope above, but for anyone else that comes here, the documentation on GH is a little sparse with regards to mapping your username / org name to a scope in the package name. Just remember these little gotcha's here: * The name of your package must always be scoped to your org (or username) + E.g., `name: @johndturn/my-package` * If your organization has capital letters in it, like `MyOrg`, just replace them in the name of the package in your `package.json` **and** your `.yarnrc` with lowercase + E.g., `name: @myorg/my-package` + **Note**: When authenticating with `npm login`, I still have kept the uppercase letters in the `--scope=` argument. * The name of your package doesn't have to be the same name of the repo. + E.g., for a repo called `MyOrg/random-prefix.js-lib`, you can have `name: @myorg/js-lib` in your `package.json` file for the project itself. Then, installing it in other projects will look something like `@myorg/js-lib: 1.0.0`.
I'm not an expert with npm/yarn so I might be misunderstanding what is happening here, but I don't think package proxying from the npm registry works with yarn yet. Could that be related? When package proxying was released for npm I remember reading comments on Twitter from people that tried it with yarn and it didn't work. Found the Twitter thread here: <https://twitter.com/github/status/1171832034580451328> > > It doesn't work with Yarn. As soon as I change the registry url -> Couldn't find package. > > >
58,316,128
The following code is to count the number of emails in a particular `SharedMailbox` or its `subfolder`. I am having trouble selecting a subfolder in SharedMailbox. I have read a number of resources on GetSharedDefaultFolder including [this one](https://stackoverflow.com/questions/27851850/outlook-selecting-a-subfolder-in-the-sharedmailbox-using-getshareddefaultfolder). However, struggling to put it together correctly. Would be really great if you could help with this. I am experiencing the following error while running the code. > > Run-time error '-2147221233 (80040010f)' Automation error > > > ``` Sub CountInboxSubjects() Dim olApp As Outlook.Application Dim olNs As Outlook.Namespace Dim olFldr As Outlook.MAPIFolder Dim MyFolder1 As Outlook.MAPIFolder Dim MyFolder2 As Outlook.MAPIFolder Dim MyFolder3 As Outlook.MAPIFolder Dim olMailItem As Outlook.MailItem Dim propertyAccessor As Outlook.propertyAccessor Dim olItem As Object Dim dic As Dictionary Dim i As Long Dim Subject As String Dim val1 As Variant Dim val2 As Variant val1 = ThisWorkbook.Worksheets("Data").Range("I2") val2 = ThisWorkbook.Worksheets("Data").Range("I3") Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") 'Set olFldr = olNs.GetDefaultFolder(olFolderInbox) Set olShareName = olNs.CreateRecipient("Shared_MailBox") Set olFldr = olNs.GetSharedDefaultFolder(olShareName, olFolderInbox) MsgBox (olFldr) Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) Set MyFolder2 = MyFolder1.Folders("Sub_Sub_Folder") MsgBox (MyFolder2) Set MyFolder3 = MyFolder1.Folders("Sub_Sub_Folder2") MsgBox (MyFolder3) If ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Inbox" Then MyFolder = olFldr ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Folder" Then MyFolder = MyFolder1 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder2 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder3 End If Set olItem = MyFolder.Items 'Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$("01/01/2019 00:00AM", "General Date") & "' And [ReceivedTime]<'" & Format$("01/02/2019 00:00AM", "General Date") & "'") Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$(val1, "General Date") & "' And [ReceivedTime]<'" & Format$(val2, "General Date") & "'") For Each olItem In myRestrictItems If olItem.Class = olMail Then Set propertyAccessor = olItem.propertyAccessor Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") If dic.Exists(Subject) Then dic(Subject) = dic(Subject) + 1 Else dic(Subject) = 1 End If Next olItem With ActiveSheet .Columns("A:B").Clear .Range("A1:B1").Value = Array("Count", "Subject") For i = 0 To dic.Count - 1 .Cells(i + 2, "A") = dic.Items()(i) .Cells(i + 2, "B") = dic.Keys()(i) Next End With End Sub ``` After trouble-shooting, I am aware the following step has issues. ``` Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) ``` I expect the msgbox will return the subfolder name but it's reporting error. > > Run-time error '-2147221233 (80040010f)' Automation error > > > I couldn't find out why. can anyone please help..
2019/10/10
[ "https://Stackoverflow.com/questions/58316128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12192891/" ]
The problem I had is slightly different. After tried what John suggested I still can't add private registry packages with `yarn` (but perfectly fine with `npm`) Then I realise two things: For GitHub packages, `npm` is fine with either `registry=https://npm.pkg.github.com/my-org` or `@my-org:registry=https://npm.pkg.github.com` but `yarn` only allow the latter syntax. Docs from Github website only show the first syntax which could cause problems for yarn users. Another thing is that if you `npm login` to the private registry but use a `.yarnrc` file in your project, yarn can't really mix your `npm` credentials with it. Although it seems behave differently on different environment. But it would seems to be a best practice to stick with either `yarn login` + `.yarnrc`, or `npm login` + `.npmrc` (you can still use yarn to manage your packages in both cases)
I'm not an expert with npm/yarn so I might be misunderstanding what is happening here, but I don't think package proxying from the npm registry works with yarn yet. Could that be related? When package proxying was released for npm I remember reading comments on Twitter from people that tried it with yarn and it didn't work. Found the Twitter thread here: <https://twitter.com/github/status/1171832034580451328> > > It doesn't work with Yarn. As soon as I change the registry url -> Couldn't find package. > > >
58,316,128
The following code is to count the number of emails in a particular `SharedMailbox` or its `subfolder`. I am having trouble selecting a subfolder in SharedMailbox. I have read a number of resources on GetSharedDefaultFolder including [this one](https://stackoverflow.com/questions/27851850/outlook-selecting-a-subfolder-in-the-sharedmailbox-using-getshareddefaultfolder). However, struggling to put it together correctly. Would be really great if you could help with this. I am experiencing the following error while running the code. > > Run-time error '-2147221233 (80040010f)' Automation error > > > ``` Sub CountInboxSubjects() Dim olApp As Outlook.Application Dim olNs As Outlook.Namespace Dim olFldr As Outlook.MAPIFolder Dim MyFolder1 As Outlook.MAPIFolder Dim MyFolder2 As Outlook.MAPIFolder Dim MyFolder3 As Outlook.MAPIFolder Dim olMailItem As Outlook.MailItem Dim propertyAccessor As Outlook.propertyAccessor Dim olItem As Object Dim dic As Dictionary Dim i As Long Dim Subject As String Dim val1 As Variant Dim val2 As Variant val1 = ThisWorkbook.Worksheets("Data").Range("I2") val2 = ThisWorkbook.Worksheets("Data").Range("I3") Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") 'Set olFldr = olNs.GetDefaultFolder(olFolderInbox) Set olShareName = olNs.CreateRecipient("Shared_MailBox") Set olFldr = olNs.GetSharedDefaultFolder(olShareName, olFolderInbox) MsgBox (olFldr) Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) Set MyFolder2 = MyFolder1.Folders("Sub_Sub_Folder") MsgBox (MyFolder2) Set MyFolder3 = MyFolder1.Folders("Sub_Sub_Folder2") MsgBox (MyFolder3) If ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Inbox" Then MyFolder = olFldr ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Folder" Then MyFolder = MyFolder1 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder2 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder3 End If Set olItem = MyFolder.Items 'Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$("01/01/2019 00:00AM", "General Date") & "' And [ReceivedTime]<'" & Format$("01/02/2019 00:00AM", "General Date") & "'") Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$(val1, "General Date") & "' And [ReceivedTime]<'" & Format$(val2, "General Date") & "'") For Each olItem In myRestrictItems If olItem.Class = olMail Then Set propertyAccessor = olItem.propertyAccessor Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") If dic.Exists(Subject) Then dic(Subject) = dic(Subject) + 1 Else dic(Subject) = 1 End If Next olItem With ActiveSheet .Columns("A:B").Clear .Range("A1:B1").Value = Array("Count", "Subject") For i = 0 To dic.Count - 1 .Cells(i + 2, "A") = dic.Items()(i) .Cells(i + 2, "B") = dic.Keys()(i) Next End With End Sub ``` After trouble-shooting, I am aware the following step has issues. ``` Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) ``` I expect the msgbox will return the subfolder name but it's reporting error. > > Run-time error '-2147221233 (80040010f)' Automation error > > > I couldn't find out why. can anyone please help..
2019/10/10
[ "https://Stackoverflow.com/questions/58316128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12192891/" ]
I'm not an expert with npm/yarn so I might be misunderstanding what is happening here, but I don't think package proxying from the npm registry works with yarn yet. Could that be related? When package proxying was released for npm I remember reading comments on Twitter from people that tried it with yarn and it didn't work. Found the Twitter thread here: <https://twitter.com/github/status/1171832034580451328> > > It doesn't work with Yarn. As soon as I change the registry url -> Couldn't find package. > > >
In Yarn v2+ the setup has changed quite a bit. ".yarnrc" is ignored and only ".yarnrc.yml" is used. To setup a private registry with a scope and token from env, add something along these lines to the ".yarnrc.yml" file (fontawesome example): ``` npmScopes: fortawesome: npmRegistryServer: "https://npm.fontawesome.com" npmAuthToken: ${FONTAWESOME_TOKEN} ``` Documentation: <https://yarnpkg.com/configuration/yarnrc#npmScopes>
58,316,128
The following code is to count the number of emails in a particular `SharedMailbox` or its `subfolder`. I am having trouble selecting a subfolder in SharedMailbox. I have read a number of resources on GetSharedDefaultFolder including [this one](https://stackoverflow.com/questions/27851850/outlook-selecting-a-subfolder-in-the-sharedmailbox-using-getshareddefaultfolder). However, struggling to put it together correctly. Would be really great if you could help with this. I am experiencing the following error while running the code. > > Run-time error '-2147221233 (80040010f)' Automation error > > > ``` Sub CountInboxSubjects() Dim olApp As Outlook.Application Dim olNs As Outlook.Namespace Dim olFldr As Outlook.MAPIFolder Dim MyFolder1 As Outlook.MAPIFolder Dim MyFolder2 As Outlook.MAPIFolder Dim MyFolder3 As Outlook.MAPIFolder Dim olMailItem As Outlook.MailItem Dim propertyAccessor As Outlook.propertyAccessor Dim olItem As Object Dim dic As Dictionary Dim i As Long Dim Subject As String Dim val1 As Variant Dim val2 As Variant val1 = ThisWorkbook.Worksheets("Data").Range("I2") val2 = ThisWorkbook.Worksheets("Data").Range("I3") Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") 'Set olFldr = olNs.GetDefaultFolder(olFolderInbox) Set olShareName = olNs.CreateRecipient("Shared_MailBox") Set olFldr = olNs.GetSharedDefaultFolder(olShareName, olFolderInbox) MsgBox (olFldr) Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) Set MyFolder2 = MyFolder1.Folders("Sub_Sub_Folder") MsgBox (MyFolder2) Set MyFolder3 = MyFolder1.Folders("Sub_Sub_Folder2") MsgBox (MyFolder3) If ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Inbox" Then MyFolder = olFldr ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Folder" Then MyFolder = MyFolder1 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder2 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder3 End If Set olItem = MyFolder.Items 'Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$("01/01/2019 00:00AM", "General Date") & "' And [ReceivedTime]<'" & Format$("01/02/2019 00:00AM", "General Date") & "'") Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$(val1, "General Date") & "' And [ReceivedTime]<'" & Format$(val2, "General Date") & "'") For Each olItem In myRestrictItems If olItem.Class = olMail Then Set propertyAccessor = olItem.propertyAccessor Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") If dic.Exists(Subject) Then dic(Subject) = dic(Subject) + 1 Else dic(Subject) = 1 End If Next olItem With ActiveSheet .Columns("A:B").Clear .Range("A1:B1").Value = Array("Count", "Subject") For i = 0 To dic.Count - 1 .Cells(i + 2, "A") = dic.Items()(i) .Cells(i + 2, "B") = dic.Keys()(i) Next End With End Sub ``` After trouble-shooting, I am aware the following step has issues. ``` Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) ``` I expect the msgbox will return the subfolder name but it's reporting error. > > Run-time error '-2147221233 (80040010f)' Automation error > > > I couldn't find out why. can anyone please help..
2019/10/10
[ "https://Stackoverflow.com/questions/58316128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12192891/" ]
I've just run into a similar situation. It seemed that `yarn` was only looking in the main Yarn package registry for my organization's private package. I had copied the examples from GitHub's Packages documentation for constructing your `.npmrc` file directly to the `.yarnrc` file in the project that will be consuming the app, not knowing that the formats were different (I've never had to deal with `.yarnrc` files before). However, after updating the `.yarnrc` file with the correct format that you've mentioned above (which I also found in googling around), `yarn` successfully found the private package and installed it correctly. As a heads up, my `yarn` version: **1.17.3** Steps I Took ------------ 1. Start new terminal session 2. `cd` to the project 3. `nvm use` (if you have a specific node version to use) 4. Add the correctly-formatted `.yarnrc` file to the project. See below for what it looks like. 5. Manually add the package and version range to the `package.json` for my private package 6. Run `npm login --registry=https://npm.pkg.github.com --scope=@MyOrg` * See the note below on scope / org gotcha's 7. Run `yarn` That worked for me. ### .yarnrc ``` "@myorg:registry" "https://npm.pkg.github.com" ``` **Note**: See below for a note on the org / scope name gotcha's ### Other Notes I know that it appears that you don't have any issues with this, given your GH username / scope above, but for anyone else that comes here, the documentation on GH is a little sparse with regards to mapping your username / org name to a scope in the package name. Just remember these little gotcha's here: * The name of your package must always be scoped to your org (or username) + E.g., `name: @johndturn/my-package` * If your organization has capital letters in it, like `MyOrg`, just replace them in the name of the package in your `package.json` **and** your `.yarnrc` with lowercase + E.g., `name: @myorg/my-package` + **Note**: When authenticating with `npm login`, I still have kept the uppercase letters in the `--scope=` argument. * The name of your package doesn't have to be the same name of the repo. + E.g., for a repo called `MyOrg/random-prefix.js-lib`, you can have `name: @myorg/js-lib` in your `package.json` file for the project itself. Then, installing it in other projects will look something like `@myorg/js-lib: 1.0.0`.
The problem I had is slightly different. After tried what John suggested I still can't add private registry packages with `yarn` (but perfectly fine with `npm`) Then I realise two things: For GitHub packages, `npm` is fine with either `registry=https://npm.pkg.github.com/my-org` or `@my-org:registry=https://npm.pkg.github.com` but `yarn` only allow the latter syntax. Docs from Github website only show the first syntax which could cause problems for yarn users. Another thing is that if you `npm login` to the private registry but use a `.yarnrc` file in your project, yarn can't really mix your `npm` credentials with it. Although it seems behave differently on different environment. But it would seems to be a best practice to stick with either `yarn login` + `.yarnrc`, or `npm login` + `.npmrc` (you can still use yarn to manage your packages in both cases)
58,316,128
The following code is to count the number of emails in a particular `SharedMailbox` or its `subfolder`. I am having trouble selecting a subfolder in SharedMailbox. I have read a number of resources on GetSharedDefaultFolder including [this one](https://stackoverflow.com/questions/27851850/outlook-selecting-a-subfolder-in-the-sharedmailbox-using-getshareddefaultfolder). However, struggling to put it together correctly. Would be really great if you could help with this. I am experiencing the following error while running the code. > > Run-time error '-2147221233 (80040010f)' Automation error > > > ``` Sub CountInboxSubjects() Dim olApp As Outlook.Application Dim olNs As Outlook.Namespace Dim olFldr As Outlook.MAPIFolder Dim MyFolder1 As Outlook.MAPIFolder Dim MyFolder2 As Outlook.MAPIFolder Dim MyFolder3 As Outlook.MAPIFolder Dim olMailItem As Outlook.MailItem Dim propertyAccessor As Outlook.propertyAccessor Dim olItem As Object Dim dic As Dictionary Dim i As Long Dim Subject As String Dim val1 As Variant Dim val2 As Variant val1 = ThisWorkbook.Worksheets("Data").Range("I2") val2 = ThisWorkbook.Worksheets("Data").Range("I3") Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") 'Set olFldr = olNs.GetDefaultFolder(olFolderInbox) Set olShareName = olNs.CreateRecipient("Shared_MailBox") Set olFldr = olNs.GetSharedDefaultFolder(olShareName, olFolderInbox) MsgBox (olFldr) Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) Set MyFolder2 = MyFolder1.Folders("Sub_Sub_Folder") MsgBox (MyFolder2) Set MyFolder3 = MyFolder1.Folders("Sub_Sub_Folder2") MsgBox (MyFolder3) If ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Inbox" Then MyFolder = olFldr ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Folder" Then MyFolder = MyFolder1 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder2 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder3 End If Set olItem = MyFolder.Items 'Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$("01/01/2019 00:00AM", "General Date") & "' And [ReceivedTime]<'" & Format$("01/02/2019 00:00AM", "General Date") & "'") Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$(val1, "General Date") & "' And [ReceivedTime]<'" & Format$(val2, "General Date") & "'") For Each olItem In myRestrictItems If olItem.Class = olMail Then Set propertyAccessor = olItem.propertyAccessor Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") If dic.Exists(Subject) Then dic(Subject) = dic(Subject) + 1 Else dic(Subject) = 1 End If Next olItem With ActiveSheet .Columns("A:B").Clear .Range("A1:B1").Value = Array("Count", "Subject") For i = 0 To dic.Count - 1 .Cells(i + 2, "A") = dic.Items()(i) .Cells(i + 2, "B") = dic.Keys()(i) Next End With End Sub ``` After trouble-shooting, I am aware the following step has issues. ``` Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) ``` I expect the msgbox will return the subfolder name but it's reporting error. > > Run-time error '-2147221233 (80040010f)' Automation error > > > I couldn't find out why. can anyone please help..
2019/10/10
[ "https://Stackoverflow.com/questions/58316128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12192891/" ]
I've just run into a similar situation. It seemed that `yarn` was only looking in the main Yarn package registry for my organization's private package. I had copied the examples from GitHub's Packages documentation for constructing your `.npmrc` file directly to the `.yarnrc` file in the project that will be consuming the app, not knowing that the formats were different (I've never had to deal with `.yarnrc` files before). However, after updating the `.yarnrc` file with the correct format that you've mentioned above (which I also found in googling around), `yarn` successfully found the private package and installed it correctly. As a heads up, my `yarn` version: **1.17.3** Steps I Took ------------ 1. Start new terminal session 2. `cd` to the project 3. `nvm use` (if you have a specific node version to use) 4. Add the correctly-formatted `.yarnrc` file to the project. See below for what it looks like. 5. Manually add the package and version range to the `package.json` for my private package 6. Run `npm login --registry=https://npm.pkg.github.com --scope=@MyOrg` * See the note below on scope / org gotcha's 7. Run `yarn` That worked for me. ### .yarnrc ``` "@myorg:registry" "https://npm.pkg.github.com" ``` **Note**: See below for a note on the org / scope name gotcha's ### Other Notes I know that it appears that you don't have any issues with this, given your GH username / scope above, but for anyone else that comes here, the documentation on GH is a little sparse with regards to mapping your username / org name to a scope in the package name. Just remember these little gotcha's here: * The name of your package must always be scoped to your org (or username) + E.g., `name: @johndturn/my-package` * If your organization has capital letters in it, like `MyOrg`, just replace them in the name of the package in your `package.json` **and** your `.yarnrc` with lowercase + E.g., `name: @myorg/my-package` + **Note**: When authenticating with `npm login`, I still have kept the uppercase letters in the `--scope=` argument. * The name of your package doesn't have to be the same name of the repo. + E.g., for a repo called `MyOrg/random-prefix.js-lib`, you can have `name: @myorg/js-lib` in your `package.json` file for the project itself. Then, installing it in other projects will look something like `@myorg/js-lib: 1.0.0`.
In Yarn v2+ the setup has changed quite a bit. ".yarnrc" is ignored and only ".yarnrc.yml" is used. To setup a private registry with a scope and token from env, add something along these lines to the ".yarnrc.yml" file (fontawesome example): ``` npmScopes: fortawesome: npmRegistryServer: "https://npm.fontawesome.com" npmAuthToken: ${FONTAWESOME_TOKEN} ``` Documentation: <https://yarnpkg.com/configuration/yarnrc#npmScopes>
58,316,128
The following code is to count the number of emails in a particular `SharedMailbox` or its `subfolder`. I am having trouble selecting a subfolder in SharedMailbox. I have read a number of resources on GetSharedDefaultFolder including [this one](https://stackoverflow.com/questions/27851850/outlook-selecting-a-subfolder-in-the-sharedmailbox-using-getshareddefaultfolder). However, struggling to put it together correctly. Would be really great if you could help with this. I am experiencing the following error while running the code. > > Run-time error '-2147221233 (80040010f)' Automation error > > > ``` Sub CountInboxSubjects() Dim olApp As Outlook.Application Dim olNs As Outlook.Namespace Dim olFldr As Outlook.MAPIFolder Dim MyFolder1 As Outlook.MAPIFolder Dim MyFolder2 As Outlook.MAPIFolder Dim MyFolder3 As Outlook.MAPIFolder Dim olMailItem As Outlook.MailItem Dim propertyAccessor As Outlook.propertyAccessor Dim olItem As Object Dim dic As Dictionary Dim i As Long Dim Subject As String Dim val1 As Variant Dim val2 As Variant val1 = ThisWorkbook.Worksheets("Data").Range("I2") val2 = ThisWorkbook.Worksheets("Data").Range("I3") Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") 'Set olFldr = olNs.GetDefaultFolder(olFolderInbox) Set olShareName = olNs.CreateRecipient("Shared_MailBox") Set olFldr = olNs.GetSharedDefaultFolder(olShareName, olFolderInbox) MsgBox (olFldr) Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) Set MyFolder2 = MyFolder1.Folders("Sub_Sub_Folder") MsgBox (MyFolder2) Set MyFolder3 = MyFolder1.Folders("Sub_Sub_Folder2") MsgBox (MyFolder3) If ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Inbox" Then MyFolder = olFldr ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Folder" Then MyFolder = MyFolder1 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder2 ElseIf ThisWorkbook.Worksheets("EPI_Data").Range("I5") = "Sub_Sub_Folder" Then MyFolder = MyFolder3 End If Set olItem = MyFolder.Items 'Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$("01/01/2019 00:00AM", "General Date") & "' And [ReceivedTime]<'" & Format$("01/02/2019 00:00AM", "General Date") & "'") Set myRestrictItems = olItem.Restrict("[ReceivedTime]>'" & Format$(val1, "General Date") & "' And [ReceivedTime]<'" & Format$(val2, "General Date") & "'") For Each olItem In myRestrictItems If olItem.Class = olMail Then Set propertyAccessor = olItem.propertyAccessor Subject = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1D001E") If dic.Exists(Subject) Then dic(Subject) = dic(Subject) + 1 Else dic(Subject) = 1 End If Next olItem With ActiveSheet .Columns("A:B").Clear .Range("A1:B1").Value = Array("Count", "Subject") For i = 0 To dic.Count - 1 .Cells(i + 2, "A") = dic.Items()(i) .Cells(i + 2, "B") = dic.Keys()(i) Next End With End Sub ``` After trouble-shooting, I am aware the following step has issues. ``` Set MyFolder1 = olFldr.Folders("Sub_Folder") MsgBox (MyFolder1) ``` I expect the msgbox will return the subfolder name but it's reporting error. > > Run-time error '-2147221233 (80040010f)' Automation error > > > I couldn't find out why. can anyone please help..
2019/10/10
[ "https://Stackoverflow.com/questions/58316128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12192891/" ]
The problem I had is slightly different. After tried what John suggested I still can't add private registry packages with `yarn` (but perfectly fine with `npm`) Then I realise two things: For GitHub packages, `npm` is fine with either `registry=https://npm.pkg.github.com/my-org` or `@my-org:registry=https://npm.pkg.github.com` but `yarn` only allow the latter syntax. Docs from Github website only show the first syntax which could cause problems for yarn users. Another thing is that if you `npm login` to the private registry but use a `.yarnrc` file in your project, yarn can't really mix your `npm` credentials with it. Although it seems behave differently on different environment. But it would seems to be a best practice to stick with either `yarn login` + `.yarnrc`, or `npm login` + `.npmrc` (you can still use yarn to manage your packages in both cases)
In Yarn v2+ the setup has changed quite a bit. ".yarnrc" is ignored and only ".yarnrc.yml" is used. To setup a private registry with a scope and token from env, add something along these lines to the ".yarnrc.yml" file (fontawesome example): ``` npmScopes: fortawesome: npmRegistryServer: "https://npm.fontawesome.com" npmAuthToken: ${FONTAWESOME_TOKEN} ``` Documentation: <https://yarnpkg.com/configuration/yarnrc#npmScopes>
638,042
When doing ``` grep index.html /var/log/apache2/other_vhosts_access.log | awk '{print $1 $13}' ``` we have a whitespace delimiter by default. **How to have both `"` and as delimiters:** ``` www.example.com:443 1.2.3.4 - - [01/Feb/2021:15:07:35 +0100] "GET /index.html HTTP/1.1" 200 8317 "https://www.example.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36" ``` **such as we can get both the IP and the user-agent with `awk`?** Using `awk -F'["]'` didn't seem to work. The expected parsing should be: ``` www.example.com:443 1.2.3.4 - - [01/Feb/2021:15:07:35 +0100] "GET /index.html HTTP/1.1" 200 8317 "https://www.example.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36" ```
2021/03/07
[ "https://unix.stackexchange.com/questions/638042", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/59989/" ]
You need to include the space in your character class: ``` echo 'word1 word2"word2 word4"word5' | awk -F '[ "]' '{ for (i = 1; i <= NF; ++i) { print $i } }' ```
You want the IP address and the user agent. The IP address is the second whitespace-delimited word. It will be in `$2` in `awk` with the default value of `FS`. The user agent is the string in the last double quoted substring. You can get at that by deleting the last double quote, and then deleting everything up to what's now the last double quote. With `awk`: ``` awk '{ ip = $2; sub("\"$",""); sub(".*\"",""); ua = $0; print ip; print ua }' ``` or, slightly shorter, ``` awk '{ ip = $2; sub("\"$",""); sub(".*\"",""); print ip; print }' ``` With `sed`: ``` sed -e 'h' -e 's/[^ ]* //;s/ .*//p' \ -e 'g' -e 's/"$//;s/.*"//' ``` This first saves the line in the hold space (`h`), then extracts the IP number by deleting up to the first space and then from the (now) first space. This isolates the IP number, which is printed. Then the saved line is retrieved (`g`) and the same procedure as in the `awk` code is applied, i.e. delete the last double quote, and then everything up to the (now) last double quote. Both commands print the IP number on one line, followed by the user agent string on the next.
28,594,568
We have GA data in Big query, and some of my users want to join that to in house data in Hadoop which we can not move to Big Query. Please let me know what is the best way to do this.
2015/02/18
[ "https://Stackoverflow.com/questions/28594568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4572433/" ]
You can use [Integer.parseInt(String, int)](http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#parseInt-java.lang.String-int-) to convert a String representing binary data to an int: ``` int value = Integer.parseInt("111111110000000010101010", 2); ``` You can then shift using the [bit shift operators](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html): > > The signed left shift operator "<<" shifts a bit pattern to the left, and the signed right shift operator ">>" shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension. > > >
An alternative is to use [Java 7's binary literal notation](http://docs.oracle.com/javase/7/docs/technotes/guides/language/binary-literals.html), to avoid the problem in the first place... ``` int value = 0b111111110000000010101010; int shifted = value >> 16; System.out.println(Integer.toBinaryString(shifted)); => 11111111 ```
19,181,359
I'm using a variable to store a count and am trying to fire off a stored procedure a number of times, iterating the number each time. However, I'm having problems with the syntax I need to use. Here's what I have so far: ``` declare @count INT declare @total INT declare @p1 nvarchar(255) set @count = 1 set @total = 50 if @count <= @total begin set @p1=NULL exec USP_DATAFORM_ADDNEW_b9c5ae3e_1e40_4e33_9682_18fb0bb40ff2 @ID=@p1 output,@ROLENAME='Load Test Role ' + @count,@DESCRIPTION=N'Role used for automated load test.',@COPYUSERS=0,@CHANGEAGENTID='023C133B-D753-41E9-BCC6-1E33A4ACD600',@SYSTEMROLEID=N'3a33d7a7-c3b3-4a34-a4d7-99ef1af78fb8' select @p1 set @count = @count + 1 end ``` The problem is that `@ROLENAME='Load Test Role ' + @count` part. What's the right syntax to use? Should I use dynamic SQL here and define the entire thing in an exec\_sql statement? For reference, I'm in SQL Server 2008 R2. The error I get is `Incorrect syntax near '+'`.
2013/10/04
[ "https://Stackoverflow.com/questions/19181359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133338/" ]
Cast the int var as a nvarchar: ``` @ROLENAME='Load Test Role ' + CAST(@count AS nvarchar) ```
Why dont you iterate it within the code? Might be easier. ``` declare @count INT = 1, @total INT = 50, @p1 nvarchar(255) while @count <= @total begin set @p1=NULL exec USP_DATAFORM_ADDNEW_b9c5ae3e_1e40_4e33_9682_18fb0bb40ff2 @ID=@p1 output,@ROLENAME='Load Test Role ' + @count,@DESCRIPTION=N'Role used for automated load test.',@COPYUSERS=0,@CHANGEAGENTID='023C133B-D753-41E9-BCC6-1E33A4ACD600',@SYSTEMROLEID=N'3a33d7a7-c3b3-4a34-a4d7-99ef1af78fb8' select @p1 set @count = @count + CAST(@count AS varchar(2)) end ```
25,187,311
I want to "sample" a `Range` using another `Range`. For example: ``` def sample(in: Range, by: Range): Range = ??? // note: Range equals broken! assert(sample(3 to 10 , 1 to 2 ).toVector == (4 to 5 ).toVector) assert(sample(3 to 10 , 1 to 4 by 2).toVector == (4 to 6 by 2).toVector) assert(sample(3 to 10 by 2, 1 to 2 ).toVector == (5 to 7 by 2).toVector) assert(sample(3 to 10 by 2, 1 to 4 by 2).toVector == (5 to 9 by 4).toVector) ``` How to define the `sample` method?
2014/08/07
[ "https://Stackoverflow.com/questions/25187311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/515054/" ]
Try this, its create a Direct2D canvas and draw a bitmap, also you can pan and zoom the view. ``` unit D2DForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Direct2D, D2D1; type TD2DForm = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormPaint(Sender: TObject); procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); private FZoom: D2D_SIZE_F; // Zoom level FView: TD2DPoint2f; // Transaltion FBitmap: ID2D1Bitmap; // A bitmap FCanvas: TDirect2DCanvas; // The Direct2D canvas FDragging: Boolean; // Dragging state FOldMousePos: TPoint; // Previous mouse position protected procedure CreateWnd; override; procedure WMPaint(var Message: TWMPaint); message WM_PAINT; procedure WMSize(var Message: TWMSize); message WM_SIZE; end; var D2DForm: TD2DForm; implementation {$R *.dfm} procedure TD2DForm.FormCreate(Sender: TObject); begin FZoom := D2D1SizeF(1, 1); // Zoom level, start from 1x FView := D2D1PointF(0, 0); // Translation end; procedure TD2DForm.FormDestroy(Sender: TObject); begin FreeAndNil(FCanvas); end; // CreateWnd is called when the form is created procedure TD2DForm.CreateWnd; var LBitmap: TBitmap; begin inherited; // TDirect2DCanvas.Create need a handle, so called from CreateWnd FCanvas := TDirect2DCanvas.Create(Handle); // Load a bitmap LBitmap := TBitmap.Create; LBitmap.LoadFromFile('c:\testb.bmp'); // Load your bitmap try FBitmap := FCanvas.CreateBitmap(LBitmap); finally FreeAndNil(LBitmap); end; end; // WMPaint is called when need to repaint the window // this will call our FormPaint() procedure TD2DForm.WMPaint(var Message: TWMPaint); var LPaintStruct: TPaintStruct; begin // This will render the canvas BeginPaint(Handle, LPaintStruct); try FCanvas.BeginDraw; try Paint; finally FCanvas.EndDraw; end; finally EndPaint(Handle, LPaintStruct); end; end; // WMSize is called when resizing the window procedure TD2DForm.WMSize(var Message: TWMSize); begin // here we resize our canvas to the same size of the window if Assigned(FCanvas) then ID2D1HwndRenderTarget(FCanvas.RenderTarget).Resize( D2D1SizeU(ClientWidth, ClientHeight)); inherited; end; procedure TD2DForm.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FDragging := True; FOldMousePos := Point(X, Y); end; procedure TD2DForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if FDragging then begin // Translate the view // its depend from zoom level FView.X := FView.X + ((X - FOldMousePos.X) / FZoom.Width ); FView.Y := FView.Y + ((Y - FOldMousePos.Y) / FZoom.Height); FOldMousePos := Point(X, Y); RePaint; end; end; procedure TD2DForm.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FDragging := False; end; procedure TD2DForm.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin // Update zoom level if WheelDelta > 0 then begin // Zoom in FZoom.Width := FZoom.Width * 1.1; FZoom.Height := FZoom.Height * 1.1; end else begin // Zoom Out FZoom.Width := FZoom.Width * 0.9; FZoom.Height := FZoom.Height * 0.9; end; Handled := True; RePaint; end; // Main painting routine procedure TD2DForm.FormPaint(Sender: TObject); var LView: TD2DMatrix3x2F; begin // Paint canvas with FCanvas do begin // Clear RenderTarget.Clear(D2D1ColorF(clBlack)); // Create view matrix // we create a translation and zoom(scale) matrix // and combine them LView := TD2DMatrix3x2F.SetProduct( TD2DMatrix3x2F.Translation(FView), TD2DMatrix3x2F.Scale(FZoom, D2D1PointF(ClientWidth / 2, ClientHeight / 2))); // Set the view matrix RenderTarget.SetTransform(LView); // Draw the bitmap RenderTarget.DrawBitmap(FBitmap); end; end; end. ```
This code can handle multiple bitmaps, test it :) ``` unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Direct2D, D2D1, StdCtrls, wincodec, ActiveX; type TIntArray = array of Integer; TD2DForm = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormPaint(Sender: TObject); procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); private FZoom: D2D_SIZE_F; // Zoom level FView: TD2DPoint2f; // Transaltion FCanvas: TDirect2DCanvas; // The Direct2D canvas FBitmaps: array of ID2D1Bitmap; // Bitmaps FDragging: Boolean; // Dragging state FOldMousePos: TPoint; // Previous mouse position FBitmapTable: array of TIntArray; // Table, each item contain index to a bitmap protected procedure CreateWnd; override; procedure WMPaint(var Message: TWMPaint); message WM_PAINT; procedure WMSize(var Message: TWMSize); message WM_SIZE; procedure WMEraseBkGnd(var Message: TWMEraseBkGnd); message WM_ERASEBKGND; end; var D2DForm: TD2DForm; implementation {$R *.dfm} function GetD2D1Bitmap(RenderTarget: ID2D1RenderTarget; imgPath: string): ID2D1Bitmap; var iWicFactory: IWICImagingFactory; iWICDecoder: IWICBitmapDecoder; iWICFrameDecode: IWICBitmapFrameDecode; iFormatConverter: IWICFormatConverter; begin CoCreateInstance(CLSID_WICImagingFactory, nil, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, iWicFactory); iWicFactory.CreateDecoderFromFilename(PWideChar(imgPath), GUID_NULL, GENERIC_READ, WICDecodeMetadataCacheOnLoad, iWICDecoder); iWicDecoder.GetFrame(0, iWICFrameDecode); iWicFactory.CreateFormatConverter(iFormatConverter); iFormatConverter.Initialize(iWICFrameDecode, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nil, 0, WICBitmapPaletteTypeMedianCut); RenderTarget.CreateBitmapFromWicBitmap(iFormatConverter, nil, Result); end; procedure TD2DForm.FormCreate(Sender: TObject); begin FZoom := D2D1SizeF(1, 1); // Zoom level, start from 1x FView := D2D1PointF(0, 0); // Translation end; procedure TD2DForm.FormDestroy(Sender: TObject); begin FreeAndNil(FCanvas); end; // CreateWnd is called when the form is created procedure TD2DForm.CreateWnd; var LIndexX: Integer; LIndexY: Integer; begin inherited; // TDirect2DCanvas.Create need a handle, so called from CreateWnd FCanvas := TDirect2DCanvas.Create(Handle); // Load bitmaps SetLength(FBitmaps, 3); // you can load more, if you want FBitmaps[0] := GetD2D1Bitmap(FCanvas.RenderTarget, 'c:\testb.bmp'); FBitmaps[1] := GetD2D1Bitmap(FCanvas.RenderTarget, 'c:\bitmap.bmp'); FBitmaps[2] := GetD2D1Bitmap(FCanvas.RenderTarget, 'c:\test.bmp'); // Create a 4 x 3 sized table, you can increase the size, if you want SetLength(FBitmapTable, 4); for LIndexY := 0 to Length(FBitmapTable) - 1 do begin SetLength(FBitmapTable[LIndexY], 3); for LIndexX := 0 to Length(FBitmapTable[LIndexY]) - 1 do FBitmapTable[LIndexY, LIndexX] := Random( Length(FBitmaps) ); // set bitmap index, to each table item end; end; // WMPaint is called when need to repaint the window // this will call our FormPaint() procedure TD2DForm.WMPaint(var Message: TWMPaint); var LPaintStruct: TPaintStruct; begin // This will render the canvas BeginPaint(Handle, LPaintStruct); try FCanvas.BeginDraw; try Paint; finally FCanvas.EndDraw; end; finally EndPaint(Handle, LPaintStruct); end; end; // WMSize is called when resizing the window procedure TD2DForm.WMSize(var Message: TWMSize); begin // here we resize the our canvas too if Assigned(FCanvas) then ID2D1HwndRenderTarget(FCanvas.RenderTarget).Resize(D2D1SizeU(ClientWidth, ClientHeight)); inherited; end; procedure TD2DForm.WMEraseBkGnd(var Message: TWMEraseBkGnd); begin Message.Result := 1; end; procedure TD2DForm.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FDragging := True; FOldMousePos := Point(X, Y); end; procedure TD2DForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if FDragging then begin // Translate the view // its depend from zoom level FView.X := FView.X + ((X - FOldMousePos.X) / FZoom.Width ); FView.Y := FView.Y + ((Y - FOldMousePos.Y) / FZoom.Height); FOldMousePos := Point(X, Y); RePaint; end; end; procedure TD2DForm.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FDragging := False; end; procedure TD2DForm.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin // Update zoom level if WheelDelta > 0 then begin // Zoom in FZoom.Width := FZoom.Width * 1.1; FZoom.Height := FZoom.Height * 1.1; end else begin // Zoom Out FZoom.Width := FZoom.Width * 0.9; FZoom.Height := FZoom.Height * 0.9; end; Handled := True; RePaint; end; // Main painting routine procedure TD2DForm.FormPaint(Sender: TObject); var LSize: TD2DSizeF; LRect: TD2D1RectF; LView: TD2DMatrix3x2F; LIndexX: Integer; LIndexY: Integer; LBitmap: ID2D1Bitmap; LMaxHeight: Single; begin // Paint canvas with FCanvas do begin // Clear RenderTarget.Clear(D2D1ColorF(clBlack)); // Create view matrix // we create a translation and zoom(scale) matrix // and combine them LView := TD2DMatrix3x2F.SetProduct( TD2DMatrix3x2F.Translation(FView), TD2DMatrix3x2F.Scale(FZoom, D2D1PointF(ClientWidth / 2, ClientHeight / 2))); // Set the view matrix RenderTarget.SetTransform(LView); // Draw the bitmap table LRect.Left := 0; LRect.Top := 0; for LIndexY := 0 to Length(FBitmapTable) - 1 do begin LMaxHeight := 0; for LIndexX := 0 to Length(FBitmapTable[LIndexY]) - 1 do begin // Get bitmap to draw LBitmap := FBitmaps[ FBitmapTable[LIndexY, LIndexX] ]; // Get Bitmap Size LBitmap.GetSize(LSize); // Calc destination rect LRect.Right := LRect.Left + LSize.Width; LRect.Bottom := LRect.Top + LSize.Height; // Draw RenderTarget.DrawBitmap(LBitmap, @LRect); // Increment left position LRect.Left := LRect.Left + LSize.Width; // Calc max bitmap height in this row if LSize.Height > LMaxHeight then LMaxHeight := LSize.Height; end; LRect.Left := 0; LRect.Top := LRect.Top + LMaxHeight; end; end; end; end. ```
10,842,118
I learned a really handy way to remove duplicate lines retaining the order from *[Remove duplicates without sorting file - BASH](http://www.unixcl.com/2008/03/remove-duplicates-without-sorting-file.html)*. Say, if you have the following file, ``` $cat file a a b b a c ``` you can use the following to remove the duplicate lines: ``` $awk '!x[$1]++' file a b c ``` How does this work in terms of precedence of operations?
2012/05/31
[ "https://Stackoverflow.com/questions/10842118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1058663/" ]
The expression is parsed as ``` !(x[$(1)]++) ``` So, from the inside out, it's: * Take field 1 of the current input line, `$(1)` (note that `$` is an operator in AWK, unlike in Perl). * Index `x` with the value of field 1; if `x` is an unbound variable, bind it to a new associative array. * Post-increment `x[$(1)]`; a rule similar to the one in C applies, so the value of the expression is that of `x[$(1)]` prior to the increment, which will be zero if `x[$(1)]` has not yet been assigned a value. * Negate the value of the previous, which will yield truth when `x[$(1)]` is zero. * Actually do the increment so that `x[$(1)]` gets a non-zero value. So, the next time, `x[$(1)]` for the same value of `$(1)` will return 1. This expression is then evaluated for every line in the input and determines whether the implied default action of `awk` should be executed, which is to echo the line to `stdout`.
In AWK arrays are associative, so the first column or first field of each line, `$1`, is used as an index for the array `x`.
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
To see all the files the package installed onto your system, do this: ``` dpkg-query -L <package_name> ``` To see the files a .deb file will install ``` dpkg-deb -c <package_name.deb> ``` To see the files contained in a package NOT installed, do this once (if you haven't installed [apt-file](http://packages.ubuntu.com/apt-file) already: ``` sudo apt-get install apt-file sudo apt-file update ``` then ``` apt-file list <package_name> ``` See [this question](https://superuser.com/questions/82923/how-to-list-files-of-a-debian-package-without-install) for more
Here's one way to do it for packages you don't have installed yet. Just change "autoconf" below for the package you are trying to get the list of files for: ``` mkdir tmp cd tmp apt-get download autoconf ar x *.deb tar tf data.* cd .. rm -r tmp ```
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
To see all the files the package installed onto your system, do this: ``` dpkg-query -L <package_name> ``` To see the files a .deb file will install ``` dpkg-deb -c <package_name.deb> ``` To see the files contained in a package NOT installed, do this once (if you haven't installed [apt-file](http://packages.ubuntu.com/apt-file) already: ``` sudo apt-get install apt-file sudo apt-file update ``` then ``` apt-file list <package_name> ``` See [this question](https://superuser.com/questions/82923/how-to-list-files-of-a-debian-package-without-install) for more
The answer given by @Gilles is very useful (actually, the answer [was improved over time](https://askubuntu.com/posts/32509/revisions)). Furthermore, I have a tip for the ones that don't want to install any auxiliary package (like the `apt-file`): * Go to <http://packages.ubuntu.com/>; * Go to the **Search package directories** session; * Insert your package name in the **Keyword** field and select **Only show exact matches**; * Select your **distribution** and click in the **Search** button. * Select the desirable package in the next screen; * In the end of page, click in the **list of files** link next to your architecture name; * The next page will show the list of files of your package. As an example: <http://packages.ubuntu.com/trusty/amd64/multipath-tools/filelist>
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
The answer given by @Gilles is very useful (actually, the answer [was improved over time](https://askubuntu.com/posts/32509/revisions)). Furthermore, I have a tip for the ones that don't want to install any auxiliary package (like the `apt-file`): * Go to <http://packages.ubuntu.com/>; * Go to the **Search package directories** session; * Insert your package name in the **Keyword** field and select **Only show exact matches**; * Select your **distribution** and click in the **Search** button. * Select the desirable package in the next screen; * In the end of page, click in the **list of files** link next to your architecture name; * The next page will show the list of files of your package. As an example: <http://packages.ubuntu.com/trusty/amd64/multipath-tools/filelist>
Use the `synaptic-package-manager`: [![enter image description here](https://i.stack.imgur.com/Gpl7o.png)](https://i.stack.imgur.com/Gpl7o.png) Assuming that we'd like to locate the files of the autotools-dev package, under 'Quick filter' enter autotools-dev to locate it. The autotools-dev package appears automatically. Select it by clicking on it and then press 'Properties'. In the appearing dialog, select the tab 'Installed Files'.
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
To see all the files the package installed onto your system, do this: ``` dpkg-query -L <package_name> ``` To see the files a .deb file will install ``` dpkg-deb -c <package_name.deb> ``` To see the files contained in a package NOT installed, do this once (if you haven't installed [apt-file](http://packages.ubuntu.com/apt-file) already: ``` sudo apt-get install apt-file sudo apt-file update ``` then ``` apt-file list <package_name> ``` See [this question](https://superuser.com/questions/82923/how-to-list-files-of-a-debian-package-without-install) for more
if you just want a single installed package, you can find the package name ``` $ apt-cache search rabbitmq ... librabbitmq-dev ... ``` then use dpkg --listfiles ``` $ dpkg --listfiles librabbitmq-dev /usr/lib/x86-64/librabbit... . . . ```
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
@drysdam `dpkg -L <package_name>` might be the best for your immediate problem, but you might like to read the [Filesystem Hierarchy Standard](http://www.pathname.com/fhs/), which describes where different types of files live in the filesystem. It is *not* definitive; it is just a descriptive account of the way things "mostly" are. More specific to Ubuntu is the [Ubuntu Server Guide](https://help.ubuntu.com/lts/serverguide/index.html), which will describe everything in enough detail. (So many of the other guides gloss over too many of the details, but this should be better.)
Use the `synaptic-package-manager`: [![enter image description here](https://i.stack.imgur.com/Gpl7o.png)](https://i.stack.imgur.com/Gpl7o.png) Assuming that we'd like to locate the files of the autotools-dev package, under 'Quick filter' enter autotools-dev to locate it. The autotools-dev package appears automatically. Select it by clicking on it and then press 'Properties'. In the appearing dialog, select the tab 'Installed Files'.
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
The answer given by @Gilles is very useful (actually, the answer [was improved over time](https://askubuntu.com/posts/32509/revisions)). Furthermore, I have a tip for the ones that don't want to install any auxiliary package (like the `apt-file`): * Go to <http://packages.ubuntu.com/>; * Go to the **Search package directories** session; * Insert your package name in the **Keyword** field and select **Only show exact matches**; * Select your **distribution** and click in the **Search** button. * Select the desirable package in the next screen; * In the end of page, click in the **list of files** link next to your architecture name; * The next page will show the list of files of your package. As an example: <http://packages.ubuntu.com/trusty/amd64/multipath-tools/filelist>
Here's one way to do it for packages you don't have installed yet. Just change "autoconf" below for the package you are trying to get the list of files for: ``` mkdir tmp cd tmp apt-get download autoconf ar x *.deb tar tf data.* cd .. rm -r tmp ```
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
@drysdam `dpkg -L <package_name>` might be the best for your immediate problem, but you might like to read the [Filesystem Hierarchy Standard](http://www.pathname.com/fhs/), which describes where different types of files live in the filesystem. It is *not* definitive; it is just a descriptive account of the way things "mostly" are. More specific to Ubuntu is the [Ubuntu Server Guide](https://help.ubuntu.com/lts/serverguide/index.html), which will describe everything in enough detail. (So many of the other guides gloss over too many of the details, but this should be better.)
Here's one way to do it for packages you don't have installed yet. Just change "autoconf" below for the package you are trying to get the list of files for: ``` mkdir tmp cd tmp apt-get download autoconf ar x *.deb tar tf data.* cd .. rm -r tmp ```
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
if you just want a single installed package, you can find the package name ``` $ apt-cache search rabbitmq ... librabbitmq-dev ... ``` then use dpkg --listfiles ``` $ dpkg --listfiles librabbitmq-dev /usr/lib/x86-64/librabbit... . . . ```
Use the `synaptic-package-manager`: [![enter image description here](https://i.stack.imgur.com/Gpl7o.png)](https://i.stack.imgur.com/Gpl7o.png) Assuming that we'd like to locate the files of the autotools-dev package, under 'Quick filter' enter autotools-dev to locate it. The autotools-dev package appears automatically. Select it by clicking on it and then press 'Properties'. In the appearing dialog, select the tab 'Installed Files'.
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
if you just want a single installed package, you can find the package name ``` $ apt-cache search rabbitmq ... librabbitmq-dev ... ``` then use dpkg --listfiles ``` $ dpkg --listfiles librabbitmq-dev /usr/lib/x86-64/librabbit... . . . ```
Here's one way to do it for packages you don't have installed yet. Just change "autoconf" below for the package you are trying to get the list of files for: ``` mkdir tmp cd tmp apt-get download autoconf ar x *.deb tar tf data.* cd .. rm -r tmp ```
32,507
I want to know where I can find my installed application when I installed it on Ubuntu using package manager. I installed RabbitMQ and ran `locate rabbitmq` which gave me following result: ``` /home/anupamg/.m2/repository/com/rabbitmq /home/anupamg/.m2/repository/com/rabbitmq/amqp-client /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/_maven.repositories /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.jar.sha1 /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.lastUpdated /home/anupamg/.m2/repository/com/rabbitmq/amqp-client/1.7.2/amqp-client-1.7.2.pom.sha1 /home/anupamg/Downloads/rabbitmq-server-generic-unix-2.4.0.tar.gz ```
2011/03/29
[ "https://askubuntu.com/questions/32507", "https://askubuntu.com", "https://askubuntu.com/users/746753/" ]
To see all the files the package installed onto your system, do this: ``` dpkg-query -L <package_name> ``` To see the files a .deb file will install ``` dpkg-deb -c <package_name.deb> ``` To see the files contained in a package NOT installed, do this once (if you haven't installed [apt-file](http://packages.ubuntu.com/apt-file) already: ``` sudo apt-get install apt-file sudo apt-file update ``` then ``` apt-file list <package_name> ``` See [this question](https://superuser.com/questions/82923/how-to-list-files-of-a-debian-package-without-install) for more
Use the `synaptic-package-manager`: [![enter image description here](https://i.stack.imgur.com/Gpl7o.png)](https://i.stack.imgur.com/Gpl7o.png) Assuming that we'd like to locate the files of the autotools-dev package, under 'Quick filter' enter autotools-dev to locate it. The autotools-dev package appears automatically. Select it by clicking on it and then press 'Properties'. In the appearing dialog, select the tab 'Installed Files'.
56,743,837
I have a beginner question. Maybe I´m just too stupid. Situation: I have a interface where I can set alarm timer values via a slider. Everytime the value gets updated, it is written down to a file. But when I set an interval I dont have access from the callback function to the watched variable, see timeCallback(). ``` Vue.component('alarm-comp', { data: function() { return { data: { wakeup: { text: "Get up", time: 30, //timeout }, ... }, test: "test", ... }, watch: { data: { handler(val) { this.saveSettings(); }, deep: true } }, mounted: function() { this.readSettings(); setInterval(() => {this.timerCallback()}, (this.data.wakeup.time) * 1000); // -> time correctly set }, methods: { timerCallback() { console.log(this.test); // -> test console.log(this.data.wakeup.time); // -> undefined }, } ```
2019/06/24
[ "https://Stackoverflow.com/questions/56743837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11633439/" ]
As per my comment… The main issue with your code is that you have not followed the guidance for the use of the `Set` command. Opening a Command Prompt window and entering **`set /?`**, should have been sufficient to learn how to use that command, *from the output*. Currently your variable is `%print_time %` not `%print_time%`, because spaces either side of the **`=`** are included in both the variables name and value. Effectively you need to change `set print_time = %mydate%_%mytime%` to `set print_time=%mydate%_%mytime%`. In addition, it is best practice to use quotation marks to protect spaces and other 'poison' characters in your strings. When it come to setting a variable, the recommended syntax is `Set "VariableName=Variable Value"`, so you should be using, `Set "print_time=%mydate%_%mytime%"`. Also although not necessary with the provided path, it is safer to enclose the variable `%DIR%` in quotation marks too, *(this would mean that any change in the destination path, perhaps introducing spaces or ampersands, would not affect the rest of the code)*. You should therefore do that in your `MkDir` and `mongodump` command lines, thus: ```bat @Echo Off For /F "Tokens=2-4Delims=/ " %%A In ('Date /T')Do Set "MyDate=%%C-%%A-%%B" For /F "Delims=:" %%A In ('Time /T')Do Set "MyTime=%%A" Set "print_time=%MyDate%_%MyTime%" Set "DIR=%print_time%" Set "DEST=D:\MongoDB\db_backup\%DIR%" MkDir "%DEST%" 2>NUL mongodump -h 127.0.0.1:27017 -d DW -u [user] -p [password] -o "%DEST%" ``` The methods you used in creating your date and time string is not very robust, because the results of `Date` and `Time` with their `/T` option are Locale/PC/User dependent. I would suggest you use a method which isn't, so offer a solution which uses `RoboCopy` instead. Additionally, the following defines only one variable in achieving your goal, instead of five: ```bat @Echo Off Set "DEST=" For /F "Tokens=1-4Delims=/: " %%A In ('RoboCopy /NJH /L "\|" Null')Do If Not Defined DEST Set "DEST=D:\MongoDB\db_backup\%%A-%%B-%%C_%%D" If Not Defined DEST GoTo :EOF MD "%DEST%" 2>NUL mongodump -h 127.0.0.1:27017 -d DW -u [user] -p [password] -o "%DEST%" ```
Try the following this works as expected for me. I suspect that you have a space in your original method, and this is just taking your code removing redundant parts and using Quotes around variables to make sure it isn't happening. ``` @ECHO OFF SET "_UN=YourUserName" SET "_PW=YourPassword" SET "_MongoDBIPPort=127.0.0.1:27017" SET "_MongoDB=DW" SET "_MongoBackupRoot=D:\MongoDB\db_backup" FOR /F "Tokens=1-7 delims=MTWFSmtwfsouehrandit:-\/. " %%A IN ("%DATE% %TIME: =0%") DO ( FOR /F "Tokens=2-4 Skip=1 Delims=(-)" %%a IN ('ECHO.^| DATE') DO ( SET "%%~a=%%~A" & SET "%%~b=%%~B" & SET "%%~c=%%~C" & SET "HH=%%~D" & SET "Mn=%%~E" & SET "SS=%%~F" & SET "Ms=%%~G" ) ) SET "_PrintTime=%yy%-%mm%-%dd%_%HH%.%Mn%" ECHO(_PrintTime = "%_PrintTime%" SET "_Dest=%_MongoBackupRoot%\%_PrintTime%" ECHO(Dest Directory = "%_Dest%" IF NOT EXIST "%_Dest%" ( MD "%_Dest%" ) mongodump -h %_MongoDBIPPort% -d %_MongoDB% -u %_UN% -p %_PW% -o "%_Dest%" ``` As your original code did not give me the issue you encountered, it again leads to to believe there may have some errant spaces in your variable declarations or other non printable characters which I am not able to receive through Stack Exchange. Note: I changed the code to no longer rely on the date being a particular format so that the code will run the same on my machine as yours as I use a different date format then you do, so I felt it was better to post code which should work for either of us. Sorry looks like I left this up mid-edit when I rushed out yesterday, and did not post it at that time. Hope that helps! :)
153,298
I have a WD My Passport Ultra and I had it plugged into my MacBook Pro 15" Mid 2012 Model and I had just closed the lid and it went to sleep. Then I came back hours later and when I opened it a message was stating that it had been improperly ejected even though it was still plugged in. I wanted to know if this was normal and if anyone else is experiencing this.
2014/10/27
[ "https://apple.stackexchange.com/questions/153298", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/97639/" ]
Same thing bothering me. As far as I can tell, there is no 'native' Finder solution. However, as a (belated) suggestion to OP, or anyone else with the same problem, here's how I solved it for myself -- sort of a 'hack', but better than Finder default behavior: Use some keyboard customization software (I'm using Karabiner), and define a (user activated) shortcut that triggers two other keyboard shortcuts that are executed automatically, and in sequence. The shortcuts that do the trick are: (1) Reveal in Finder, (2) Merge all windows. Details: "Reveal in Finder" is already bound to a shortcut natively (cmd-R), but "Merge all windows" is not afaik. Since adding menu items in Karabiner is a bit tricky, probably the easiest way is to assign a shortcut to "Merge..." in System Preferences -> Keyboard -> Shortcuts -> App shortcuts. I picked cmd-shift-M. You can then make use of this (OSX) shortcut in the definition of a Karabiner shortcut. In Karabiner, I then defined a custom shortcut (cmd-R), triggering cmd-R and cmd-shift-M. The effect is pretty close to what I wanted to see in the first place: in a Finder search tab/window, I select an item, press cmd-R, which reveals the item in a new window, which is immediately merged into the existing window as a new tab. Focus remains on main window, the new tab goes to the end of the tab bar, and I can continue revealing other items immediately without having to cycle tabs. The one thing that still bothers me: the "merge windows" animation is slow-ish, and I can't find a way to speed it up (or disable it). Like I said, not perfect perhaps, but it's reasonably close to what I had in mind.
Xtra Finder does this automatically and I had been using it. However I found it slow after upgrading to Yosemite - like many other things - so I uninstalled it to give the Finder another chance with the hope it had improved. Sadly it remains really limited and like you, I use Spotlight to navigate to folders and find it infuriating that it keeps launching new windows. I would also love a fix to this. BTW XtraFinder is free and has other benefits like using the delete key to delete a file
486,324
**UPDATE: Code snippet already done below. Not sure if correct.** I implemented the routine which is found in Microchip's datasheet in order to reset the EEPROM memory (24LC512)in case it hangs up. But not sure it is correct. Many people in the internet commented on doing this, but no code "in the wild" yet. Maybe it's about time... [![enter image description here](https://i.stack.imgur.com/PjpgK.png)](https://i.stack.imgur.com/PjpgK.png) <http://ww1.microchip.com/downloads/en/AppNotes/01028a.pdf> I made a draft. I am asking for comments as I can't test this. ``` Wire1.end(); const int SDA=70; const int SCL=71; pinMode(SDA, OUTPUT); //70 -> SDA1 pinMode(71, OUTPUT); //71 -> SCL2. /* Send START condition */ //A HIGH to LOW transition on the SDA line while SCL is HIGH defines a START condition. digitalWrite(71, HIGH); delayMicroseconds(5); digitalWrite(SDA, HIGH); delayMicroseconds(5); digitalWrite(SDA, LOW); delayMicroseconds(5); digitalWrite(71, LOW); digitalWrite(SDA, HIGH); //WRONG?? " while allowing the SDA line to float," https://www.microchip.com/forums/m898899.aspx //send 9 clock pulses to reset slaves for(int i = 0; i < 9; i++){ digitalWrite(71, HIGH); delayMicroseconds(5); digitalWrite(71, LOW); } /* Send START condition */ //A HIGH to LOW transition on the SDA line while SCL is HIGH defines a START condition. digitalWrite(71, HIGH); delayMicroseconds(5); digitalWrite(SDA, HIGH); delayMicroseconds(5); digitalWrite(SDA, LOW); delayMicroseconds(5); digitalWrite(71, LOW); /* Send STOP condition */ //A LOW to HIGH transition on the SDA line while SCL is HIGH defines a STOP condition. digitalWrite(71, HIGH); delayMicroseconds(5); digitalWrite(SDA, LOW); delayMicroseconds(5); digitalWrite(SDA, HIGH); delayMicroseconds(5); digitalWrite(71, LOW); Wire1.begin(); ``` ```
2020/03/15
[ "https://electronics.stackexchange.com/questions/486324", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/245273/" ]
As the bus may be in any state, it may not even be possible to use the TWI peripheral to send anything, not even start bit. So you must switch the I2C peripheral off so you can just send the wanted sequence by bit-banging the GPIO pins with software. Just remember that you must never output logic high, only logic low or input.
Is the spec really calling for you to send 9 bits over I2C when the interface is generally byte oriented? (Could be so as this is a reset operation, although it is unusual. I would first check the datasheet.) If it is so, the best way is probably to take over the port pins and write a routine to bit bash this, then release the port. It's a routine that would only be used exceptionally, so no harm with it, and bit bashing is not too hard with I2C. In this case you don't care if it is a bit slower than normal operations.
55,725,618
I am trying to follow the latest Google's good practises implementing a single Activity Application with Navigation Components. However after reading the whole Navigation documentation I still think there are a lot of cases that they don't address. For example, How should I implement the following case: [![navgraph](https://i.stack.imgur.com/3V010.png)](https://i.stack.imgur.com/3V010.png) * App starts in a splash screen. Then after some loading goes to the News Fragment. **Note:** Splash Screen should pop from the backstack, since it shouldn't be acessible anymore. * A Navigation Drawer should be available in all fragments of Section 1, allowing the user to navigate between fragments in this section. * However some fragments in the section can navigate to a new area which should have a back button (not a drawer).
2019/04/17
[ "https://Stackoverflow.com/questions/55725618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4712672/" ]
Have you tried creating a new project with selected `Navigation Drawer Activity`? **1. Drawer** In XML you should add for this activity a `FrameLayout` that will hold fragments. Then you can start using this activity as a container for your fragments and on `DrawerMenuItem` click, you load a particular fragment. I use this method to reload fragments: ``` public void replaceFragment (Fragment fragment, Bundle args){ fragment.setArguments(args); getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit(); } ``` and call it like this from activity: ``` replaceFragment(Fragment.newInstance(), args) ``` Then you have your drawer available in all fragments. **2. Details screen with back arrow** As for another screen with for example Article details, you could start activity with details: `startActivity(new Intent(packageContext, ArticleDetailsActivity.class));` Then there is no drawer and you have a back button. **3. Splash** As for creating a "good" splash screen Google "Android splash screen the right way", there are posts on medium (by Sylvain Saurel) or bignerdranch (by Chris Stewart) that cover this topic.
Use `DestinatedChangedListener` on the `nav controller` to `lock` and `unlock` the drawer mode.
127,086
I installed the driver for my network card. iwconfig and ifconfig are all responsive to connecting to the network, I'm given an access point address. Then, I try to connect to a website and no dice. ping www.google.com yields no result. What gives?
2010/04/03
[ "https://superuser.com/questions/127086", "https://superuser.com", "https://superuser.com/users/1698/" ]
Ping your router, then an external IP address, then a web site. Failure on the first means that your wireless is not working, on the second means that your external connection is not working, on the third means that your DNS setup is incorrect.
I am 100% sure that you used the ifconfig and iwconfig commands to issue an IP address and connect to the access point. What you are missing is setting up the proper routes and DNS.
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
It's perfectly normal; `до свидания` is just a polite form of a farewell and is used regardless of the probability to meet again. Moreover, `до свидания` can be used in (formal) phone calls, when people have actually never met and probably never will. `Всего доброго` is also fine and, I think, perfectly interchangeable with `до свидания`.
A way of saying goodbye that implies that it is likely that you won't see each other again is > > проща́й > > > or the more polite (or plural) > > проща́йте > > > Yeah, and I agree with Lev that до свидания is perfectly normal regardless of the probablity of meeting again. It's just that if you want to *imply* that you probably won't meet for a long time or ever, прощай(те) is a better choice.
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
It's perfectly normal; `до свидания` is just a polite form of a farewell and is used regardless of the probability to meet again. Moreover, `до свидания` can be used in (formal) phone calls, when people have actually never met and probably never will. `Всего доброго` is also fine and, I think, perfectly interchangeable with `до свидания`.
Practice shows that it is perfectly acceptable to say `До свидания` regardless of whether you think you'll actually see them again. Think about it ... you can't possibly know if you'll see them again, you may. Even if the person is terminally ill, I believe it's still OK to say `До свидания`, implying that you'll meet them again in the afterlife at some point in the future.
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
It's perfectly normal; `до свидания` is just a polite form of a farewell and is used regardless of the probability to meet again. Moreover, `до свидания` can be used in (formal) phone calls, when people have actually never met and probably never will. `Всего доброго` is also fine and, I think, perfectly interchangeable with `до свидания`.
In Russia "*до свиданья*" can be used in either case of terminating the communication. If it is a voice or tete-a-tete conversation, then "*до свиданья*" will have different meanings depending on the intonation. These meanings include (but are not limited to) friendly "*see you later*", "*hope to see you soon*" etc., or a disappointed "*hope to never see you again*".
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
It's perfectly normal; `до свидания` is just a polite form of a farewell and is used regardless of the probability to meet again. Moreover, `до свидания` can be used in (formal) phone calls, when people have actually never met and probably never will. `Всего доброго` is also fine and, I think, perfectly interchangeable with `до свидания`.
The most informal way to say goodbye is "Пока", cognate to Italian "ciao". "До свидания" is totally OK, and this is just like you use the "How are you" greeting in English – just a formal way to mark a specific situation. More close to "see you" is "увидимся". This actually means that persons involved in conversation are saying goodbye to each other (попрощались друг с другом) and that they most probably will meet in the near future.
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
It's perfectly normal; `до свидания` is just a polite form of a farewell and is used regardless of the probability to meet again. Moreover, `до свидания` can be used in (formal) phone calls, when people have actually never met and probably never will. `Всего доброго` is also fine and, I think, perfectly interchangeable with `до свидания`.
You should use "прощай" only if you want to stress that you will never (really never!) meet again. It could be deemed to be rudeness or threat. I recommend never use "прощай" if you unsure. It could be used at the end of the romantic relationship. Or if you or another person should die shortly. Or your familiar is going to move to the far place and you don't expect to see it again. "До свидания", "всего хорошего", "всего доброго" is usually used at the end of the conversation (regardless will you meet again or not). You could use "удачи" as less formal form (but still appropriate in many cases). "Пока" is used in informal conversations (mostly with friends). There are a lot of another forms: "до встречи" (if you are going to meet again), "ещё увидимся" (less formal form of the same), maybe "созвонимся" (if you are going to chat via phone), even "спишемся" (if you are going to communicate via email/IM), "давай" (like "пока"). Often couple of phrases is combined, e.g. "Ну пока, удачи", or "Давай, ещё увидимся".
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
A way of saying goodbye that implies that it is likely that you won't see each other again is > > проща́й > > > or the more polite (or plural) > > проща́йте > > > Yeah, and I agree with Lev that до свидания is perfectly normal regardless of the probablity of meeting again. It's just that if you want to *imply* that you probably won't meet for a long time or ever, прощай(те) is a better choice.
You should use "прощай" only if you want to stress that you will never (really never!) meet again. It could be deemed to be rudeness or threat. I recommend never use "прощай" if you unsure. It could be used at the end of the romantic relationship. Or if you or another person should die shortly. Or your familiar is going to move to the far place and you don't expect to see it again. "До свидания", "всего хорошего", "всего доброго" is usually used at the end of the conversation (regardless will you meet again or not). You could use "удачи" as less formal form (but still appropriate in many cases). "Пока" is used in informal conversations (mostly with friends). There are a lot of another forms: "до встречи" (if you are going to meet again), "ещё увидимся" (less formal form of the same), maybe "созвонимся" (if you are going to chat via phone), even "спишемся" (if you are going to communicate via email/IM), "давай" (like "пока"). Often couple of phrases is combined, e.g. "Ну пока, удачи", or "Давай, ещё увидимся".
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
Practice shows that it is perfectly acceptable to say `До свидания` regardless of whether you think you'll actually see them again. Think about it ... you can't possibly know if you'll see them again, you may. Even if the person is terminally ill, I believe it's still OK to say `До свидания`, implying that you'll meet them again in the afterlife at some point in the future.
You should use "прощай" only if you want to stress that you will never (really never!) meet again. It could be deemed to be rudeness or threat. I recommend never use "прощай" if you unsure. It could be used at the end of the romantic relationship. Or if you or another person should die shortly. Or your familiar is going to move to the far place and you don't expect to see it again. "До свидания", "всего хорошего", "всего доброго" is usually used at the end of the conversation (regardless will you meet again or not). You could use "удачи" as less formal form (but still appropriate in many cases). "Пока" is used in informal conversations (mostly with friends). There are a lot of another forms: "до встречи" (if you are going to meet again), "ещё увидимся" (less formal form of the same), maybe "созвонимся" (if you are going to chat via phone), even "спишемся" (if you are going to communicate via email/IM), "давай" (like "пока"). Often couple of phrases is combined, e.g. "Ну пока, удачи", or "Давай, ещё увидимся".
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
In Russia "*до свиданья*" can be used in either case of terminating the communication. If it is a voice or tete-a-tete conversation, then "*до свиданья*" will have different meanings depending on the intonation. These meanings include (but are not limited to) friendly "*see you later*", "*hope to see you soon*" etc., or a disappointed "*hope to never see you again*".
You should use "прощай" only if you want to stress that you will never (really never!) meet again. It could be deemed to be rudeness or threat. I recommend never use "прощай" if you unsure. It could be used at the end of the romantic relationship. Or if you or another person should die shortly. Or your familiar is going to move to the far place and you don't expect to see it again. "До свидания", "всего хорошего", "всего доброго" is usually used at the end of the conversation (regardless will you meet again or not). You could use "удачи" as less formal form (but still appropriate in many cases). "Пока" is used in informal conversations (mostly with friends). There are a lot of another forms: "до встречи" (if you are going to meet again), "ещё увидимся" (less formal form of the same), maybe "созвонимся" (if you are going to chat via phone), even "спишемся" (if you are going to communicate via email/IM), "давай" (like "пока"). Often couple of phrases is combined, e.g. "Ну пока, удачи", or "Давай, ещё увидимся".
374
I have a habit of saying 'До свидания' (Au revoir; until we meet again) when terminating a conversation. Would this seem strange if I'm not likely to actually meet that person again, such as a clerk, a stranger asking for directions or just somebody who called the wrong number? Should I instead be using 'Всего доброго' (All the best) or a different farewell entirely?
2012/06/27
[ "https://russian.stackexchange.com/questions/374", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/38/" ]
The most informal way to say goodbye is "Пока", cognate to Italian "ciao". "До свидания" is totally OK, and this is just like you use the "How are you" greeting in English – just a formal way to mark a specific situation. More close to "see you" is "увидимся". This actually means that persons involved in conversation are saying goodbye to each other (попрощались друг с другом) and that they most probably will meet in the near future.
You should use "прощай" only if you want to stress that you will never (really never!) meet again. It could be deemed to be rudeness or threat. I recommend never use "прощай" if you unsure. It could be used at the end of the romantic relationship. Or if you or another person should die shortly. Or your familiar is going to move to the far place and you don't expect to see it again. "До свидания", "всего хорошего", "всего доброго" is usually used at the end of the conversation (regardless will you meet again or not). You could use "удачи" as less formal form (but still appropriate in many cases). "Пока" is used in informal conversations (mostly with friends). There are a lot of another forms: "до встречи" (if you are going to meet again), "ещё увидимся" (less formal form of the same), maybe "созвонимся" (if you are going to chat via phone), even "спишемся" (if you are going to communicate via email/IM), "давай" (like "пока"). Often couple of phrases is combined, e.g. "Ну пока, удачи", or "Давай, ещё увидимся".
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
Generating and serving an Angular project via a development server - First go to your Project Directory and the type the below - ``` ng new my-app cd my-app ng generate component User (or) ng g c user ng serve ``` Here “**D:\Angular\my-app>**” is my Angular application Project Directory and the “**User**” is the name of component. The commonds looks like - ``` D:\Angular\my-app>ng g component User create src/app/user/user.component.html (23 bytes) create src/app/user/user.component.spec.ts (614 bytes) create src/app/user/user.component.ts (261 bytes) create src/app/user/user.component.css (0 bytes) update src/app/app.module.ts (586 bytes) ```
ng generate component component\_name was not working in my case because instead of using 'app' as project folder name, I renamed it to something else. I again changed it to app. Now, it is working fine
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
Make sure you are in your project directory in the CMD line ``` ng g component componentName ```
I think you have to upgrade the latest angular cli using this command. ``` npm install -g @angular/cli ``` Then if you run `ng g c componentName`, it will work.
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
In Angular4 this will work the same. If you get an error I think your problem is somewhere else. In command prompt type > > ng generate component YOURCOMPONENTNAME > > > There are even shorthands for this: the commands `generate` can be used as `g` and `component` as `c`: > > ng g c YOURCOMPONENTNAME > > > you can use `ng --help`, `ng g --help` or `ng g c --help` for the docs. Ofcourse rename YOURCOMPONENTNAME to the name you would like to use. > > [Docs:](https://github.com/angular/angular-cli#generating-components-directives-pipes-and-services) angular-cli will add reference to components, directives and pipes automatically in the app.module.ts. > > > **Update: This still functions in Angular version 8.**
``` ng g component componentname ``` It generates the component and adds the component to module declarations. when creating component manually , you should add the component in declaration of the module like this : ``` @NgModule({ imports: [ yourCommaSeparatedModules ], declarations: [ yourCommaSeparatedComponents ] }) export class yourModule { } ```
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
**For creating component under certain folder** ``` ng g c employee/create-employee --skipTests=false --flat=true ``` This line will create a folder name 'employee', underneath that it creates a 'create-employee' component. **without creating any folder** ``` ng g c create-employee --skipTests=false --flat=true ```
Go to your project directory in CMD, run the following code. ``` ng g c componentname ``` A folder will be created in the component name. inside that, you can find four files such as HTML, CSS, spec.ts & ts. And you should not rename any of the files.
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
1) first go to your Project Directory 2) then Run below Command in terminal. ``` ng generate component componentname ``` **OR** ``` ng g component componentname ``` 3) after that you will see output like this, ``` create src/app/test/componentname.component.css (0 bytes) create src/app/test/componentname.component.html (23 bytes) create src/app/test/componentname.component.spec.ts (614 bytes) create src/app/test/componentname.component.ts (261 bytes) update src/app/app.module.ts (1087 bytes) ```
Make sure you are in your project directory in the CMD line ``` ng g component componentName ```
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
``` ng g c componentname ``` It will create the following 4 files: 1. `componentname.css` 2. `componentname.html` 3. `componentname.spec.ts` 4. `componentname.ts`
`ng g c COMPONENTNAME` should work, if your are getting module not found exception then try these things- 1. Check your project directory. 2. If you are using visual studio code then reload it or reopen your project in it.
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
In Angular4 this will work the same. If you get an error I think your problem is somewhere else. In command prompt type > > ng generate component YOURCOMPONENTNAME > > > There are even shorthands for this: the commands `generate` can be used as `g` and `component` as `c`: > > ng g c YOURCOMPONENTNAME > > > you can use `ng --help`, `ng g --help` or `ng g c --help` for the docs. Ofcourse rename YOURCOMPONENTNAME to the name you would like to use. > > [Docs:](https://github.com/angular/angular-cli#generating-components-directives-pipes-and-services) angular-cli will add reference to components, directives and pipes automatically in the app.module.ts. > > > **Update: This still functions in Angular version 8.**
1) first go to your Project Directory 2) then Run below Command in terminal. ``` ng generate component componentname ``` **OR** ``` ng g component componentname ``` 3) after that you will see output like this, ``` create src/app/test/componentname.component.css (0 bytes) create src/app/test/componentname.component.html (23 bytes) create src/app/test/componentname.component.spec.ts (614 bytes) create src/app/test/componentname.component.ts (261 bytes) update src/app/app.module.ts (1087 bytes) ```
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
**For creating component under certain folder** ``` ng g c employee/create-employee --skipTests=false --flat=true ``` This line will create a folder name 'employee', underneath that it creates a 'create-employee' component. **without creating any folder** ``` ng g c create-employee --skipTests=false --flat=true ```
if you want that component not appears in one folder. ``` ng g c NameComponent --flat ```
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
ng g c --dry-run so you can see what you are about to do before you actually do it will save some frustration. Just shows you what it is going to do without actually doing it.
Go to Project location in Specified Folder ``` C:\Angular6\sample> ``` Here you can type the command ``` C:\Angular6\sample>ng g c users ``` Here g means generate , c means component ,users is the component name it will generate the 4 files ``` users.component.html, users.component.spec.ts, users.component.ts, users.component.css ```
44,151,427
In angular 2 I use ``` ng g c componentname ``` But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
2017/05/24
[ "https://Stackoverflow.com/questions/44151427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7501582/" ]
1) first go to your Project Directory 2) then Run below Command in terminal. ``` ng generate component componentname ``` **OR** ``` ng g component componentname ``` 3) after that you will see output like this, ``` create src/app/test/componentname.component.css (0 bytes) create src/app/test/componentname.component.html (23 bytes) create src/app/test/componentname.component.spec.ts (614 bytes) create src/app/test/componentname.component.ts (261 bytes) update src/app/app.module.ts (1087 bytes) ```
You should be in the `src/app` folder of your angular-cli project on command line. For example: ``` D:\angular2-cli\first-app\src\app> ng generate component test ``` Only then it will generate your component.
32,224,228
I have the following layout > > > ``` > _______________________________________________________ > | iframe | > | ______ _____________________________________ ______ | > || menu ||info ||advert|| > || || || || > || || || || > || || || || > || || || || > > ``` > > I have read many pages of answers and they all seem to say the same things, but i still can't get my code to work. I want links in my MENU to change the iframe, which will load new topics each with their own menu. Also some pages in my INFO box need to change the source of the iframe. An example is when I want to log out of my account and return to my homepage: I hit LOGOUT on the MENU, which loads logout.php into INFO and nulls all variables followed by this ... ``` <script type="text/javascript"> top.document.getElementById('iframeid').src='home.php'; </script> ``` I have also tried (and variations of) ``` document.getElementById('iframeid').src='home.php'; parent.document.getElementById('iframeid').src='home.php'; top.document.getElementById('iframeid').location='home.php'; top.document.getElementById('iframeid').location='WEBSITE/home.php'; ``` It looks like such a simple thing, but I have now spent over 24 hours on this - any clues please?
2015/08/26
[ "https://Stackoverflow.com/questions/32224228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3268334/" ]
You may change the src value of the iframe. example: <https://jsfiddle.net/0g4uoymt/1/> ``` setTimeout(function(){ $("iframe").attr("src", "https://i.imgur.com/eMPOYrO.webm"); }, 1000); ```
OK, i've figured this out now - due to not being able to update the iframe containing the JS, i tried to update the parent iframe and this worked, so to overcome this practically, all i have done is generated a new iframe with the exact same attributes as this one and placed it behind. i can change the source of the new one and just include this functional iframe again at the beginning of each page - thank you for all your help guys. i hope this also helps other people
32,224,228
I have the following layout > > > ``` > _______________________________________________________ > | iframe | > | ______ _____________________________________ ______ | > || menu ||info ||advert|| > || || || || > || || || || > || || || || > || || || || > > ``` > > I have read many pages of answers and they all seem to say the same things, but i still can't get my code to work. I want links in my MENU to change the iframe, which will load new topics each with their own menu. Also some pages in my INFO box need to change the source of the iframe. An example is when I want to log out of my account and return to my homepage: I hit LOGOUT on the MENU, which loads logout.php into INFO and nulls all variables followed by this ... ``` <script type="text/javascript"> top.document.getElementById('iframeid').src='home.php'; </script> ``` I have also tried (and variations of) ``` document.getElementById('iframeid').src='home.php'; parent.document.getElementById('iframeid').src='home.php'; top.document.getElementById('iframeid').location='home.php'; top.document.getElementById('iframeid').location='WEBSITE/home.php'; ``` It looks like such a simple thing, but I have now spent over 24 hours on this - any clues please?
2015/08/26
[ "https://Stackoverflow.com/questions/32224228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3268334/" ]
you can do it via `iframe.src = 'home.php'`. But you need to make sure you execute your JS code is executed after the "onload" event. ``` window.onload = function() { ... } ``` See this [fiddle](http://jsfiddle.net/Lfnhm8eh/) for an example.
OK, i've figured this out now - due to not being able to update the iframe containing the JS, i tried to update the parent iframe and this worked, so to overcome this practically, all i have done is generated a new iframe with the exact same attributes as this one and placed it behind. i can change the source of the new one and just include this functional iframe again at the beginning of each page - thank you for all your help guys. i hope this also helps other people
70,675,940
java.lang.NoSuchFieldError: INDEX\_CONTENT\_TYPE error Elasticsearch Version : 7.16.2 ```java // elasticsearch implementation 'org.springframework.data:spring-data-elasticsearch:4.3.0' implementation 'org.elasticsearch:elasticsearch:7.16.2' implementation 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.16.2' // jackson-core implementation 'com.fasterxml.jackson.core:jackson-core:2.13.1' ``` ```java public <T> void bulk(String indexName, List<T> documents, Class<T> tClass) { elasticsearchIndex.setIndexName(indexName); List<IndexQuery> queries = new ArrayList<>(); for (T document : documents) { IndexQuery query = new IndexQueryBuilder() .withObject(document) .build(); queries.add(query); } IndexOperations indexOps = elasticsearchTemplate.indexOps(tClass); if (!indexOps.exists()) { indexOps.create(); indexOps.putMapping(indexOps.createMapping()); } elasticsearchTemplate.bulkIndex(queries, tClass); // error } ``` ```java @Getter @Setter @ToString @Document(indexName = "#{@elasticsearchIndex.getIndexName()}") ``` java.lang.NoSuchFieldError: INDEX\_CONTENT\_TYPE
2022/01/12
[ "https://Stackoverflow.com/questions/70675940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16855984/" ]
I experienced this same issue. I resolved it by downgrading Elastic Search and dependencies from `7.16` to `7.15`. The current [documentation](https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#preface.requirements) shows that `7.15.2` is the highest version currently support (or tested for release).
The problem you faced has been fixed in version 4.4.0 which supports elasticsearch 7.17.3. Check <https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#new-features.4-4-0> > > 1.1. New in Spring Data Elasticsearch 4.4 > > > * ... > * Upgrade to Elasticsearch 7.17.3. > > >
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
I had a similar case like these. My suggestion is, that you have 2 "base classes" or "super classes". The first class, very general class, represents the "conceptual root" for all containers classes, almost not methods, similar to an interface, and should be like: --- containers.hpp --------------- ``` class Container { protected: int GetValue(); void SetValue(int newValue); size_t GetSize(); void Resize(size_t); }; ``` --- The second class, starts to be a little less conceptual and more "real world": --- mcontainers.hpp ---------------- ``` #include "containers.hpp"; class MethodContainer: public Container { protected: void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` } -- And, finally, some classes that are concrete: --- stacks.hpp ----------- ``` #include "containers.hpp"; #include "mcontainers.hpp"; #define pointer void* class Stack: public MethodContainer { public: // these methods use "mcontainer::Insert", "mcontainer::Replace", etc void Push(pointer Item); void Pop(); pointer Extract(); } ``` --- AS @Chris mentioned, there are several libraries for doing this, but there is always an exception to the rule, and you may want to "reinvent the wheel" if you need it. *I had an application, with its set of libraries, that included some containers / collections. It was made in another progr. langr. and need it to migrate it to C++. Altought, I also check the c++ standard libraries, I ended migrating my libraries to C++, because I had several libraries calling my container libraries, and need it to do it fast.* When using "base classes", you may want to "protect" its members, and "take it to the public", in child classes. I usually don't make "private" fields or methods, unless necessarily. **Summary: Some very common complex stuff (like memory allocation or storage) may be done in your base classes, but, most of those complexity should be leave it to child classes.**
If this container is used only by you in your code and the methods of your interface are sufficient for a specific purpose it is fine doing it this way. However, as soon as someone else is going to use the container, or you plan to use it in other areas I'd recommend adding interface methods working with iterator types, then your container is much more open to be used with the stdlib containers and algorithms. Use the interfaces of the stdlib containers as example.
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
Classes should only provide a basic/minimal interface of **member-functions** (and preferably no data!). You can then add convenience methods as **non-friend non-member** functions. According to the interface-principle however, these functions are still part of your classes interface. You already named the prime reason for this: it makes the class a lot easier to maintain. Also, implementing your "convienence" method part will serve as a nice test to see if you interface is good enough. Note that the member function part of a container should usually be very generic and powerful, and care not about much more than maintaining class invariants. This is most modern opinion on the subject, as far as I know. It is prominently advocated in Scott Meyer's "Effective C++" (In the most recent 3rd edition) and in Sutter's and Alexandrescu's "C++ Coding Standards".
If this container is used only by you in your code and the methods of your interface are sufficient for a specific purpose it is fine doing it this way. However, as soon as someone else is going to use the container, or you plan to use it in other areas I'd recommend adding interface methods working with iterator types, then your container is much more open to be used with the stdlib containers and algorithms. Use the interfaces of the stdlib containers as example.
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
The problem is that as soon as you write another container class (there are plenty of them in the wild, you may need different kinds), you will find that your design squares in O(N \* M), where N is the number of container classes and M the number of algorithms. The solution is to decouple the containers from the algorithms, and this is why iterators were introduced in the STL. There are alternatives to iterators, using eg. polymorphism. You can factor out the traversing interface in an abstract common base class, and implement the algorithms in term of it. In short, keep the most logic out of your container classes.
If this container is used only by you in your code and the methods of your interface are sufficient for a specific purpose it is fine doing it this way. However, as soon as someone else is going to use the container, or you plan to use it in other areas I'd recommend adding interface methods working with iterator types, then your container is much more open to be used with the stdlib containers and algorithms. Use the interfaces of the stdlib containers as example.
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
You should try to keep your interface lean, especially if you might want to implement different container types, e.g. array-based and linked-list. If you provide some basic methods in all your containers, you can create external algorithms which perform certain tasks but which can work on all containers: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); ``` could become ``` template<class ContainerType> void ReplaceAllElementsInContainer(ContainerType& Container, const std::size_t Start, const std::size_t End, const T Value); ``` outside the classes. If you don't do this, you have to write all those methods In all your containers. Another possibility is to use the template method pattern (not related to C++ templates) and write all these methods in a base class (which defines the basic methods as pure virtual and calls them from the implemented "convenience" methods). This leads to possibly many virtual function calls which might not be desired in a container class for performance reasons.
If this container is used only by you in your code and the methods of your interface are sufficient for a specific purpose it is fine doing it this way. However, as soon as someone else is going to use the container, or you plan to use it in other areas I'd recommend adding interface methods working with iterator types, then your container is much more open to be used with the stdlib containers and algorithms. Use the interfaces of the stdlib containers as example.
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
Classes should only provide a basic/minimal interface of **member-functions** (and preferably no data!). You can then add convenience methods as **non-friend non-member** functions. According to the interface-principle however, these functions are still part of your classes interface. You already named the prime reason for this: it makes the class a lot easier to maintain. Also, implementing your "convienence" method part will serve as a nice test to see if you interface is good enough. Note that the member function part of a container should usually be very generic and powerful, and care not about much more than maintaining class invariants. This is most modern opinion on the subject, as far as I know. It is prominently advocated in Scott Meyer's "Effective C++" (In the most recent 3rd edition) and in Sutter's and Alexandrescu's "C++ Coding Standards".
I had a similar case like these. My suggestion is, that you have 2 "base classes" or "super classes". The first class, very general class, represents the "conceptual root" for all containers classes, almost not methods, similar to an interface, and should be like: --- containers.hpp --------------- ``` class Container { protected: int GetValue(); void SetValue(int newValue); size_t GetSize(); void Resize(size_t); }; ``` --- The second class, starts to be a little less conceptual and more "real world": --- mcontainers.hpp ---------------- ``` #include "containers.hpp"; class MethodContainer: public Container { protected: void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` } -- And, finally, some classes that are concrete: --- stacks.hpp ----------- ``` #include "containers.hpp"; #include "mcontainers.hpp"; #define pointer void* class Stack: public MethodContainer { public: // these methods use "mcontainer::Insert", "mcontainer::Replace", etc void Push(pointer Item); void Pop(); pointer Extract(); } ``` --- AS @Chris mentioned, there are several libraries for doing this, but there is always an exception to the rule, and you may want to "reinvent the wheel" if you need it. *I had an application, with its set of libraries, that included some containers / collections. It was made in another progr. langr. and need it to migrate it to C++. Altought, I also check the c++ standard libraries, I ended migrating my libraries to C++, because I had several libraries calling my container libraries, and need it to do it fast.* When using "base classes", you may want to "protect" its members, and "take it to the public", in child classes. I usually don't make "private" fields or methods, unless necessarily. **Summary: Some very common complex stuff (like memory allocation or storage) may be done in your base classes, but, most of those complexity should be leave it to child classes.**
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
The problem is that as soon as you write another container class (there are plenty of them in the wild, you may need different kinds), you will find that your design squares in O(N \* M), where N is the number of container classes and M the number of algorithms. The solution is to decouple the containers from the algorithms, and this is why iterators were introduced in the STL. There are alternatives to iterators, using eg. polymorphism. You can factor out the traversing interface in an abstract common base class, and implement the algorithms in term of it. In short, keep the most logic out of your container classes.
I had a similar case like these. My suggestion is, that you have 2 "base classes" or "super classes". The first class, very general class, represents the "conceptual root" for all containers classes, almost not methods, similar to an interface, and should be like: --- containers.hpp --------------- ``` class Container { protected: int GetValue(); void SetValue(int newValue); size_t GetSize(); void Resize(size_t); }; ``` --- The second class, starts to be a little less conceptual and more "real world": --- mcontainers.hpp ---------------- ``` #include "containers.hpp"; class MethodContainer: public Container { protected: void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` } -- And, finally, some classes that are concrete: --- stacks.hpp ----------- ``` #include "containers.hpp"; #include "mcontainers.hpp"; #define pointer void* class Stack: public MethodContainer { public: // these methods use "mcontainer::Insert", "mcontainer::Replace", etc void Push(pointer Item); void Pop(); pointer Extract(); } ``` --- AS @Chris mentioned, there are several libraries for doing this, but there is always an exception to the rule, and you may want to "reinvent the wheel" if you need it. *I had an application, with its set of libraries, that included some containers / collections. It was made in another progr. langr. and need it to migrate it to C++. Altought, I also check the c++ standard libraries, I ended migrating my libraries to C++, because I had several libraries calling my container libraries, and need it to do it fast.* When using "base classes", you may want to "protect" its members, and "take it to the public", in child classes. I usually don't make "private" fields or methods, unless necessarily. **Summary: Some very common complex stuff (like memory allocation or storage) may be done in your base classes, but, most of those complexity should be leave it to child classes.**
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
You should try to keep your interface lean, especially if you might want to implement different container types, e.g. array-based and linked-list. If you provide some basic methods in all your containers, you can create external algorithms which perform certain tasks but which can work on all containers: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); ``` could become ``` template<class ContainerType> void ReplaceAllElementsInContainer(ContainerType& Container, const std::size_t Start, const std::size_t End, const T Value); ``` outside the classes. If you don't do this, you have to write all those methods In all your containers. Another possibility is to use the template method pattern (not related to C++ templates) and write all these methods in a base class (which defines the basic methods as pure virtual and calls them from the implemented "convenience" methods). This leads to possibly many virtual function calls which might not be desired in a container class for performance reasons.
I had a similar case like these. My suggestion is, that you have 2 "base classes" or "super classes". The first class, very general class, represents the "conceptual root" for all containers classes, almost not methods, similar to an interface, and should be like: --- containers.hpp --------------- ``` class Container { protected: int GetValue(); void SetValue(int newValue); size_t GetSize(); void Resize(size_t); }; ``` --- The second class, starts to be a little less conceptual and more "real world": --- mcontainers.hpp ---------------- ``` #include "containers.hpp"; class MethodContainer: public Container { protected: void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` } -- And, finally, some classes that are concrete: --- stacks.hpp ----------- ``` #include "containers.hpp"; #include "mcontainers.hpp"; #define pointer void* class Stack: public MethodContainer { public: // these methods use "mcontainer::Insert", "mcontainer::Replace", etc void Push(pointer Item); void Pop(); pointer Extract(); } ``` --- AS @Chris mentioned, there are several libraries for doing this, but there is always an exception to the rule, and you may want to "reinvent the wheel" if you need it. *I had an application, with its set of libraries, that included some containers / collections. It was made in another progr. langr. and need it to migrate it to C++. Altought, I also check the c++ standard libraries, I ended migrating my libraries to C++, because I had several libraries calling my container libraries, and need it to do it fast.* When using "base classes", you may want to "protect" its members, and "take it to the public", in child classes. I usually don't make "private" fields or methods, unless necessarily. **Summary: Some very common complex stuff (like memory allocation or storage) may be done in your base classes, but, most of those complexity should be leave it to child classes.**
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
Classes should only provide a basic/minimal interface of **member-functions** (and preferably no data!). You can then add convenience methods as **non-friend non-member** functions. According to the interface-principle however, these functions are still part of your classes interface. You already named the prime reason for this: it makes the class a lot easier to maintain. Also, implementing your "convienence" method part will serve as a nice test to see if you interface is good enough. Note that the member function part of a container should usually be very generic and powerful, and care not about much more than maintaining class invariants. This is most modern opinion on the subject, as far as I know. It is prominently advocated in Scott Meyer's "Effective C++" (In the most recent 3rd edition) and in Sutter's and Alexandrescu's "C++ Coding Standards".
The problem is that as soon as you write another container class (there are plenty of them in the wild, you may need different kinds), you will find that your design squares in O(N \* M), where N is the number of container classes and M the number of algorithms. The solution is to decouple the containers from the algorithms, and this is why iterators were introduced in the STL. There are alternatives to iterators, using eg. polymorphism. You can factor out the traversing interface in an abstract common base class, and implement the algorithms in term of it. In short, keep the most logic out of your container classes.
5,326,525
I'm writing a container class for fun and education. Previously when writing container classes I had limited myself to just a few very basic methods: `GetValue`, `SetValue`, `GetSize` and `Resize`. I did this to avoid "code spaghetti" so my class would be easier to debug. However, it occurred to me that users of the class might want to do more than just simple substitution. So I added a few more methods: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); void Replace(const std::size_t Start, const std::size_t End, const MyClass Other); void Insert(const std::size_t Index, const T Value); void Insert(const std::size_t Index, const MyClass Other); void Delete(const std::size_t Index); void Delete(const std::size_t Start, const std::size_t End); ``` In general, should classes provide only the most basic interface and let the users of the class make their own functions to do the complex stuff? Or should the complex stuff be built-in at the cost of maintainability?
2011/03/16
[ "https://Stackoverflow.com/questions/5326525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497934/" ]
Classes should only provide a basic/minimal interface of **member-functions** (and preferably no data!). You can then add convenience methods as **non-friend non-member** functions. According to the interface-principle however, these functions are still part of your classes interface. You already named the prime reason for this: it makes the class a lot easier to maintain. Also, implementing your "convienence" method part will serve as a nice test to see if you interface is good enough. Note that the member function part of a container should usually be very generic and powerful, and care not about much more than maintaining class invariants. This is most modern opinion on the subject, as far as I know. It is prominently advocated in Scott Meyer's "Effective C++" (In the most recent 3rd edition) and in Sutter's and Alexandrescu's "C++ Coding Standards".
You should try to keep your interface lean, especially if you might want to implement different container types, e.g. array-based and linked-list. If you provide some basic methods in all your containers, you can create external algorithms which perform certain tasks but which can work on all containers: ``` void Replace(const std::size_t Start, const std::size_t End, const T Value); ``` could become ``` template<class ContainerType> void ReplaceAllElementsInContainer(ContainerType& Container, const std::size_t Start, const std::size_t End, const T Value); ``` outside the classes. If you don't do this, you have to write all those methods In all your containers. Another possibility is to use the template method pattern (not related to C++ templates) and write all these methods in a base class (which defines the basic methods as pure virtual and calls them from the implemented "convenience" methods). This leads to possibly many virtual function calls which might not be desired in a container class for performance reasons.
15,863,798
I'm making use of a library that outputs to the console using log4j. However, the method that makes use of the library gets called many times and this means that the console is always full. I need a way of stopping the log4j outputting to the console. I have seen a similar question but could not work out what to do. I think (if I have understood) that there is a method or variable in log4j that I have to reference but have know idea what exactly. Also, what do I import to access log4j? Thanks a lot for any help! Just realised: the output looks like it could be stopped by fixing something? Please check below. Output: ``` log4j:WARN No appenders could be found for logger (eu.medsea.mimeutil.TextMimeDetector). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. ```
2013/04/07
[ "https://Stackoverflow.com/questions/15863798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1875850/" ]
You can change the level log to ERROR for instance to limit the amount of log you have. Usually the log level is located in the log4j.properties file. Ex: ``` # Root logger option log4j.rootLogger=ERROR ```
just realised when running in the terminal it works fine (rather than running in Eclipse). Guessing that means that it cannot find the file mentioned in your answers. Cheers.
15,863,798
I'm making use of a library that outputs to the console using log4j. However, the method that makes use of the library gets called many times and this means that the console is always full. I need a way of stopping the log4j outputting to the console. I have seen a similar question but could not work out what to do. I think (if I have understood) that there is a method or variable in log4j that I have to reference but have know idea what exactly. Also, what do I import to access log4j? Thanks a lot for any help! Just realised: the output looks like it could be stopped by fixing something? Please check below. Output: ``` log4j:WARN No appenders could be found for logger (eu.medsea.mimeutil.TextMimeDetector). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. ```
2013/04/07
[ "https://Stackoverflow.com/questions/15863798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1875850/" ]
You can change the level log to ERROR for instance to limit the amount of log you have. Usually the log level is located in the log4j.properties file. Ex: ``` # Root logger option log4j.rootLogger=ERROR ```
The message `WARN Please initialize the log4j system properly` means (as stated above) that log4j is not initialized properly because your application can't find the `lo4j.properties` file at runtime. You can get a basic version of this file here: [log4j sample configuration file (properties file)](https://stackoverflow.com/questions/2128185/log4j-sample-configuration-file-properties-file) Just put it in your classpath. After we have done this you'll be able to configure the logging level as you want. For example, to turn off all messagges (and keep only actual error messages), in the `lo4j.properties` file you can set the root logger level to error, as explained by *TheEwook*. If you still have the problem then you should check your **build** procedure, but the specific check depends by the tool you use to compile. For example, if you use Eclipse, usually the `lo4j.properties` should be located in the `resources` directory, which should be set a source folder. If you use Maven, usually such file should be located in the `src/main/resources` directory. If you use Ant, probably you need to copy such file using a Ant's task. In other words, regardless of your build procedure, make sure that the `lo4j.properties` is made visible in the runtime classpath.
70,996,317
I have a DataFrame that looks something like this: ``` Col1 Col2 Col3 0 7 11 17 1 13 12 15 2 19 23 14 3 22 19 21 ``` I want to find the row-wise minimum after applying a function, returning the original values before the function was applied, somewhat like using the built-in `min` function in python with the `key` argument. E.g. if the function gives the absolute difference between the values of this DataFrame and a series `s`: ``` 16 10 17 27 ``` i.e. `abs(Col# - s)` then a new DataFrame containing the results of the function would look like: ``` Col1 Col2 Col3 0 9 5 1 1 3 2 5 2 2 6 3 3 5 8 6 ``` The row-wise minimum of this would then be a series looking like: ``` 1 2 2 5 ``` I want a series containing the corresponding values from the original DataFrame: ``` 17 12 19 22 ``` I'm not aware of any minimum-finding function in pandas that has a `key` argument like python's built-in function. I have found a solution that requires iterating through the rows of the DataFrame `df` as follows: ``` l = [] for idx,row in df.iterrows(): l.append(min(row,key = lambda x: abs(x-s[idx]))) pandas.Series(l) ``` I've also considered applying the function to the DataFrame, then finding `idxmin` of each row: ``` df1 = df.apply(lambda x: abs(x-s)) s2 = df1.idxmin(1) ``` which should give `s2` as: ``` Col3 Col2 Col1 Col1 ``` and then is there a way to select values from a DataFrame using column names from a series, i.e. using the column names from `s2`, return a series of values from `df` with the value of `Col3` from the 1st row, the value of `Col2` from the 2nd row, the value of `Col1` from the 3rd row, and the value of `Col1` from the 4th row? At the moment, the only way I know of also involves iteration: ``` l = [] for idx,row in df.iterrows(): l.append(row[s2[idx]]) pandas.Series(l) ``` Are there any better ways of achieving this besides what I've mentioned? Dictionaries used to construct the DataFrame and Series used in the example: ``` data = {'Col1': [7, 13, 19, 22], 'Col2': [11, 12, 23, 19], 'Col3': [17, 15, 14, 21]} s = {0: 16, 1: 10, 2: 17, 3: 27} ```
2022/02/05
[ "https://Stackoverflow.com/questions/70996317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14872471/" ]
As `lookup` is now deprecated, you have to flatten your dataframe manually to retrieve one value per row with `loc`. The first line computes your operation and get the index of the minimum: ``` r = df.sub(sr, axis=0).abs().idxmin(axis=1) df['min_val_with_key'] = df.unstack().loc[zip(r.values, r.index)].values print(df) print(r) # Output of df Col1 Col2 Col3 min_val_with_key 0 7 11 17 17 1 13 12 15 12 2 19 23 14 19 3 22 19 21 22 # Output of r 0 Col3 1 Col2 2 Col1 3 Col1 dtype: object ``` Setup: ``` df = pd.DataFrame({'Col1': [7, 13, 19, 22], 'Col2': [11, 12, 23, 19], 'Col3': [17, 15, 14, 21]}) sr = pd.Series([16, 10, 17, 27]) ```
You can get the indices using idxmin and then just read the single values using loc and append them to a list: ``` df = pd.DataFrame({'Col1': {0: 7, 1: 13, 2: 19, 3: 22}, 'Col2': {0: 11, 1: 12, 2: 23, 3: 19}, 'Col3': {0: 17, 1: 15, 2: 14, 3: 21}}) series = pd.Series([16, 10, 17, 27]) df2 = df.subtract(series, axis=0).abs() minima = df2.idxmin(axis=1) result = [] for row, column in minima.iteritems(): result.append(df.loc[row, column]) df_result = pd.DataFrame(result, columns=["minimum"]) ``` The last part can also be done using a list comprehension: ``` minima = df2.idxmin(axis=1) df_result = pd.DataFrame( [df.loc[row, column] for row, column in minima.iteritems()], columns=["minimum"] ) ```
70,996,317
I have a DataFrame that looks something like this: ``` Col1 Col2 Col3 0 7 11 17 1 13 12 15 2 19 23 14 3 22 19 21 ``` I want to find the row-wise minimum after applying a function, returning the original values before the function was applied, somewhat like using the built-in `min` function in python with the `key` argument. E.g. if the function gives the absolute difference between the values of this DataFrame and a series `s`: ``` 16 10 17 27 ``` i.e. `abs(Col# - s)` then a new DataFrame containing the results of the function would look like: ``` Col1 Col2 Col3 0 9 5 1 1 3 2 5 2 2 6 3 3 5 8 6 ``` The row-wise minimum of this would then be a series looking like: ``` 1 2 2 5 ``` I want a series containing the corresponding values from the original DataFrame: ``` 17 12 19 22 ``` I'm not aware of any minimum-finding function in pandas that has a `key` argument like python's built-in function. I have found a solution that requires iterating through the rows of the DataFrame `df` as follows: ``` l = [] for idx,row in df.iterrows(): l.append(min(row,key = lambda x: abs(x-s[idx]))) pandas.Series(l) ``` I've also considered applying the function to the DataFrame, then finding `idxmin` of each row: ``` df1 = df.apply(lambda x: abs(x-s)) s2 = df1.idxmin(1) ``` which should give `s2` as: ``` Col3 Col2 Col1 Col1 ``` and then is there a way to select values from a DataFrame using column names from a series, i.e. using the column names from `s2`, return a series of values from `df` with the value of `Col3` from the 1st row, the value of `Col2` from the 2nd row, the value of `Col1` from the 3rd row, and the value of `Col1` from the 4th row? At the moment, the only way I know of also involves iteration: ``` l = [] for idx,row in df.iterrows(): l.append(row[s2[idx]]) pandas.Series(l) ``` Are there any better ways of achieving this besides what I've mentioned? Dictionaries used to construct the DataFrame and Series used in the example: ``` data = {'Col1': [7, 13, 19, 22], 'Col2': [11, 12, 23, 19], 'Col3': [17, 15, 14, 21]} s = {0: 16, 1: 10, 2: 17, 3: 27} ```
2022/02/05
[ "https://Stackoverflow.com/questions/70996317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14872471/" ]
You can use the underlying numpy array and [`numpy.choose`](https://numpy.org/doc/stable/reference/generated/numpy.choose.html): ``` s = pd.Series([16,10,17,27]) idx = np.argmin(abs(df.sub(s, axis=0)).values, axis=1) # array([2, 1, 0, 0]) pd.Series(np.choose(idx, df.values.T), index=s.index) # 0 17 # 1 12 # 2 19 # 3 22 # dtype: int64 ```
As `lookup` is now deprecated, you have to flatten your dataframe manually to retrieve one value per row with `loc`. The first line computes your operation and get the index of the minimum: ``` r = df.sub(sr, axis=0).abs().idxmin(axis=1) df['min_val_with_key'] = df.unstack().loc[zip(r.values, r.index)].values print(df) print(r) # Output of df Col1 Col2 Col3 min_val_with_key 0 7 11 17 17 1 13 12 15 12 2 19 23 14 19 3 22 19 21 22 # Output of r 0 Col3 1 Col2 2 Col1 3 Col1 dtype: object ``` Setup: ``` df = pd.DataFrame({'Col1': [7, 13, 19, 22], 'Col2': [11, 12, 23, 19], 'Col3': [17, 15, 14, 21]}) sr = pd.Series([16, 10, 17, 27]) ```
70,996,317
I have a DataFrame that looks something like this: ``` Col1 Col2 Col3 0 7 11 17 1 13 12 15 2 19 23 14 3 22 19 21 ``` I want to find the row-wise minimum after applying a function, returning the original values before the function was applied, somewhat like using the built-in `min` function in python with the `key` argument. E.g. if the function gives the absolute difference between the values of this DataFrame and a series `s`: ``` 16 10 17 27 ``` i.e. `abs(Col# - s)` then a new DataFrame containing the results of the function would look like: ``` Col1 Col2 Col3 0 9 5 1 1 3 2 5 2 2 6 3 3 5 8 6 ``` The row-wise minimum of this would then be a series looking like: ``` 1 2 2 5 ``` I want a series containing the corresponding values from the original DataFrame: ``` 17 12 19 22 ``` I'm not aware of any minimum-finding function in pandas that has a `key` argument like python's built-in function. I have found a solution that requires iterating through the rows of the DataFrame `df` as follows: ``` l = [] for idx,row in df.iterrows(): l.append(min(row,key = lambda x: abs(x-s[idx]))) pandas.Series(l) ``` I've also considered applying the function to the DataFrame, then finding `idxmin` of each row: ``` df1 = df.apply(lambda x: abs(x-s)) s2 = df1.idxmin(1) ``` which should give `s2` as: ``` Col3 Col2 Col1 Col1 ``` and then is there a way to select values from a DataFrame using column names from a series, i.e. using the column names from `s2`, return a series of values from `df` with the value of `Col3` from the 1st row, the value of `Col2` from the 2nd row, the value of `Col1` from the 3rd row, and the value of `Col1` from the 4th row? At the moment, the only way I know of also involves iteration: ``` l = [] for idx,row in df.iterrows(): l.append(row[s2[idx]]) pandas.Series(l) ``` Are there any better ways of achieving this besides what I've mentioned? Dictionaries used to construct the DataFrame and Series used in the example: ``` data = {'Col1': [7, 13, 19, 22], 'Col2': [11, 12, 23, 19], 'Col3': [17, 15, 14, 21]} s = {0: 16, 1: 10, 2: 17, 3: 27} ```
2022/02/05
[ "https://Stackoverflow.com/questions/70996317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14872471/" ]
You can use the underlying numpy array and [`numpy.choose`](https://numpy.org/doc/stable/reference/generated/numpy.choose.html): ``` s = pd.Series([16,10,17,27]) idx = np.argmin(abs(df.sub(s, axis=0)).values, axis=1) # array([2, 1, 0, 0]) pd.Series(np.choose(idx, df.values.T), index=s.index) # 0 17 # 1 12 # 2 19 # 3 22 # dtype: int64 ```
You can get the indices using idxmin and then just read the single values using loc and append them to a list: ``` df = pd.DataFrame({'Col1': {0: 7, 1: 13, 2: 19, 3: 22}, 'Col2': {0: 11, 1: 12, 2: 23, 3: 19}, 'Col3': {0: 17, 1: 15, 2: 14, 3: 21}}) series = pd.Series([16, 10, 17, 27]) df2 = df.subtract(series, axis=0).abs() minima = df2.idxmin(axis=1) result = [] for row, column in minima.iteritems(): result.append(df.loc[row, column]) df_result = pd.DataFrame(result, columns=["minimum"]) ``` The last part can also be done using a list comprehension: ``` minima = df2.idxmin(axis=1) df_result = pd.DataFrame( [df.loc[row, column] for row, column in minima.iteritems()], columns=["minimum"] ) ```
51,482,381
Currently I have a data frame with this line of code that gives me Date and Time as follows: ``` ts = pd.date_range(start=pd.to_datetime(startDate,format='%m-%d-%Yt%H:%M:%S'),periods=len(df),freq='1min') ``` This gives the date range for the dataframe in minute intervals and it runs on a 24hr time frame. I was wondering how to constrict the time frame from 9:30-16:00 (9:30AM-4:00PM) and then move to the next day once it hits 4:00PM. My dataframe right now: ``` df = Time Open High Low Close Volume Date 2018-03-20 09:30:00 93.05 93.32 93.01 93.12 524939 2018-03-20 09:31:00 93.68 93.69 93.53 93.54 77138 2018-03-20 09:32:00 92.82 92.90 92.82 92.88 43388 ... ... ... ... ... ... ... 2018-03-20 15:56:00 93.65 93.71 93.64 93.69 44175 2018-03-20 15:57:00 93.12 93.29 93.00 93.27 166822 2018-03-20 15:58:00 93.28 93.36 93.27 93.33 70954 2018-03-20 15:59:00 93.33 93.43 93.30 93.34 94118 2018-03-20 16:00:00 93.34 93.53 93.34 93.44 75326 2018-03-20 16:01:00 93.43 93.45 93.30 93.30 53790 ``` and I would like the following dataframe to be my result updated\_df = ``` Time Open High Low Close Volume Date 2018-03-20 09:30:00 93.05 93.32 93.01 93.12 524939 2018-03-20 09:31:00 93.68 93.69 93.53 93.54 77138 2018-03-20 09:32:00 92.82 92.90 92.82 92.88 43388 ... ... ... ... ... ... ... 2018-03-20 15:56:00 93.65 93.71 93.64 93.69 44175 2018-03-20 15:57:00 93.12 93.29 93.00 93.27 166822 2018-03-20 15:58:00 93.28 93.36 93.27 93.33 70954 2018-03-20 15:59:00 93.33 93.43 93.30 93.34 94118 2018-03-20 16:00:00 93.34 93.53 93.34 93.44 75326 2018-03-21 09:30:00 93.43 93.45 93.30 93.30 53790 ``` I used ``` df['Date'] = ts.date df['Time'] = ts.time ``` to create the `Date` and `Time` columns, set `Date` as the index and `Time` as the first column.
2018/07/23
[ "https://Stackoverflow.com/questions/51482381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9801467/" ]
Just use simple slicing ``` t = pd.to_datetime(df.Time) df[(t >= '09:30:00') & (t <= '16:00:00')] Date Time Open High Low Close Volume 0 2018-03-20 09:30:00 93.05 93.32 93.01 93.12 524939 1 2018-03-20 09:31:00 93.68 93.69 93.53 93.54 77138 2 2018-03-20 09:32:00 92.82 92.90 92.82 92.88 43388 3 2018-03-20 15:56:00 93.65 93.71 93.64 93.69 44175 4 2018-03-20 15:57:00 93.12 93.29 93.00 93.27 166822 5 2018-03-20 15:58:00 93.28 93.36 93.27 93.33 70954 6 2018-03-20 15:59:00 93.33 93.43 93.30 93.34 94118 7 2018-03-20 16:00:00 93.34 93.53 93.34 93.44 75326 ```
Here is another way using simple indexing, but also using `.between` for succinctness. It still works even if your `Time` column is not of dtype `datetime` (i.e. works with `str` or `O` dtypes): ``` df.loc[df.Time.between('09:30:00', '16:00:00')] Time Open High Low Close Volume Date 2018-03-20 09:30:00 93.05 93.32 93.01 93.12 524939 2018-03-20 09:31:00 93.68 93.69 93.53 93.54 77138 2018-03-20 09:32:00 92.82 92.90 92.82 92.88 43388 2018-03-20 15:56:00 93.65 93.71 93.64 93.69 44175 2018-03-20 15:57:00 93.12 93.29 93.00 93.27 166822 2018-03-20 15:58:00 93.28 93.36 93.27 93.33 70954 2018-03-20 15:59:00 93.33 93.43 93.30 93.34 94118 2018-03-20 16:00:00 93.34 93.53 93.34 93.44 75326 ```
51,482,381
Currently I have a data frame with this line of code that gives me Date and Time as follows: ``` ts = pd.date_range(start=pd.to_datetime(startDate,format='%m-%d-%Yt%H:%M:%S'),periods=len(df),freq='1min') ``` This gives the date range for the dataframe in minute intervals and it runs on a 24hr time frame. I was wondering how to constrict the time frame from 9:30-16:00 (9:30AM-4:00PM) and then move to the next day once it hits 4:00PM. My dataframe right now: ``` df = Time Open High Low Close Volume Date 2018-03-20 09:30:00 93.05 93.32 93.01 93.12 524939 2018-03-20 09:31:00 93.68 93.69 93.53 93.54 77138 2018-03-20 09:32:00 92.82 92.90 92.82 92.88 43388 ... ... ... ... ... ... ... 2018-03-20 15:56:00 93.65 93.71 93.64 93.69 44175 2018-03-20 15:57:00 93.12 93.29 93.00 93.27 166822 2018-03-20 15:58:00 93.28 93.36 93.27 93.33 70954 2018-03-20 15:59:00 93.33 93.43 93.30 93.34 94118 2018-03-20 16:00:00 93.34 93.53 93.34 93.44 75326 2018-03-20 16:01:00 93.43 93.45 93.30 93.30 53790 ``` and I would like the following dataframe to be my result updated\_df = ``` Time Open High Low Close Volume Date 2018-03-20 09:30:00 93.05 93.32 93.01 93.12 524939 2018-03-20 09:31:00 93.68 93.69 93.53 93.54 77138 2018-03-20 09:32:00 92.82 92.90 92.82 92.88 43388 ... ... ... ... ... ... ... 2018-03-20 15:56:00 93.65 93.71 93.64 93.69 44175 2018-03-20 15:57:00 93.12 93.29 93.00 93.27 166822 2018-03-20 15:58:00 93.28 93.36 93.27 93.33 70954 2018-03-20 15:59:00 93.33 93.43 93.30 93.34 94118 2018-03-20 16:00:00 93.34 93.53 93.34 93.44 75326 2018-03-21 09:30:00 93.43 93.45 93.30 93.30 53790 ``` I used ``` df['Date'] = ts.date df['Time'] = ts.time ``` to create the `Date` and `Time` columns, set `Date` as the index and `Time` as the first column.
2018/07/23
[ "https://Stackoverflow.com/questions/51482381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9801467/" ]
Here's one way using `datetime.time`: ``` import datetime df = pd.DataFrame(index=range(100)) ts = pd.date_range(start=pd.to_datetime('now'), periods=len(df), freq='1min') min_time = datetime.time(9, 30, 0) max_time = datetime.time(16, 0, 0) res = ts[(min_time <= ts.time) & (ts.time <= max_time)] print(res) DatetimeIndex(['2018-07-23 15:39:34', '2018-07-23 15:40:34', '2018-07-23 15:41:34', '2018-07-23 15:42:34', '2018-07-23 15:43:34', '2018-07-23 15:44:34', '2018-07-23 15:45:34', '2018-07-23 15:46:34', '2018-07-23 15:47:34', '2018-07-23 15:48:34', '2018-07-23 15:49:34', '2018-07-23 15:50:34', '2018-07-23 15:51:34', '2018-07-23 15:52:34', '2018-07-23 15:53:34', '2018-07-23 15:54:34', '2018-07-23 15:55:34', '2018-07-23 15:56:34', '2018-07-23 15:57:34', '2018-07-23 15:58:34', '2018-07-23 15:59:34'], dtype='datetime64[ns]', freq='T') ```
Here is another way using simple indexing, but also using `.between` for succinctness. It still works even if your `Time` column is not of dtype `datetime` (i.e. works with `str` or `O` dtypes): ``` df.loc[df.Time.between('09:30:00', '16:00:00')] Time Open High Low Close Volume Date 2018-03-20 09:30:00 93.05 93.32 93.01 93.12 524939 2018-03-20 09:31:00 93.68 93.69 93.53 93.54 77138 2018-03-20 09:32:00 92.82 92.90 92.82 92.88 43388 2018-03-20 15:56:00 93.65 93.71 93.64 93.69 44175 2018-03-20 15:57:00 93.12 93.29 93.00 93.27 166822 2018-03-20 15:58:00 93.28 93.36 93.27 93.33 70954 2018-03-20 15:59:00 93.33 93.43 93.30 93.34 94118 2018-03-20 16:00:00 93.34 93.53 93.34 93.44 75326 ```
27,010,104
I get a JSON serialized string to be displayed in UI . I want to show a particular property as hyperlink based on some parameters. What is the best way to approach this?
2014/11/19
[ "https://Stackoverflow.com/questions/27010104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3700866/" ]
Nginx is a web server and is concerned with web server stuff, not with how to run Python programs. uWSGI is an application server and knows how to speak WSGI with Python (and other languages now). Both Nginx and uWSGI speak the uWSGI protocol, which is an efficient protocol over UNIX sockets. Nginx deals with http requests from/responses to the outside world (possibly load balancing, caching, etc.). Your Flask application deals with WSGI requests/responses. uWSGI knows how to start your application (possibly with multiprocessing and/or threading) and bridge the gap between HTTP and WSGI. There are other HTTP servers besides Nginx, and other WSGI servers besides uWSGI, but they all use the same workflow: the HTTP server passes to the WSGI server, which manages your application process and passes back to the HTTP server. This setup is known as a [reverse proxy](https://en.wikipedia.org/wiki/Reverse_proxy). It allows each tool to do what it's good at and not be concerned about the other parts of the process. There is nothing particularly inefficient about it, until you get to truly *massive* scales.
Well, WSGI is a specification for interface between Python applications and web servers. uWSGI is (simply put) a realization of this specification written in C/C++. You can run almost any application on a "serious" webserver (like nginx) by just providing an entry point: ``` def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return ["Hello World"] ``` and then running it like this: ``` uwsgi --http :9090 --wsgi-file file_with_the_code_above.py ``` You can return anything you want instead of ["Hello world"], of course. See <http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html> for more.
103,653
I would appreciate if some trading fundamental analysis expert could please explain me this. Recently I lost basically all my entire life savings, everything i worked for, for over 3 years, waking up daily at 5am. All my money is lost and want to know the solution where and why I was wrong. I am asking for AUDUSD, although similar large consequence was on other symbols too. So recently Apple's bad results in China effected AUDUSD with large downtrend and I was in uptrend position (because of double bottom pattern) for around two months, praying to go up but it didn't. Obviously Apple is USA company so it should effect symbols (their charts) where USD is either on the left part or on the right part (audUSD) but what I don't understand is the following: there where NEGATIVE news about Apple which means NEGATIVE news about USD too. Since USD is on the ***right*** part of trading symbol, this means that consequence on the chart should be the opposite one comparing to the result of event. This is for sure correct so bad news for Apple means bad news for USD, therefore there should be uptrend but major downtrend occur. My first, out of two, questions is: WHY? How is this possible? AUD, i assume so, cannot be effected on this event (negative news for Apple) but why downtrend if USD is on the right side? It should be uptrend. Second question: Would you please kindly forward me to some learning resources (links, ebooks,...) or event consultants where could I learn what affect has particular event on what trading symbol? I would like to learn as much as possible about how parameter A (event A) could affect symbol B. Example: I made another very large loss on USDMXN downtrend position when around three months ago some Mexican institution stopped airport construction. I don't know if they stopped continuation of construction or start of construction. Just because in description of event was mentioned name of the country (Mexico) it was easy to understand that this could affect trading symbols that have either on left or right part of the symbol MXN (i lost the money anyway because i know nothing about events but i traded patterns). But if name of the country was missing in event description article, I would have no idea to which symbols is it related to. So in this second question, I am asking where could I learn more about which event has effect on which symbol... I am not economist and going through thousands of economy books would take decades... Please kindly forward me to some resources, consultants, etc. Thank you in advance and happy, healthy new year.
2019/01/04
[ "https://money.stackexchange.com/questions/103653", "https://money.stackexchange.com", "https://money.stackexchange.com/users/81174/" ]
The drop in AAPL on Jan 3, 2019, was enough to affect several major US stock indices. The falling stock market led many investors to move into bonds, increasing US bond prices and reducing US bond yields. Falling US bond yields tends to drive international investors away from investing in US bonds, leading to a falling US dollar. On Jan 4, the overall US stock market bounced back considerably, even if AAPL did not. This pulled money back out of bonds, increasing yields. Which brought international traders back to the dollar. Here you can see how bond prices (represented by the BND ETF) are negatively correlated with the S&P 500 index (^GSPC) and with AUDUSD over the past 5 days: [![enter image description here](https://i.stack.imgur.com/tC1Nx.png)](https://i.stack.imgur.com/tC1Nx.png) **Edit** The event you're asking about isn't in the earlier chart. Here it is in a chart that doesn't skip times when US markets are closed: [![enter image description here](https://i.stack.imgur.com/JUPDq.png)](https://i.stack.imgur.com/JUPDq.png) Here, I also compared other currencies. It's interesting that JPY and AUD had much bigger reactions than EUR or GBP. Maybe this is related to those countries being in the middle of the trading day when the AAPL announcement was released. Maybe it's totally unrelated to AAPL. At any rate, you should probably re-think your assumption that this was a USD movement and not a AUD (and JPY) movement.
The company suggested that a revenue decline was due to a slowdown in China. A better viewpoint is that the company was simply facing more competition in China and that there was no new news on China. But the idea of a sharp slowdown in China hit the currency markets very hard. Currency traders with the better viewpoint could have just waited for the currency market to recover. According to a Forex chart, the January 02 spike-down in the Australian dollar was about 3.6% . A Forex account would have needed about 6.6% margin deposit to keep from having the position closed-out by the spike. Or otherwise, where was the stop-loss set ? But the Australian dollar does move according to China economic reports because Australia exports to China. Basically to trade currencies the trader must use a source that has a daily calendar of economic reports. A big risk, as is seen here, is an unexpected report.
37,531,931
Instructions for installing operating systems inside a VirtualBox virtual machine sometimes advise that the user ensures that the "Live CD/DVD" checkbox is checked. Other instructions don't mention this checkbox at all. What is the purpose of this checkbox? Does its setting have any functional difference in the operation of a VirtualBox VM? I am able to boot and install live CDs/DVDs regardless of this checkbox's setting, so I'm confused about why it's even there. I could not find a clear reference to this setting in the VirtualBox User Manual either (did I miss it?), leaving me further perplexed. Here is a screenshot of the specific item I'm referencing: [![enter image description here](https://i.stack.imgur.com/mXPFQ.png)](https://i.stack.imgur.com/mXPFQ.png)
2016/05/30
[ "https://Stackoverflow.com/questions/37531931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4463672/" ]
Normally, when you eject a CD from the guest OS (e.g. right-click -> eject in File Explorer), it also removes the ISO from the drive (in VM settings page) and it becomes an empty CD drive. With the "Live CD/DVD" box checked, the ISO is not removed when you eject the disk using the guest OS file explorer and it remains attached to the drive. So for example, if you were to eject the CD before rebooting, you'd still reboot to the Live CD. (without this option, it'd boot to an empty CD drive)
At first I was also unable to find an answer, but the mouseover (in my version) tells me: > > Live CD/DVD > > > When checked, the virtual disk will not be removed > when the guest system ejects it. > > >