qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
9,233,076
I am experiencing inconsistent behavior across machines with conversion to Well-Known Text (WKT) of spatial types in SQL server 2008. It looks as if the data is being stored identically, but the conversion back to WKT acts differently depending on the machine! Here's something I put together to pinpoint the issue: ``...
2012/02/10
[ "https://Stackoverflow.com/questions/9233076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/791838/" ]
To duplicate an object by value instead of reference, you can serialize it (e.g. JSON) and then deserialize it right after. You then have a copy by value. Here's an example ``` ItemVO originalItemVO = new ItemVO(); originalItemVO.ItemId = 1; originalItemVO.ItemCategory = "ORIGINAL"; string json = Newtonsoft.Json.Jso...
class are [reference type](http://msdn.microsoft.com/en-us/library/490f96s2.aspx) and when you change one instance it will change the ariginal refference. so use [value type](http://msdn.microsoft.com/en-us/library/s1ax56ch.aspx) object for overcome your task(ex: use [struct](http://msdn.microsoft.com/en-us/library/ah1...
9,233,076
I am experiencing inconsistent behavior across machines with conversion to Well-Known Text (WKT) of spatial types in SQL server 2008. It looks as if the data is being stored identically, but the conversion back to WKT acts differently depending on the machine! Here's something I put together to pinpoint the issue: ``...
2012/02/10
[ "https://Stackoverflow.com/questions/9233076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/791838/" ]
You would need to construct a new instance of your class, not just assign the variable: ``` duplicateItemVO = new ItemVO { ItemId = originalItemVO.ItemId, ItemCategory = originalItemVO.ItemCategory }; ``` When you're dealing with reference types (any class), just assigning a variable is c...
As of c# 4.5 the base class object contains a method called MemberwiseClone that enables you to perform a shallow copy of that object and returns the result as a new instance. (If a field is a value type, a bit-by-bit copy of the field is performed. If a field is a reference type, the reference is copied but the referr...
9,233,076
I am experiencing inconsistent behavior across machines with conversion to Well-Known Text (WKT) of spatial types in SQL server 2008. It looks as if the data is being stored identically, but the conversion back to WKT acts differently depending on the machine! Here's something I put together to pinpoint the issue: ``...
2012/02/10
[ "https://Stackoverflow.com/questions/9233076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/791838/" ]
class are [reference type](http://msdn.microsoft.com/en-us/library/490f96s2.aspx) and when you change one instance it will change the ariginal refference. so use [value type](http://msdn.microsoft.com/en-us/library/s1ax56ch.aspx) object for overcome your task(ex: use [struct](http://msdn.microsoft.com/en-us/library/ah1...
By Default objects are reference type. Assign the one object to another object its means that you just refer the address of the object.Any changes in any object it will reflect in both. To solve this problem you should have initialize the object using "new" keyword, then add this object value in the first object.
9,233,076
I am experiencing inconsistent behavior across machines with conversion to Well-Known Text (WKT) of spatial types in SQL server 2008. It looks as if the data is being stored identically, but the conversion back to WKT acts differently depending on the machine! Here's something I put together to pinpoint the issue: ``...
2012/02/10
[ "https://Stackoverflow.com/questions/9233076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/791838/" ]
You cannot practically copy an object since they would more likely be of reference types. The ideal method is to serialize or stream the object into a new one - Provided your class is serializable (by providing the [Serializable] attribute in class declaration). ``` private static T Clone<T>(T source) { if...
class are [reference type](http://msdn.microsoft.com/en-us/library/490f96s2.aspx) and when you change one instance it will change the ariginal refference. so use [value type](http://msdn.microsoft.com/en-us/library/s1ax56ch.aspx) object for overcome your task(ex: use [struct](http://msdn.microsoft.com/en-us/library/ah1...
9,233,076
I am experiencing inconsistent behavior across machines with conversion to Well-Known Text (WKT) of spatial types in SQL server 2008. It looks as if the data is being stored identically, but the conversion back to WKT acts differently depending on the machine! Here's something I put together to pinpoint the issue: ``...
2012/02/10
[ "https://Stackoverflow.com/questions/9233076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/791838/" ]
In order to change one instance without changing the other you need to clone the actual values of this instance and not the reference. The pattern used in .Net is to implement ICloneable. So your code would look like this: ``` public class ItemVO: ICloneable { public ItemVO() { ItemId = ""; ...
I suggest using as is in the link below. For me it worked very well. <https://msdn.microsoft.com/en-us/library/system.object.memberwiseclone(v=vs.110).aspx> ``` public Person ShallowCopy () { return (Person) this.MemberwiseClone (); } ```
71,670,205
I have a pandas dataframe that represents the trips I have taken for work. Each row is a single trip, with a column for the date and the number of kilometers traveled. I get reimbursed on a per kilometer basis for every trip besides the first and the last of each day (these are considered ordinary travel to and from w...
2022/03/30
[ "https://Stackoverflow.com/questions/71670205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727632/" ]
You can use [`transform`](https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.transform.html) ``` df = pd.DataFrame({ 'day':(1,1,1,2,2,3,3,3,3), 'dist':(5,2,7,11,11,4,10,5,12), }) def is_claimable(group): claim = np.ones(len(group), dtype='int8') claim[[0, -1]] = 0 re...
if you sort your dataframe by day column: ``` df['claim'] = (df['day'].eq(df['day'].shift()) & df['day'].eq(df['day'].shift(-1))).astype(int) ``` Diff version @ Rodalm ``` (df['day'].diff().eq(0) & df['day'].diff(-1).eq(0)).astype(int) ``` Or use [`GroupBy.cumcount`](https://pandas.pydata.org/docs...
71,670,205
I have a pandas dataframe that represents the trips I have taken for work. Each row is a single trip, with a column for the date and the number of kilometers traveled. I get reimbursed on a per kilometer basis for every trip besides the first and the last of each day (these are considered ordinary travel to and from w...
2022/03/30
[ "https://Stackoverflow.com/questions/71670205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727632/" ]
if you sort your dataframe by day column: ``` df['claim'] = (df['day'].eq(df['day'].shift()) & df['day'].eq(df['day'].shift(-1))).astype(int) ``` Diff version @ Rodalm ``` (df['day'].diff().eq(0) & df['day'].diff(-1).eq(0)).astype(int) ``` Or use [`GroupBy.cumcount`](https://pandas.pydata.org/docs...
One option is to pivot and use `first_valid_index` and `last_valid_index`; of course this will fail if there are duplicates in the combination of index and columns: ```py positions = df.pivot(None, 'day', 'distance') first = positions.apply(pd.Series.first_valid_index) last = positions.apply(pd.Series.last_valid_index...
71,670,205
I have a pandas dataframe that represents the trips I have taken for work. Each row is a single trip, with a column for the date and the number of kilometers traveled. I get reimbursed on a per kilometer basis for every trip besides the first and the last of each day (these are considered ordinary travel to and from w...
2022/03/30
[ "https://Stackoverflow.com/questions/71670205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727632/" ]
You can use [`transform`](https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.transform.html) ``` df = pd.DataFrame({ 'day':(1,1,1,2,2,3,3,3,3), 'dist':(5,2,7,11,11,4,10,5,12), }) def is_claimable(group): claim = np.ones(len(group), dtype='int8') claim[[0, -1]] = 0 re...
You can do `transform` and take the `first` and `last` position ``` g = df.reset_index().groupby('day')['index'] con = (df.index == g.transform('first')) | (df.index == g.transform('last')) df['new'] = (~con).astype(int) df Out[117]: day dist new 0 1 5 0 1 1 2 1 2 1 7 0 3 2 1...
71,670,205
I have a pandas dataframe that represents the trips I have taken for work. Each row is a single trip, with a column for the date and the number of kilometers traveled. I get reimbursed on a per kilometer basis for every trip besides the first and the last of each day (these are considered ordinary travel to and from w...
2022/03/30
[ "https://Stackoverflow.com/questions/71670205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727632/" ]
You can use [`transform`](https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.transform.html) ``` df = pd.DataFrame({ 'day':(1,1,1,2,2,3,3,3,3), 'dist':(5,2,7,11,11,4,10,5,12), }) def is_claimable(group): claim = np.ones(len(group), dtype='int8') claim[[0, -1]] = 0 re...
One option is to pivot and use `first_valid_index` and `last_valid_index`; of course this will fail if there are duplicates in the combination of index and columns: ```py positions = df.pivot(None, 'day', 'distance') first = positions.apply(pd.Series.first_valid_index) last = positions.apply(pd.Series.last_valid_index...
71,670,205
I have a pandas dataframe that represents the trips I have taken for work. Each row is a single trip, with a column for the date and the number of kilometers traveled. I get reimbursed on a per kilometer basis for every trip besides the first and the last of each day (these are considered ordinary travel to and from w...
2022/03/30
[ "https://Stackoverflow.com/questions/71670205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727632/" ]
You can do `transform` and take the `first` and `last` position ``` g = df.reset_index().groupby('day')['index'] con = (df.index == g.transform('first')) | (df.index == g.transform('last')) df['new'] = (~con).astype(int) df Out[117]: day dist new 0 1 5 0 1 1 2 1 2 1 7 0 3 2 1...
One option is to pivot and use `first_valid_index` and `last_valid_index`; of course this will fail if there are duplicates in the combination of index and columns: ```py positions = df.pivot(None, 'day', 'distance') first = positions.apply(pd.Series.first_valid_index) last = positions.apply(pd.Series.last_valid_index...
44,655
This is my routine I’ve been doing for 5 months now: * Monday - Chest, Arms, Cardio * Tuesday - Back, Shoulders. * Wednesday - Legs, Abs, Cardio * Thursday - Chest, Arms * Friday - Back, Shoulders. Cardio * Saturday - Legs, Abs * Sunday - Rest Day 4 different workouts on the muscle groups daily 4 sets inside of each ...
2021/12/21
[ "https://fitness.stackexchange.com/questions/44655", "https://fitness.stackexchange.com", "https://fitness.stackexchange.com/users/37450/" ]
There's a lot going on in that question, but I'll try answering everything one by one: 1. Compound lifts: include more than one muscle group at a time, there is not much more to it definition-wise. The most common compound exercises are: squat, bench press, deadlift, shoulder press, pull up, row. Implementing these in...
Well if you have a sport you want to perform in then there are athleticism programs that prevent injury and develop said athleticism. I have posted one put together from Kneesovertoesguy material and that material aligns with my experience of what increases athleticism and strength. I'll repost it here. Many weight li...
65,905,721
I have an application written in Microsoft Access using VBA which opens Excel files, processes the contents in various ways and then closes them. If the a file cannot be opened, then I need to detect this and skip the file otherwise the application effectively freezes. The Excel files come from numerous sources and if...
2021/01/26
[ "https://Stackoverflow.com/questions/65905721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5021236/" ]
After trying a number of approaches to this I found that restricted files contain a string that indicates that they are secured with rights management. So if you open the file and examine the contents you can detect if it's restricted without trying to load it into Excel. This function works with all the files that I...
There is a clear example in the documentation: ``` Sub ShowPermissions() Dim irmPermission As Office.Permission Dim strIRMInfo As String Set irmPermission = ActiveWorkbook.Permission If irmPermission.Enabled Then strIRMInfo = "Permissions are restricted on this document." & vbCrLf strIR...
8,182,561
I'm restoring a database from a file named `databasebkup.bak` (saved in `C:\\databasebkup.bak`) to a Sql Server 2005 database named MyDatabase. I've referenced `Microsoft.SqlServer.Management.Common;Microsoft.SqlServer.Management.Sdk.Sfc;` and `Microsoft.SqlServer.Management.Smo` in my code, which looks like this: ``...
2011/11/18
[ "https://Stackoverflow.com/questions/8182561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1045045/" ]
Try changing: ``` restore.Database = "C:\\databasebkup.bak"; ``` to: ``` restore.Database = "MyDatabase"; ``` Also, it looks like you're connecting using Windows Authentication; make sure the currently logged in user has the proper rights to do a backup.
You put your backup file name in the wrong property, and completely forgot to specify the database name itself. Read the documentation for the `Database` and `MediaName` properties again. <http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.aspx>
7,034,971
How can i make sure user do not call init, instead client should call sharedSingleton to get a shared instance. ``` @synthesize delegate; - (id)init { self = [super init]; if (self) { // Initialization code here. } return self; } + (LoginController *)sharedSingleton { static LoginControl...
2011/08/12
[ "https://Stackoverflow.com/questions/7034971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746400/" ]
Short answer: you can't; Objective-C has no concept of private methods. Check out the answer to [this similar question](https://stackoverflow.com/questions/195078/is-it-possible-to-make-the-init-method-private-in-objective-c).
You can't make methods private in Objective-C. You could raise a [NSException](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSException_Class/Reference/Reference.html) if the wrong initializer is invoked. ``` - (id)init { [NSException exceptionWithName:@"InvalidOperatio...
7,034,971
How can i make sure user do not call init, instead client should call sharedSingleton to get a shared instance. ``` @synthesize delegate; - (id)init { self = [super init]; if (self) { // Initialization code here. } return self; } + (LoginController *)sharedSingleton { static LoginControl...
2011/08/12
[ "https://Stackoverflow.com/questions/7034971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746400/" ]
I've seen it done two ways. 1. Throw an exception inside `init`. 2. Have the object returned by init be your singleton object. Just to be clear, though, don't do this. It's unnecessary and will make your singletons overly difficult to test and subclass. edit to add examples Throw an exception in init ==============...
You can't make methods private in Objective-C. You could raise a [NSException](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSException_Class/Reference/Reference.html) if the wrong initializer is invoked. ``` - (id)init { [NSException exceptionWithName:@"InvalidOperatio...
7,034,971
How can i make sure user do not call init, instead client should call sharedSingleton to get a shared instance. ``` @synthesize delegate; - (id)init { self = [super init]; if (self) { // Initialization code here. } return self; } + (LoginController *)sharedSingleton { static LoginControl...
2011/08/12
[ "https://Stackoverflow.com/questions/7034971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746400/" ]
Use `UNAVAILABLE_ATTRIBUTE` abolish `init` method, and implement `initPrivate` ``` + (instancetype)shareInstance; - (instancetype)init UNAVAILABLE_ATTRIBUTE; + (instancetype)new UNAVAILABLE_ATTRIBUTE; ``` implement ``` + (instancetype)shareInstance { static MyClass *shareInstance = nil; static dispatch_on...
You can't make methods private in Objective-C. You could raise a [NSException](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSException_Class/Reference/Reference.html) if the wrong initializer is invoked. ``` - (id)init { [NSException exceptionWithName:@"InvalidOperatio...
7,034,971
How can i make sure user do not call init, instead client should call sharedSingleton to get a shared instance. ``` @synthesize delegate; - (id)init { self = [super init]; if (self) { // Initialization code here. } return self; } + (LoginController *)sharedSingleton { static LoginControl...
2011/08/12
[ "https://Stackoverflow.com/questions/7034971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746400/" ]
I've seen it done two ways. 1. Throw an exception inside `init`. 2. Have the object returned by init be your singleton object. Just to be clear, though, don't do this. It's unnecessary and will make your singletons overly difficult to test and subclass. edit to add examples Throw an exception in init ==============...
Short answer: you can't; Objective-C has no concept of private methods. Check out the answer to [this similar question](https://stackoverflow.com/questions/195078/is-it-possible-to-make-the-init-method-private-in-objective-c).
7,034,971
How can i make sure user do not call init, instead client should call sharedSingleton to get a shared instance. ``` @synthesize delegate; - (id)init { self = [super init]; if (self) { // Initialization code here. } return self; } + (LoginController *)sharedSingleton { static LoginControl...
2011/08/12
[ "https://Stackoverflow.com/questions/7034971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746400/" ]
Use `UNAVAILABLE_ATTRIBUTE` abolish `init` method, and implement `initPrivate` ``` + (instancetype)shareInstance; - (instancetype)init UNAVAILABLE_ATTRIBUTE; + (instancetype)new UNAVAILABLE_ATTRIBUTE; ``` implement ``` + (instancetype)shareInstance { static MyClass *shareInstance = nil; static dispatch_on...
Short answer: you can't; Objective-C has no concept of private methods. Check out the answer to [this similar question](https://stackoverflow.com/questions/195078/is-it-possible-to-make-the-init-method-private-in-objective-c).
32,364,126
according [this answer](https://stackoverflow.com/a/29533456/2674303) I try to write my code: pojo: ``` class MyBean{ public String getValueName() { return valueName; } public void setValueName(String valueName) { this.valueName = valueName; } String valueName; } ``` inside co...
2015/09/02
[ "https://Stackoverflow.com/questions/32364126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2674303/" ]
Your problem, I believe, is `@ModelAttribute`. You're asking Spring to map the parameters to `MyBean` object, and the property inside this object is `valueName`. In order Spring to reflect the params to the object, it needs to be in the correct case. You have 2 options: * change the property name to `valuename` in ...
Here is what you can do... Create the domain(POJO) with all lowercase variables ``` public class MyBean{ private String valuename; public String getValuename() { return valuename; } public void setValuename(String valuename) { this.valuename = valuename; } } ``` Then create a c...
32,364,126
according [this answer](https://stackoverflow.com/a/29533456/2674303) I try to write my code: pojo: ``` class MyBean{ public String getValueName() { return valueName; } public void setValueName(String valueName) { this.valueName = valueName; } String valueName; } ``` inside co...
2015/09/02
[ "https://Stackoverflow.com/questions/32364126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2674303/" ]
Your problem, I believe, is `@ModelAttribute`. You're asking Spring to map the parameters to `MyBean` object, and the property inside this object is `valueName`. In order Spring to reflect the params to the object, it needs to be in the correct case. You have 2 options: * change the property name to `valuename` in ...
Actually, you have to change the things in the `CaseInsensitiveRequestFilter` class as per your bean variable name. In your case the variable is `valueName`, so for every request it will convert it as per your variable setter method camel case injection and then match as per your request. Just try for your custom requi...
42,032,180
I've a question about something what really confuses me! Let's watch this code righ here: ``` #ifndef HEADER_H #define HEADER_H #include <iostream> class example; class anything_else; class A { public: A(); }; ... ``` What does `class example;` and `class anything_else;` mean, while `class A {};...
2017/02/03
[ "https://Stackoverflow.com/questions/42032180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6783419/" ]
> > What does `class example;` and `class anything_else;` mean > > > They are declarations of the classes `example` and `anything_else`. They tell the compiler that those are valid class names. This kind of declaration is informally referred to as "forward declaration". > > while `class A {};` gets declared? > ...
if you want to have member variables of a type that have not yet been included you do a **forward declaration** of the type. ``` class X; ``` forward declares the class X so you can have a. e.g. a pointer to that class in our class declaration. ``` class Y { ... X* p; }; ``` later you must supply the definition...
33,257,969
I am in the process of implementing a single page app based on Angular and Node.js, running on a Windows Server within a corporate Windows Active directory domain environment. I know that it is possible to authenticate via AD (by passing a username and password) with the assistance of node packages such as "passport-ld...
2015/10/21
[ "https://Stackoverflow.com/questions/33257969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5471094/" ]
Since 2020, it can also be done with [node-expose-sspi](https://github.com/jlguenego/node-expose-sspi). This module let you deal with the Microsoft SSPI API which was exposed to Node. SSO can be done with both Kerberos and NTLM. It has been tested and is in production as intranet ERP. Note: I am the author of node-ex...
As the author noted in their update, this can be done with [Node-SSPI](https://github.com/abbr/nodesspi). I verified that it also works on a windows domain.
35,958,916
I want to create a link which is catched by **$\_GET** in PHP. Let me explain: Currently i do this in **HTML**: ``` <a href="?contactus">Contact Us</a> ``` And this is what i do in **php**: ``` <?php if (isset($_GET['contactus'])){ include "contactus.php"; } ?> ``` In this case the address become...
2016/03/12
[ "https://Stackoverflow.com/questions/35958916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3922544/" ]
You can use domain.com/contactus and parse the URL ``` $url = "http://domain.com/contactus"; $url = parse_url($url); $path = $url['path']; // contactus echo $path; // contactus ``` You can then use it ``` if ($path == "contactus"){ include "contactus.php"; } ``` You will still need URL rewrite, try a...
hi you need to do like this at page where u set anchor tag do following $url="contact.php?page"='contactus'; give href="$url" . And other side you can use `$urlget = $_GET['page'];` plz note the attribute u used is page so when u try to get in nother page u need to use `$_GET['page']` and you can see url when you c...
35,958,916
I want to create a link which is catched by **$\_GET** in PHP. Let me explain: Currently i do this in **HTML**: ``` <a href="?contactus">Contact Us</a> ``` And this is what i do in **php**: ``` <?php if (isset($_GET['contactus'])){ include "contactus.php"; } ?> ``` In this case the address become...
2016/03/12
[ "https://Stackoverflow.com/questions/35958916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3922544/" ]
you need a .htaccess file to make it work like this: ``` <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^contactus\/?/?$ index.php?contactus </IfModule> ``` and index.php like this ``` <?php if (isset($_GET['contactus'])){ include "contactus.php"; } ?> ```
You can use domain.com/contactus and parse the URL ``` $url = "http://domain.com/contactus"; $url = parse_url($url); $path = $url['path']; // contactus echo $path; // contactus ``` You can then use it ``` if ($path == "contactus"){ include "contactus.php"; } ``` You will still need URL rewrite, try a...
35,958,916
I want to create a link which is catched by **$\_GET** in PHP. Let me explain: Currently i do this in **HTML**: ``` <a href="?contactus">Contact Us</a> ``` And this is what i do in **php**: ``` <?php if (isset($_GET['contactus'])){ include "contactus.php"; } ?> ``` In this case the address become...
2016/03/12
[ "https://Stackoverflow.com/questions/35958916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3922544/" ]
you need a .htaccess file to make it work like this: ``` <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^contactus\/?/?$ index.php?contactus </IfModule> ``` and index.php like this ``` <?php if (isset($_GET['contactus'])){ include "contactus.php"; } ?> ```
hi you need to do like this at page where u set anchor tag do following $url="contact.php?page"='contactus'; give href="$url" . And other side you can use `$urlget = $_GET['page'];` plz note the attribute u used is page so when u try to get in nother page u need to use `$_GET['page']` and you can see url when you c...
259,658
When the user clicks the "**Create an Account**" button on the login page, instead of being directed to the account creation page they are taken to the home page. > > I cannot see any reason for this, this feature used to work. I can > only guess that it has something to do with the **SSL > implementation**. Does a...
2019/01/29
[ "https://magento.stackexchange.com/questions/259658", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/76620/" ]
you can get all `products` with `qty` using below code ``` <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $StockState = $objectManager->get('\Magento\CatalogInventor...
**Collection stock item from Resource Model** ``` $resource = $objectManager->create('Magento\CatalogInventory\Model\ResourceModel\Stock\Item'); $select = $resource->getConnection()->select()->from($resource->getMainTable()); $stockItems = $resource->getConnection()->fetchAll($select); foreach($stockItems as $_item){ ...
259,658
When the user clicks the "**Create an Account**" button on the login page, instead of being directed to the account creation page they are taken to the home page. > > I cannot see any reason for this, this feature used to work. I can > only guess that it has something to do with the **SSL > implementation**. Does a...
2019/01/29
[ "https://magento.stackexchange.com/questions/259658", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/76620/" ]
Instead of using Object Manager, use dependency structure for good practise. ``` /** * @var \Magento\Framework\View\Result\PageFactory */ protected $productFactory; public function __construct( ..... \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productFactory ..... ) { ..... $t...
**Collection stock item from Resource Model** ``` $resource = $objectManager->create('Magento\CatalogInventory\Model\ResourceModel\Stock\Item'); $select = $resource->getConnection()->select()->from($resource->getMainTable()); $stockItems = $resource->getConnection()->fetchAll($select); foreach($stockItems as $_item){ ...
55,472,932
I have an Array of Objects Like: ``` [ { id: 8, username: 'peter' ,weight:80,date:'2019-10-14'}, { id: 1, username: 'harry' ,weight:80,date:'2019-01-01'}, { id: 2, username: 'harry' ,weight:84,date:'2019-02-21'}, { id: 3, username: 'john' ,weight:80,date:'2019-03-11'}, { id: 7, username: 'john' ,weight:80,date:'...
2019/04/02
[ "https://Stackoverflow.com/questions/55472932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5470302/" ]
You could take a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and get the values. ```js var array = [{ id: 1, username: 'harry', weight: 80, date: '2019-01-01' }, { id: 2, username: 'harry', weight: 84, date: '2019-02-21' }, { id: 3, username: 'john', weight: 80, date: ...
Check the array from end for current object `username` and previous object `username`. If they are same break the loop, else push in the array. ```js const input = [ { id: 1, username: 'harry' ,weight:80,date:'2019-01-01'}, { id: 2, username: 'harry' ,weight:84,date:'2019-02-21'}, { id: 3, usern...
55,472,932
I have an Array of Objects Like: ``` [ { id: 8, username: 'peter' ,weight:80,date:'2019-10-14'}, { id: 1, username: 'harry' ,weight:80,date:'2019-01-01'}, { id: 2, username: 'harry' ,weight:84,date:'2019-02-21'}, { id: 3, username: 'john' ,weight:80,date:'2019-03-11'}, { id: 7, username: 'john' ,weight:80,date:'...
2019/04/02
[ "https://Stackoverflow.com/questions/55472932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5470302/" ]
You could take a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and get the values. ```js var array = [{ id: 1, username: 'harry', weight: 80, date: '2019-01-01' }, { id: 2, username: 'harry', weight: 84, date: '2019-02-21' }, { id: 3, username: 'john', weight: 80, date: ...
Maps and Sets inherently only hold unique values. You can use this as following: ```js var myMap = [ { id: 1, username: 'harry' ,weight:80,date:'2019-01-01'}, { id: 2, username: 'harry' ,weight:84,date:'2019-02-21'}, { id: 3, username: 'john' ,weight:80,date:'2019-03-11'}, { id: 4, username: 'peter' ,weight:8...
25,910,672
Trying to add the id of a parent field to the child foreign key field in my form. The user has a list of locations. From that location they can add an assessment of that location. Instead of the assessment form giving me a list of all locations, I would like it to auto select the right one urls.py ``` url(r'^accounts...
2014/09/18
[ "https://Stackoverflow.com/questions/25910672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3972986/" ]
If acceptable you can just do this, ``` $(document).ready(function () { $('[id$=txt1]').numeric({ allow: "." }); $('[id$=txt1]').numeric(); }); ``` Where txt1 is the client instance name of the textbox where user is inputting data. Wrong answer, Delete not working. Cant be used as the same will allow multiple "." ...
You should should check the user input on each click. For example: if the input field id='MyInputField" you should use the following code ``` var decimalsRestrictions = function (field) { $(field).bind("propertychange input", function (e) { var resVal = twoDecimalsRestrictions(field.val()); if (field.val() !=...
25,910,672
Trying to add the id of a parent field to the child foreign key field in my form. The user has a list of locations. From that location they can add an assessment of that location. Instead of the assessment form giving me a list of all locations, I would like it to auto select the right one urls.py ``` url(r'^accounts...
2014/09/18
[ "https://Stackoverflow.com/questions/25910672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3972986/" ]
You can use regular expression to validate decimal number ``` var input = control.value; var exp = /^\-?\d*\.?\d*$/; if(!exp.test(input)) { control.value=""; alert('Invalid Value') } ```
You should should check the user input on each click. For example: if the input field id='MyInputField" you should use the following code ``` var decimalsRestrictions = function (field) { $(field).bind("propertychange input", function (e) { var resVal = twoDecimalsRestrictions(field.val()); if (field.val() !=...
53,477,669
I have an application, which is written in codeigniter. I use CI provided session library for session management purposes. It is deployed on live. When I connect the application to WiFi or LAN in my laboratory (college) network, session data get unsetted randomly. And the application logs out the current user. But wh...
2018/11/26
[ "https://Stackoverflow.com/questions/53477669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9470634/" ]
After monitoring the logs, I understood the following points, * There is a parameter in the session library `sess_match_ip` * first, you have to set it to false * then you have to check whether the following loop in session library is getting executed or not, ``` if ($this->sess_match_ip == TRUE AND $session['ip_addr...
If the IP changes *while you are logged in* and that seems to be causing the user to log-out, it's probably because CI sessions can be configured (or not) to enforce that sessions are tied to an IP address. Please note that while this is easily configurable, if you're using CI's database driver for session data, you'll...
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
You could include checking on `keyup` as well, e.g: ``` $('#visitID').on('change keyup', function () { this.value ? $("#saveandclosebutton").show() : $("#saveandclosebutton").hide(); }); ``` [**jsFiddle here**](http://jsfiddle.net/b2XmK/3/) Of course you'd need to set the button to be `display:none` initally, as ...
Try Keyup. Change it to: ``` $('#visitID').keyup(function () { var len = $('#visitID').val().length; if ( len == 0) $("#saveandclosebutton").hide(); else $("#saveandclosebutton").show(); }); ```
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
I guess that the `saveandclosebutton` is called differently. Try first to see if the main logic is working at all: ``` $('#visitID').on('change keyup', function () { console.log($('#visitID').val().length); }); ``` and check if the console has any output at all. You can add the `keyup` as I did so that the che...
Try to use **[.is()](http://api.jquery.com/is/)** with **[:empty](http://api.jquery.com/empty-selector/)** selector as well as using **[keyup](http://api.jquery.com/keyup/)** event to have live update when you're typing text inside your input: ``` $('#visitID').on('change keyup', function () { if ($(this).is(':emp...
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
You could include checking on `keyup` as well, e.g: ``` $('#visitID').on('change keyup', function () { this.value ? $("#saveandclosebutton").show() : $("#saveandclosebutton").hide(); }); ``` [**jsFiddle here**](http://jsfiddle.net/b2XmK/3/) Of course you'd need to set the button to be `display:none` initally, as ...
Try to use **[.is()](http://api.jquery.com/is/)** with **[:empty](http://api.jquery.com/empty-selector/)** selector as well as using **[keyup](http://api.jquery.com/keyup/)** event to have live update when you're typing text inside your input: ``` $('#visitID').on('change keyup', function () { if ($(this).is(':emp...
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
Bind the event handler to both the `keyup` and `change` events, but you also want to cause the event handler to get executed when the page loads: ``` $('#visitID').on('keyup change', function() { $('#saveandclosebutton').toggle($(this).val().length > 0); }).change(); ``` [jsfiddle](http://jsfiddle.net/29DSq/)
Try [.toggle( showOrHide )](http://api.jquery.com/toggle/#toggle-showOrHide) ``` $('#visitID').on('change keyup', function () { $("#saveandclosebutton").toggle(this.value.length == 0); }); ```
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
You could include checking on `keyup` as well, e.g: ``` $('#visitID').on('change keyup', function () { this.value ? $("#saveandclosebutton").show() : $("#saveandclosebutton").hide(); }); ``` [**jsFiddle here**](http://jsfiddle.net/b2XmK/3/) Of course you'd need to set the button to be `display:none` initally, as ...
I guess that the `saveandclosebutton` is called differently. Try first to see if the main logic is working at all: ``` $('#visitID').on('change keyup', function () { console.log($('#visitID').val().length); }); ``` and check if the console has any output at all. You can add the `keyup` as I did so that the che...
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
Bind the event handler to both the `keyup` and `change` events, but you also want to cause the event handler to get executed when the page loads: ``` $('#visitID').on('keyup change', function() { $('#saveandclosebutton').toggle($(this).val().length > 0); }).change(); ``` [jsfiddle](http://jsfiddle.net/29DSq/)
Try to use **[.is()](http://api.jquery.com/is/)** with **[:empty](http://api.jquery.com/empty-selector/)** selector as well as using **[keyup](http://api.jquery.com/keyup/)** event to have live update when you're typing text inside your input: ``` $('#visitID').on('change keyup', function () { if ($(this).is(':emp...
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
Bind the event handler to both the `keyup` and `change` events, but you also want to cause the event handler to get executed when the page loads: ``` $('#visitID').on('keyup change', function() { $('#saveandclosebutton').toggle($(this).val().length > 0); }).change(); ``` [jsfiddle](http://jsfiddle.net/29DSq/)
Try Keyup. Change it to: ``` $('#visitID').keyup(function () { var len = $('#visitID').val().length; if ( len == 0) $("#saveandclosebutton").hide(); else $("#saveandclosebutton").show(); }); ```
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
I guess that the `saveandclosebutton` is called differently. Try first to see if the main logic is working at all: ``` $('#visitID').on('change keyup', function () { console.log($('#visitID').val().length); }); ``` and check if the console has any output at all. You can add the `keyup` as I did so that the che...
Try Keyup. Change it to: ``` $('#visitID').keyup(function () { var len = $('#visitID').val().length; if ( len == 0) $("#saveandclosebutton").hide(); else $("#saveandclosebutton").show(); }); ```
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
I guess that the `saveandclosebutton` is called differently. Try first to see if the main logic is working at all: ``` $('#visitID').on('change keyup', function () { console.log($('#visitID').val().length); }); ``` and check if the console has any output at all. You can add the `keyup` as I did so that the che...
Try [.toggle( showOrHide )](http://api.jquery.com/toggle/#toggle-showOrHide) ``` $('#visitID').on('change keyup', function () { $("#saveandclosebutton").toggle(this.value.length == 0); }); ```
22,766,392
I want to check if the input is empty or not **while the user is typing** this is my code ``` $('#visitID').on('change', function () { if ($('#visitID').val().length == 0) { $("#saveandclosebutton").hide(); } else { $("#saveandclosebutton").show(); } }); ``` but ...
2014/03/31
[ "https://Stackoverflow.com/questions/22766392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3195376/" ]
Bind the event handler to both the `keyup` and `change` events, but you also want to cause the event handler to get executed when the page loads: ``` $('#visitID').on('keyup change', function() { $('#saveandclosebutton').toggle($(this).val().length > 0); }).change(); ``` [jsfiddle](http://jsfiddle.net/29DSq/)
I guess that the `saveandclosebutton` is called differently. Try first to see if the main logic is working at all: ``` $('#visitID').on('change keyup', function () { console.log($('#visitID').val().length); }); ``` and check if the console has any output at all. You can add the `keyup` as I did so that the che...
46,958,995
I have been trying to mock the callback with no success. Here is an example code: ``` public class TestService { private UtilService utilService; private LoadingCache<String, String> cache= CacheBuilder.newBuilder() .build(new CacheLoader<String, String>() { public String load(Stri...
2017/10/26
[ "https://Stackoverflow.com/questions/46958995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/227035/" ]
Your issue is that you've created the spy yourself. So the callback will be tied to the real method. Allowing Mockito to deal with the object creation solves the issue. (I'm using mockito 1.10.19) I've refactored your test code: ``` @RunWith(MockitoJUnitRunner.class) public class TestServiceTest { public static ...
When getKey() method is invoked inside the load() method, it is called inside TestService class, not through the mock-proxy. That's why ``` doReturn(MYKEY).when(testService).getKey(MYKEY); ``` doesn't work. However, you might and should mock UtilService and see that is accessed only once.
213,016
Please suggest books/references on ARDL model and ARDL bounds test approach to study.
2016/05/17
[ "https://stats.stackexchange.com/questions/213016", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/35988/" ]
A classical textbook on cointegration in the ADL/ECM framework is [Co-integration, Error Correction, and the Econometric Analysis of Non-Stationary Data](https://global.oup.com/academic/product/co-integration-error-correction-and-the-econometric-analysis-of-non-stationary-data-9780198288107?q=cointegration&lang=en&cc=f...
Btw, there is now a user-written Gretl package for running a bootstrap version of both the PSS and BDM bounds test on cointegration. For an example see [here](https://sites.google.com/site/arturtarassow/it-s-not-really-ablog-but-rather-a-note-to-myself/replicating-eviews-blog-entry-on-ardl-based-cointegration-tests).
213,016
Please suggest books/references on ARDL model and ARDL bounds test approach to study.
2016/05/17
[ "https://stats.stackexchange.com/questions/213016", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/35988/" ]
A classical textbook on cointegration in the ADL/ECM framework is [Co-integration, Error Correction, and the Econometric Analysis of Non-Stationary Data](https://global.oup.com/academic/product/co-integration-error-correction-and-the-econometric-analysis-of-non-stationary-data-9780198288107?q=cointegration&lang=en&cc=f...
The GRETL progrmme will be more useful, if it includes the test for degeneration case 1 using ARDL Bootstrap method along with PSS and BDM bounds test on cointegration.. McNown et al. (2016) define the following degenerate cases and the degenerate cases cannot be cointegration. 1. Degenerate case #1 occurs when the F-...
213,016
Please suggest books/references on ARDL model and ARDL bounds test approach to study.
2016/05/17
[ "https://stats.stackexchange.com/questions/213016", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/35988/" ]
The GRETL progrmme will be more useful, if it includes the test for degeneration case 1 using ARDL Bootstrap method along with PSS and BDM bounds test on cointegration.. McNown et al. (2016) define the following degenerate cases and the degenerate cases cannot be cointegration. 1. Degenerate case #1 occurs when the F-...
Btw, there is now a user-written Gretl package for running a bootstrap version of both the PSS and BDM bounds test on cointegration. For an example see [here](https://sites.google.com/site/arturtarassow/it-s-not-really-ablog-but-rather-a-note-to-myself/replicating-eviews-blog-entry-on-ardl-based-cointegration-tests).
31,896,084
I am creating a text based game using C++ for a school project, the game works by allowing the user to pick a choice from a list of options in each scene; similar to how the games hosted by [Choice of Games](https://www.choiceofgames.com/category/our-games/) work. As a result of this I have a large amount of text that ...
2015/08/08
[ "https://Stackoverflow.com/questions/31896084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4674340/" ]
I recommend using external files. It makes changing the content much easier and doesn't require recompiling the entire program for a simple typo. You can use one file and just separate each paragraph with a blank line. Grabbing "all text between blank lines" at that point is trivial. If the choices cause the paragrap...
If you do not plan to translate you game to other languages, you are on your own, both approaches have their pros and cons: * text in source: easy to write, text is near the place where it is used. * text in resource files: easier to remove duplicate strings, forces a better structure of text data. If you simply imag...
31,896,084
I am creating a text based game using C++ for a school project, the game works by allowing the user to pick a choice from a list of options in each scene; similar to how the games hosted by [Choice of Games](https://www.choiceofgames.com/category/our-games/) work. As a result of this I have a large amount of text that ...
2015/08/08
[ "https://Stackoverflow.com/questions/31896084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4674340/" ]
I recommend using external files. It makes changing the content much easier and doesn't require recompiling the entire program for a simple typo. You can use one file and just separate each paragraph with a blank line. Grabbing "all text between blank lines" at that point is trivial. If the choices cause the paragrap...
Storing text in the program files is not a good coding practice. This would result in unnecessary code bloat (it's not even code) and the need to recompile if you need to change the text. A simple solution would be to create a text file with careful formatting like line numbers or whitespace that would allow you to pu...
31,896,084
I am creating a text based game using C++ for a school project, the game works by allowing the user to pick a choice from a list of options in each scene; similar to how the games hosted by [Choice of Games](https://www.choiceofgames.com/category/our-games/) work. As a result of this I have a large amount of text that ...
2015/08/08
[ "https://Stackoverflow.com/questions/31896084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4674340/" ]
Please don't put displayed text into code. That's an antipattern. You have to recompile your game for every minor text change like fixing typos, and for major changes like translating into other languages. Convention for most programming languages is to put all the displayed text into (a few) resource files or proper...
If you do not plan to translate you game to other languages, you are on your own, both approaches have their pros and cons: * text in source: easy to write, text is near the place where it is used. * text in resource files: easier to remove duplicate strings, forces a better structure of text data. If you simply imag...
31,896,084
I am creating a text based game using C++ for a school project, the game works by allowing the user to pick a choice from a list of options in each scene; similar to how the games hosted by [Choice of Games](https://www.choiceofgames.com/category/our-games/) work. As a result of this I have a large amount of text that ...
2015/08/08
[ "https://Stackoverflow.com/questions/31896084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4674340/" ]
Please don't put displayed text into code. That's an antipattern. You have to recompile your game for every minor text change like fixing typos, and for major changes like translating into other languages. Convention for most programming languages is to put all the displayed text into (a few) resource files or proper...
Storing text in the program files is not a good coding practice. This would result in unnecessary code bloat (it's not even code) and the need to recompile if you need to change the text. A simple solution would be to create a text file with careful formatting like line numbers or whitespace that would allow you to pu...
33,336,480
In a slightly different question from [this other](https://stackoverflow.com/questions/33336086/bash-in-file-converting-first-field-of-a-text-file-from-decimal-to-hexadecimal), I would like to convert any number in a text file from **decimal to hexadecimal**. A number is here defined by `a set of numeric characters t...
2015/10/25
[ "https://Stackoverflow.com/questions/33336480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1461017/" ]
Since you're okay with using `grep` and `bc` in a pipe, it's clear that you don't want a solution in pure `sh`, but are happy to use external tools. ``` perl -pe 's/([0-9]+)/sprintf "%02X", $1/ge' myfile.txt ```
A Python solution (thanks to the suggestion from user *4ae1e1*): ``` $ cat convert.py #!/usr/bin/env python3 import fileinput import re for line in fileinput.input(): print(re.sub("\d+", lambda matchobj: "%X" % int(matchobj.group(0)), line), end="") ``` Example usage: ``` cat MyFile.txt | ./convert.py ``` o...
33,336,480
In a slightly different question from [this other](https://stackoverflow.com/questions/33336086/bash-in-file-converting-first-field-of-a-text-file-from-decimal-to-hexadecimal), I would like to convert any number in a text file from **decimal to hexadecimal**. A number is here defined by `a set of numeric characters t...
2015/10/25
[ "https://Stackoverflow.com/questions/33336480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1461017/" ]
Since you're okay with using `grep` and `bc` in a pipe, it's clear that you don't want a solution in pure `sh`, but are happy to use external tools. ``` perl -pe 's/([0-9]+)/sprintf "%02X", $1/ge' myfile.txt ```
dec2hex command will do the task.
4,075,196
I am looking for a solution to a particular task of manipulating a rectangle out of a hole. I will be happy for any suggestions. I wasn't able to find any simplifications (e.g.: transferring the problem to a problem of manipulating a rod), which would lead to an equivalent optimum. Problem: **Minimize height, above a ...
2021/03/24
[ "https://math.stackexchange.com/questions/4075196", "https://math.stackexchange.com", "https://math.stackexchange.com/users/886460/" ]
Hint. A figure worth a thousand words. [![enter image description here](https://i.stack.imgur.com/ccGG6.jpg)](https://i.stack.imgur.com/ccGG6.jpg) NOTE Attached a MATHEMATICA script which calculates the maximum height clearance needed to free the frame ``` parms1 = {w -> 1, a -> 1.2, h -> 1.5, b -> 1.9}; parms2 = ...
Hint: Here is what the diagram should look like [![enter image description here](https://i.stack.imgur.com/3CP9Y.png)](https://i.stack.imgur.com/3CP9Y.png) Notice that the left most point of the rectangle is on the line that is with the floor? Could you take it from there using similar triangles? Note that there is...
51,307,156
First of all, I wanted to figure out how to even write an array of objects (like in js) in sql statement, and I am found nothing on the internet... I can certainly just repeating all the insert statement, but I really just want to loop through a dataset and inject them into a table for a set of columns with exactly th...
2018/07/12
[ "https://Stackoverflow.com/questions/51307156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2646226/" ]
You can use `jsonb_array_elements` to extract each JSON from the array, then use that as the source for an INSERT: ``` create table x(name text, gender text); insert into x (name, gender) select t ->> 'name', t ->> 'gender' from jsonb_array_elements( '[ { "name": "abc", "gender": "male" }, { "name":...
``` select * from json_each( (REPLACE( REPLACE( REPLACE( your_input, '},{' , ' ' ) ,'[','{') ,']','}'))::json) ``` this will output a table ``` name | gender -----+------- abc | male bcc | female ccc | male ``` you can insert it in any table you want
13,798,539
I an creating a sample example to call link using WebClient using async and await method now I want to attach cancel async call functionality also. But I am not able to get CancellationTokenSource token and attach DownloadStringTaskAsync to this cancellation token. Following Is my code can anyone tell me how to accompl...
2012/12/10
[ "https://Stackoverflow.com/questions/13798539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1101776/" ]
The async capabilities of `WebClient` predate .Net 4.5, so it supports [the Task-based Asynchronous Pattern](http://msdn.microsoft.com/en-us/library/hh873175.aspx) only partially. That includes having its own cancellation mechanism: [the `CancelAsync()` method](http://msdn.microsoft.com/en-us/library/system.net.webclie...
`WebClient` doesn't support cancellation. I recommend you use a newer type such as `HttpClient`: ``` ... cts = new CancellationTokenSource(); string result; using (var client = new HttpClient()) using (var response = await client.GetAsync("http://gyorgybalassy.wordpress.com", cts.Token)) { result = await response.Co...
13,798,539
I an creating a sample example to call link using WebClient using async and await method now I want to attach cancel async call functionality also. But I am not able to get CancellationTokenSource token and attach DownloadStringTaskAsync to this cancellation token. Following Is my code can anyone tell me how to accompl...
2012/12/10
[ "https://Stackoverflow.com/questions/13798539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1101776/" ]
Extension methods based on svick's answer: ``` public static async Task<string> DownloadStringTaskAsync(this WebClient webClient, string url, CancellationToken cancellationToken) { using (cancellationToken.Register(webClient.CancelAsync)) { return await webClient.DownloadStringTaskAsync(url); } } publ...
`WebClient` doesn't support cancellation. I recommend you use a newer type such as `HttpClient`: ``` ... cts = new CancellationTokenSource(); string result; using (var client = new HttpClient()) using (var response = await client.GetAsync("http://gyorgybalassy.wordpress.com", cts.Token)) { result = await response.Co...
13,798,539
I an creating a sample example to call link using WebClient using async and await method now I want to attach cancel async call functionality also. But I am not able to get CancellationTokenSource token and attach DownloadStringTaskAsync to this cancellation token. Following Is my code can anyone tell me how to accompl...
2012/12/10
[ "https://Stackoverflow.com/questions/13798539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1101776/" ]
The async capabilities of `WebClient` predate .Net 4.5, so it supports [the Task-based Asynchronous Pattern](http://msdn.microsoft.com/en-us/library/hh873175.aspx) only partially. That includes having its own cancellation mechanism: [the `CancelAsync()` method](http://msdn.microsoft.com/en-us/library/system.net.webclie...
Extension methods based on svick's answer: ``` public static async Task<string> DownloadStringTaskAsync(this WebClient webClient, string url, CancellationToken cancellationToken) { using (cancellationToken.Register(webClient.CancelAsync)) { return await webClient.DownloadStringTaskAsync(url); } } publ...
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
Hyperphysics has a pretty good section about opamps: * [Operational Amplifier Concepts](http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampcon.html) * [Op-amp Varieties](http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampvar.html)
I know it's not all online, but [the Art of Electronic by Horowitz and Hill](http://books.google.com/books?id=bkOMDgwFA28C&printsec=frontcover&source=gbs%5Fnavlinks%5Fs#v=onepage&q=&f=false) is fantastic. It's basically the only book you need for the first 2 years of learning electronics (especially if you don't have a...
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
I know it's not all online, but [the Art of Electronic by Horowitz and Hill](http://books.google.com/books?id=bkOMDgwFA28C&printsec=frontcover&source=gbs%5Fnavlinks%5Fs#v=onepage&q=&f=false) is fantastic. It's basically the only book you need for the first 2 years of learning electronics (especially if you don't have a...
Falstad [Falstad Circuit index](http://www.falstad.com/circuit/e-index.html) has an excellent Java applet that allows you to do virtual prototyping with various types of circuits. Has a nice section on **Op amps**, whats great is the built in O'scope, volt and current meters. Right clicking on a template component in ...
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
Falstad [Falstad Circuit index](http://www.falstad.com/circuit/e-index.html) has an excellent Java applet that allows you to do virtual prototyping with various types of circuits. Has a nice section on **Op amps**, whats great is the built in O'scope, volt and current meters. Right clicking on a template component in ...
[**Op Amps for Everyone**](http://focus.ti.com/lit/an/slod006b/slod006b.pdf) (2.0 MB PDF) by Texas Instruments is a very good reference. It covers almost any aspect you might need. Even single supply opamp techniques.
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
I know it's not all online, but [the Art of Electronic by Horowitz and Hill](http://books.google.com/books?id=bkOMDgwFA28C&printsec=frontcover&source=gbs%5Fnavlinks%5Fs#v=onepage&q=&f=false) is fantastic. It's basically the only book you need for the first 2 years of learning electronics (especially if you don't have a...
This one helped me a lot for a Devices class which included op-amps. Really good animations, and covers most types (inverter, differentiator...) needed for a starting point.[link text] <http://electronics.wisc-online.com/Search.asp?search=op+amp> [1]
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
I know it's not all online, but [the Art of Electronic by Horowitz and Hill](http://books.google.com/books?id=bkOMDgwFA28C&printsec=frontcover&source=gbs%5Fnavlinks%5Fs#v=onepage&q=&f=false) is fantastic. It's basically the only book you need for the first 2 years of learning electronics (especially if you don't have a...
Try [Opamps for Everyone](http://focus.ti.com/lit/an/slod006b/slod006b.pdf) (warning -- large pdf, and some TI bias) It has lots to teach, covers beginning to somewhat advanced topics, and it's free.
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
Hyperphysics has a pretty good section about opamps: * [Operational Amplifier Concepts](http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampcon.html) * [Op-amp Varieties](http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampvar.html)
The "IC Opamp Cookbook" paperback was ~THE~ standard for hobbyist electronics back in the 80s. Still a good reference.
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
There are a couple of very good tutorials at Analog Devices and Texas Instruments. The TI one is called "[Handbook of Operational Amplifiers](http://focus.ti.com/lit/an/sboa092a/sboa092a.pdf)".
This one helped me a lot for a Devices class which included op-amps. Really good animations, and covers most types (inverter, differentiator...) needed for a starting point.[link text] <http://electronics.wisc-online.com/Search.asp?search=op+amp> [1]
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
Try [Opamps for Everyone](http://focus.ti.com/lit/an/slod006b/slod006b.pdf) (warning -- large pdf, and some TI bias) It has lots to teach, covers beginning to somewhat advanced topics, and it's free.
The "IC Opamp Cookbook" paperback was ~THE~ standard for hobbyist electronics back in the 80s. Still a good reference.
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
Hyperphysics has a pretty good section about opamps: * [Operational Amplifier Concepts](http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampcon.html) * [Op-amp Varieties](http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampvar.html)
There are a couple of very good tutorials at Analog Devices and Texas Instruments. The TI one is called "[Handbook of Operational Amplifiers](http://focus.ti.com/lit/an/sboa092a/sboa092a.pdf)".
592
Can anyone point me to a tutorial for electronic noobs that explains how to use op-amps and what I can do with them, besides amplification?
2009/11/21
[ "https://electronics.stackexchange.com/questions/592", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/123/" ]
I know it's not all online, but [the Art of Electronic by Horowitz and Hill](http://books.google.com/books?id=bkOMDgwFA28C&printsec=frontcover&source=gbs%5Fnavlinks%5Fs#v=onepage&q=&f=false) is fantastic. It's basically the only book you need for the first 2 years of learning electronics (especially if you don't have a...
There are a couple of very good tutorials at Analog Devices and Texas Instruments. The TI one is called "[Handbook of Operational Amplifiers](http://focus.ti.com/lit/an/sboa092a/sboa092a.pdf)".
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
You can use `@Test(expected = ArithmeticException::class)` or even better one of Kotlin's library methods like [`failsWith()`](http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.test/fails-with.html). You can make it even shorter by using reified generics and a helper method like this: ``` inline fun <reified T : Thr...
Firt steps is to add `(expected = YourException::class)` in test annotation ``` @Test(expected = YourException::class) ``` Second step is to add this function ``` private fun throwException(): Boolean = throw YourException() ``` Finally you will have something like this: ``` @Test(expected = ArithmeticException:...
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
[Kotlin has its own test helper package](https://github.com/JetBrains/kotlin/tree/master/libraries/kotlin.test) that can help to do this kind of unittest. Your test can be very expressive by use `assertFailWith`: ``` @Test fun test_arithmethic() { assertFailsWith<ArithmeticException> { omg() } } ```
You can also use generics with kotlin.test package: ``` import kotlin.test.assertFailsWith @Test fun testFunction() { assertFailsWith<MyException> { // The code that will throw MyException } } ```
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
You can use [Kotest](https://github.com/kotest/kotest) for this. In your test, you can wrap arbitrary code with a shouldThrow block: ``` shouldThrow<ArithmeticException> { // code in here that you expect to throw a ArithmeticException } ```
This simple sample worked in the 4.13.2 version of Junit ``` @Test fun testZeroDividing(){ var throwing = ThrowingRunnable { /*call your method here*/ Calculator().divide(1,0) } assertThrows(/*define your exception here*/ IllegalArgumentException::class.java, throwing) } ```
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
The Kotlin translation of the Java example for **JUnit 4.12** is: ``` @Test(expected = ArithmeticException::class) fun omg() { val blackHole = 1 / 0 } ``` However, **JUnit 4.13** [introduced](https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.13.md) two `assertThrows` methods for finer-granular exc...
This simple sample worked in the 4.13.2 version of Junit ``` @Test fun testZeroDividing(){ var throwing = ThrowingRunnable { /*call your method here*/ Calculator().divide(1,0) } assertThrows(/*define your exception here*/ IllegalArgumentException::class.java, throwing) } ```
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
This simple sample worked in the 4.13.2 version of Junit ``` @Test fun testZeroDividing(){ var throwing = ThrowingRunnable { /*call your method here*/ Calculator().divide(1,0) } assertThrows(/*define your exception here*/ IllegalArgumentException::class.java, throwing) } ```
Another version of syntaxis using [kluent](https://github.com/MarkusAmshove/Kluent): ``` @Test fun `should throw ArithmeticException`() { invoking { val backHole = 1 / 0 } `should throw` ArithmeticException::class } ```
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
org.junit.jupiter.api.Assertions.kt ----------------------------------- ``` /** * Example usage: * ```kotlin * val exception = assertThrows<IllegalArgumentException>("Should throw an Exception") { * throw IllegalArgumentException("Talk to a duck") * } * assertEquals("Talk to a duck", exception.message) * ``...
Another version of syntaxis using [kluent](https://github.com/MarkusAmshove/Kluent): ``` @Test fun `should throw ArithmeticException`() { invoking { val backHole = 1 / 0 } `should throw` ArithmeticException::class } ```
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
You can use [Kotest](https://github.com/kotest/kotest) for this. In your test, you can wrap arbitrary code with a shouldThrow block: ``` shouldThrow<ArithmeticException> { // code in here that you expect to throw a ArithmeticException } ```
JUnit5 has [kotlin support](https://junit.org/junit5/docs/current/user-guide/#writing-tests-assertions-kotlin) built in. ``` import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows class MyTests { @Test fun `division by zero -- should throw ArithmeticException`() { assertThrows<Ari...
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
JUnit5 has [kotlin support](https://junit.org/junit5/docs/current/user-guide/#writing-tests-assertions-kotlin) built in. ``` import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows class MyTests { @Test fun `division by zero -- should throw ArithmeticException`() { assertThrows<Ari...
This simple sample worked in the 4.13.2 version of Junit ``` @Test fun testZeroDividing(){ var throwing = ThrowingRunnable { /*call your method here*/ Calculator().divide(1,0) } assertThrows(/*define your exception here*/ IllegalArgumentException::class.java, throwing) } ```
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
org.junit.jupiter.api.Assertions.kt ----------------------------------- ``` /** * Example usage: * ```kotlin * val exception = assertThrows<IllegalArgumentException>("Should throw an Exception") { * throw IllegalArgumentException("Talk to a duck") * } * assertEquals("Talk to a duck", exception.message) * ``...
Firt steps is to add `(expected = YourException::class)` in test annotation ``` @Test(expected = YourException::class) ``` Second step is to add this function ``` private fun throwException(): Boolean = throw YourException() ``` Finally you will have something like this: ``` @Test(expected = ArithmeticException:...
30,331,806
In Java, the programmer can specify expected exceptions for JUnit test cases like this: ``` @Test(expected = ArithmeticException.class) public void omg() { int blackHole = 1 / 0; } ``` How would I do this in Kotlin? I have tried two syntax variations, but none of them worked: ``` import org.junit.Test // ... ...
2015/05/19
[ "https://Stackoverflow.com/questions/30331806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/252000/" ]
You can use [Kotest](https://github.com/kotest/kotest) for this. In your test, you can wrap arbitrary code with a shouldThrow block: ``` shouldThrow<ArithmeticException> { // code in here that you expect to throw a ArithmeticException } ```
org.junit.jupiter.api.Assertions.kt ----------------------------------- ``` /** * Example usage: * ```kotlin * val exception = assertThrows<IllegalArgumentException>("Should throw an Exception") { * throw IllegalArgumentException("Talk to a duck") * } * assertEquals("Talk to a duck", exception.message) * ``...
11,586,791
I have some very simple sub-navigation that I'm trying to build across the top of the content area within my web site, but CSS doesn't seem to have any simple solutions for such a common problem: I want either 3 or 4 equally spaced DIVs across the top of the page. 1) e.g. 3 Variable-Width, Equally-Spaced DIVs ``` [[L...
2012/07/20
[ "https://Stackoverflow.com/questions/11586791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1222530/" ]
You could use percentages, then it just comes down to simple math: ``` [[LEFT=22%]2% margin><2% margin[LEFT CENTER=22%]2% margin><2% margin[RIGHT CENTER=22%]2% margin><2% marginRIGHT=22%]]=100%/??px ``` You could then specify a width for its container and use ``` display:inline; ``` to keep them inline. Note: I...
``` ol { width: 400px; /*width: 800px;*/ display: table; table-layout: fixed; /* the magic dust that ensure equal width */ background: #ccc } ol > li { display: table-cell; border: 1px dashed red; text-align: center } ``` like here: <http://jsfiddle.net/QzYAr/>
11,586,791
I have some very simple sub-navigation that I'm trying to build across the top of the content area within my web site, but CSS doesn't seem to have any simple solutions for such a common problem: I want either 3 or 4 equally spaced DIVs across the top of the page. 1) e.g. 3 Variable-Width, Equally-Spaced DIVs ``` [[L...
2012/07/20
[ "https://Stackoverflow.com/questions/11586791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1222530/" ]
Reference: [**jsFiddle Pure CSS Demo**](http://jsfiddle.net/qx4WG/) The solution was to `float` the individual breadcrumbs while using a simple formula to determine the percentage of breadcrumb `width` based on the number total breadcrumbs.
``` ol { width: 400px; /*width: 800px;*/ display: table; table-layout: fixed; /* the magic dust that ensure equal width */ background: #ccc } ol > li { display: table-cell; border: 1px dashed red; text-align: center } ``` like here: <http://jsfiddle.net/QzYAr/>
11,586,791
I have some very simple sub-navigation that I'm trying to build across the top of the content area within my web site, but CSS doesn't seem to have any simple solutions for such a common problem: I want either 3 or 4 equally spaced DIVs across the top of the page. 1) e.g. 3 Variable-Width, Equally-Spaced DIVs ``` [[L...
2012/07/20
[ "https://Stackoverflow.com/questions/11586791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1222530/" ]
Reference: [**jsFiddle Pure CSS Demo**](http://jsfiddle.net/qx4WG/) The solution was to `float` the individual breadcrumbs while using a simple formula to determine the percentage of breadcrumb `width` based on the number total breadcrumbs.
You could use percentages, then it just comes down to simple math: ``` [[LEFT=22%]2% margin><2% margin[LEFT CENTER=22%]2% margin><2% margin[RIGHT CENTER=22%]2% margin><2% marginRIGHT=22%]]=100%/??px ``` You could then specify a width for its container and use ``` display:inline; ``` to keep them inline. Note: I...
11,586,791
I have some very simple sub-navigation that I'm trying to build across the top of the content area within my web site, but CSS doesn't seem to have any simple solutions for such a common problem: I want either 3 or 4 equally spaced DIVs across the top of the page. 1) e.g. 3 Variable-Width, Equally-Spaced DIVs ``` [[L...
2012/07/20
[ "https://Stackoverflow.com/questions/11586791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1222530/" ]
You could use percentages, then it just comes down to simple math: ``` [[LEFT=22%]2% margin><2% margin[LEFT CENTER=22%]2% margin><2% margin[RIGHT CENTER=22%]2% margin><2% marginRIGHT=22%]]=100%/??px ``` You could then specify a width for its container and use ``` display:inline; ``` to keep them inline. Note: I...
One way I've found to do it is using flex boxes (or inline-flex). [Here](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes) is a great explanation and example of how it can be done. I think in the future, flex boxes will be the superior way of handling this sort of th...
11,586,791
I have some very simple sub-navigation that I'm trying to build across the top of the content area within my web site, but CSS doesn't seem to have any simple solutions for such a common problem: I want either 3 or 4 equally spaced DIVs across the top of the page. 1) e.g. 3 Variable-Width, Equally-Spaced DIVs ``` [[L...
2012/07/20
[ "https://Stackoverflow.com/questions/11586791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1222530/" ]
Reference: [**jsFiddle Pure CSS Demo**](http://jsfiddle.net/qx4WG/) The solution was to `float` the individual breadcrumbs while using a simple formula to determine the percentage of breadcrumb `width` based on the number total breadcrumbs.
One way I've found to do it is using flex boxes (or inline-flex). [Here](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes) is a great explanation and example of how it can be done. I think in the future, flex boxes will be the superior way of handling this sort of th...
18,831,480
I'm developing an app for iOs using flash air, version 3.8, this version allow me to load a externals swf with assets, flash professional cs6 and flash builder 4.7 I have some kind of lobby where the user select a differents games. If I deploy the app just with 1 game (1 swf), I would loaded a game without problem Bu...
2013/09/16
[ "https://Stackoverflow.com/questions/18831480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2171002/" ]
You never initialized `paths`: ``` private ArrayList<String> paths = new ArrayList<String>(); ``` Note that I've also used a type parameter of `String` here, as you should. In general try to stay away from using [raw types](http://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html).
You have incorrect syntax at this line ``` private ArrayList<String> paths; ``` You are not initializing arraylist properly. in order to initialize it properly you would have to do ``` private ArrayList<String> paths = new ArrayList<>(); ``` Note: I did not put `String` inside `<>` as its redundant in java 1.7.
18,831,480
I'm developing an app for iOs using flash air, version 3.8, this version allow me to load a externals swf with assets, flash professional cs6 and flash builder 4.7 I have some kind of lobby where the user select a differents games. If I deploy the app just with 1 game (1 swf), I would loaded a game without problem Bu...
2013/09/16
[ "https://Stackoverflow.com/questions/18831480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2171002/" ]
You never initialized `paths`: ``` private ArrayList<String> paths = new ArrayList<String>(); ``` Note that I've also used a type parameter of `String` here, as you should. In general try to stay away from using [raw types](http://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html).
***Additional remark:*** `File.listFiles()` might return `null` which might be your NullPointerException. So do: ``` public void getPaths(File[] files) { if (files == null) { return; } ``` And Java 7 has a [Files.walkFileTree](http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#walkFil...
18,831,480
I'm developing an app for iOs using flash air, version 3.8, this version allow me to load a externals swf with assets, flash professional cs6 and flash builder 4.7 I have some kind of lobby where the user select a differents games. If I deploy the app just with 1 game (1 swf), I would loaded a game without problem Bu...
2013/09/16
[ "https://Stackoverflow.com/questions/18831480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2171002/" ]
You have incorrect syntax at this line ``` private ArrayList<String> paths; ``` You are not initializing arraylist properly. in order to initialize it properly you would have to do ``` private ArrayList<String> paths = new ArrayList<>(); ``` Note: I did not put `String` inside `<>` as its redundant in java 1.7.
***Additional remark:*** `File.listFiles()` might return `null` which might be your NullPointerException. So do: ``` public void getPaths(File[] files) { if (files == null) { return; } ``` And Java 7 has a [Files.walkFileTree](http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#walkFil...
16,673,241
I have a problem with initial caps(first letter big). ``` .article { text-align:justify; text-wrap: unrestricted; -moz-column-count:3; /* Firefox */ -webkit-column-count:3; /* Safari and Chrome */ column-count:3; } .article:first-letter { font-size:38px; float:left; line-height: 38px;...
2013/05/21
[ "https://Stackoverflow.com/questions/16673241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839439/" ]
You can use sinqle quote instead: ``` document.write('<iframe width="'); ``` or ``` document.write("<iframe width='"); ``` Or escape the double quote: ``` document.write("<iframe width=\""); ```
Use single quotes or escape them. ``` var str = "<iframe src='foo'>"; var str = "<iframe src=\"foo\">"; ```
16,673,241
I have a problem with initial caps(first letter big). ``` .article { text-align:justify; text-wrap: unrestricted; -moz-column-count:3; /* Firefox */ -webkit-column-count:3; /* Safari and Chrome */ column-count:3; } .article:first-letter { font-size:38px; float:left; line-height: 38px;...
2013/05/21
[ "https://Stackoverflow.com/questions/16673241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839439/" ]
Either escape the doublequote: ``` document.write("<iframe width=\""); ``` or use different types of quotes: ``` document.write('<iframe width="'); ``` or: ``` document.write("<iframe width='"); ``` You also forgot the parentheses around the parameter list. For the second problem, the solution is to use an en...
Use single quotes or escape them. ``` var str = "<iframe src='foo'>"; var str = "<iframe src=\"foo\">"; ```
16,673,241
I have a problem with initial caps(first letter big). ``` .article { text-align:justify; text-wrap: unrestricted; -moz-column-count:3; /* Firefox */ -webkit-column-count:3; /* Safari and Chrome */ column-count:3; } .article:first-letter { font-size:38px; float:left; line-height: 38px;...
2013/05/21
[ "https://Stackoverflow.com/questions/16673241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839439/" ]
Either escape the doublequote: ``` document.write("<iframe width=\""); ``` or use different types of quotes: ``` document.write('<iframe width="'); ``` or: ``` document.write("<iframe width='"); ``` You also forgot the parentheses around the parameter list. For the second problem, the solution is to use an en...
You can use sinqle quote instead: ``` document.write('<iframe width="'); ``` or ``` document.write("<iframe width='"); ``` Or escape the double quote: ``` document.write("<iframe width=\""); ```
33,105,581
`std::regex_replace` (Added in C++ 11) replaces all the occurrences. How can I make it replace only the first occurrence?
2015/10/13
[ "https://Stackoverflow.com/questions/33105581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3143558/" ]
If the `flags` parameter to [`std::regex_replace`](http://en.cppreference.com/w/cpp/regex/regex_replace) contains `std::regex_constants::format_first_only`, only the first match is replaced. ``` std::regex_replace("12 34", std::regex(R"(\d+)"), "num", std::rege...
I found the solution myself. Posting for others if they face the same issue. Add: `std::tr1::regex_constants::format_first_only` to replace only the first occurrence as the fourth argument to `regex_replace`
91,004
Seed phrases seem to be pretty secure, approximately as strong as bitcoin private key according to this site <https://en.bitcoin.it/wiki/Seed_phrase>. But who store the private key adresses of these seed phrases, I suppose it is the wallet software provider, so each one of these provider have to save this data somewhe...
2019/10/14
[ "https://bitcoin.stackexchange.com/questions/91004", "https://bitcoin.stackexchange.com", "https://bitcoin.stackexchange.com/users/95422/" ]
The private keys are not *stored*, they are *deterministically generated* from the seed data. The seed encodes up to 256 bits of random entropy in a human readable form with a checksum attached to it. These details are outlined in BIP39 This entropy is then passed through the PBKDF2 hash function in order to produce ...
> > who store the private key adresses of these seed phrases, > > > The private-keys are generated from the seed-phrase by a mathematical function. There is no need to store a list of seed-phrases and corresponding private-keys. > > I suppose it is the wallet software provider > > > No, you should be the on...
26,587,450
I'm working on getting the number of days between two dates using Java. When I give the application date as 27 it shows 0, and when I give as 26 it even shows 0. Is there anything wrong in my code? Any ideas would be greatly appreciated. Here is my code ``` public static void main (String[] args) throws java.lang....
2014/10/27
[ "https://Stackoverflow.com/questions/26587450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4120679/" ]
You can try in this way. Use [TimeUnit.MILLISECONDS.toDays()](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html#toDays%28long%29) ``` long duration = appDate.getTime() - currentDate.getTime(); long diffInSeconds = TimeUnit.MILLISECONDS.toSeconds(duration); long diffInMinutes = TimeUnit.MILL...
If it's less than a day of difference, the result of the division operation will be zero, because that's how integer (and long integer) division works. You can try to divide by a `double` value: ``` double diffDays = diff / (24 * 60 * 60 * 1000.0); ```
26,587,450
I'm working on getting the number of days between two dates using Java. When I give the application date as 27 it shows 0, and when I give as 26 it even shows 0. Is there anything wrong in my code? Any ideas would be greatly appreciated. Here is my code ``` public static void main (String[] args) throws java.lang....
2014/10/27
[ "https://Stackoverflow.com/questions/26587450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4120679/" ]
You need to decide on the business rules. If there is less than a day difference, for example 23 hours, do you want to count that as 0 or round up to 1? You `strAppDate` is `"2014-10-28 15:11:30.0"`, and depnding on your timezone, `currentDate` is the 27th, so the difference between `appDate.getTime()` and `currentDat...
If it's less than a day of difference, the result of the division operation will be zero, because that's how integer (and long integer) division works. You can try to divide by a `double` value: ``` double diffDays = diff / (24 * 60 * 60 * 1000.0); ```
656,083
I am display the 256 colors for tput by colouring tho background colour using the following bash function. ``` tput-bgcolours () { for color in {0..255}; do bg=$(tput setab $color) echo -n $bg" " done echo $(tput sgr0) } ``` How can I pass a range of values to the function rather that ...
2021/06/28
[ "https://unix.stackexchange.com/questions/656083", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/451524/" ]
The first step is to disable the default conda prompt modifier by running `conda config --set changeps1 false` as they already mentioned. Next, add the following to your `.zshrc`: ``` # Determines prompt modifier if and when a conda environment is active precmd_conda_info() { if [[ -n $CONDA_PREFIX ]]; then i...
Run: ``` conda config --set changeps1 False ``` or add `changeps1: False` to your `.condarc`.
31,234,843
JSON: ``` { "Item 1":[ { "Item 1.1":2, "Item 1.2":3 } ], "Item 2":[ { "Item 2.1":2, "Item 2.2":23 } ] } ``` JS: ``` $.getJSON(jsonPath, function(data, status) { var tocHTML = []; function eachObj(obj, i) { ...
2015/07/05
[ "https://Stackoverflow.com/questions/31234843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172637/" ]
Your code does this when it sees that the value of an entry in the outer iteration is an array: ``` tocHTML.push('<a data-page="' + value[0] + '">' + key + '</a>'); tocHTML.push('<ul>'); eachObj(value[1]); tocHTML.push('</ul>'); ``` That code intends to iterate over `v...
Try utilizing `$.map()` ```js var data = { "Item 1": [{ "Item 1.1": 2, "Item 1.2": 3 }], "Item 2": [{ "Item 2.1": 2, "Item 2.2": 23 }] }; var ul = $("<ul class=list />"); ul.appendTo("body"); $.each(data, function(key, value) { var html = "<li class=item>" + "<...
3,219
I have friends that are very picky when it comes to MP3 bitrate, and will always look for the 320 kbps version of a file. However, I have never noticed any differences, they sound the same to me. I remember reading somewhere, can't remember where, that the human ear is simply incapable of sensing the difference, even i...
2011/05/15
[ "https://skeptics.stackexchange.com/questions/3219", "https://skeptics.stackexchange.com", "https://skeptics.stackexchange.com/users/1781/" ]
Here is one surprising result, from an experiment described in Maximum PC's article "[Do Higher MP3 Bit Rates Really Pay Off?](http://www.maximumpc.com/article/do_higher_mp3_bit_rates_pay_off?page=0,0)": Its conclusion: > > [No other] Maximum PC Challenge has ever surprised us as much as this one. It’s downright hum...
**There is a distinct difference, however whether it's perceivable, and how much, depends on many factors.** Unfortunately I can't access the full articles, however here's the abstract of a [very relevant article](http://www.aes.org/e-lib/browse.cfm?elib=15074), emphasis mine. > > Mp3 compression is commonly used to...
3,219
I have friends that are very picky when it comes to MP3 bitrate, and will always look for the 320 kbps version of a file. However, I have never noticed any differences, they sound the same to me. I remember reading somewhere, can't remember where, that the human ear is simply incapable of sensing the difference, even i...
2011/05/15
[ "https://skeptics.stackexchange.com/questions/3219", "https://skeptics.stackexchange.com", "https://skeptics.stackexchange.com/users/1781/" ]
Here is one surprising result, from an experiment described in Maximum PC's article "[Do Higher MP3 Bit Rates Really Pay Off?](http://www.maximumpc.com/article/do_higher_mp3_bit_rates_pay_off?page=0,0)": Its conclusion: > > [No other] Maximum PC Challenge has ever surprised us as much as this one. It’s downright hum...
It really depends on a number of factors. Some of them are: * The age of the listener, the older you get, the less high frequency sounds you can [hear](http://www.roger-russell.com/hearing/hearing.htm). Besides age, there are [more individual factors](http://www.ncbi.nlm.nih.gov/pubmed/3558959). * The quality of the m...
3,219
I have friends that are very picky when it comes to MP3 bitrate, and will always look for the 320 kbps version of a file. However, I have never noticed any differences, they sound the same to me. I remember reading somewhere, can't remember where, that the human ear is simply incapable of sensing the difference, even i...
2011/05/15
[ "https://skeptics.stackexchange.com/questions/3219", "https://skeptics.stackexchange.com", "https://skeptics.stackexchange.com/users/1781/" ]
**There is a distinct difference, however whether it's perceivable, and how much, depends on many factors.** Unfortunately I can't access the full articles, however here's the abstract of a [very relevant article](http://www.aes.org/e-lib/browse.cfm?elib=15074), emphasis mine. > > Mp3 compression is commonly used to...
It really depends on a number of factors. Some of them are: * The age of the listener, the older you get, the less high frequency sounds you can [hear](http://www.roger-russell.com/hearing/hearing.htm). Besides age, there are [more individual factors](http://www.ncbi.nlm.nih.gov/pubmed/3558959). * The quality of the m...
9,691,521
I want to ask a thing about digital signing I am not very sure. Instead of creating a self signed certificate to use to sign some (PDF) files, I wanted to take my SSL cert which have my data already verified. But the question is: Can a SSL cert be used to digital sign files or is it incompatible in some manner? EDIT:...
2012/03/13
[ "https://Stackoverflow.com/questions/9691521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/739009/" ]
To support digital signing certificate must have `digitalSignature` option in it's `keyUsage` field (and `codeSigning` option in it's `extendedKeyUsage` field if your want to sign programs with it). Signing may be done with existing tools or manually (java example, you are not asking for it, but this code snippet migh...
At the core, the certificate is just a normal RSA public key that's been signed by several authorities. So yes, definitely possible. Though I don't know of any easy-to-use widespread tools for the end-user for this.
9,691,521
I want to ask a thing about digital signing I am not very sure. Instead of creating a self signed certificate to use to sign some (PDF) files, I wanted to take my SSL cert which have my data already verified. But the question is: Can a SSL cert be used to digital sign files or is it incompatible in some manner? EDIT:...
2012/03/13
[ "https://Stackoverflow.com/questions/9691521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/739009/" ]
To support digital signing certificate must have `digitalSignature` option in it's `keyUsage` field (and `codeSigning` option in it's `extendedKeyUsage` field if your want to sign programs with it). Signing may be done with existing tools or manually (java example, you are not asking for it, but this code snippet migh...
Yes, you can sign and verify the signature of files using SSL certificates Here is an example: ```bash SSLCERT='/XXXX/ssl/certs/fqdn.pem' SSLKEY='/XXXX/ssl/private_keys/fqdn.pem' # You might not need to specify a CA CACERTFILE='/XXXX/ssl/certs/ca.pem' # File to sign FILE='YYYYYYY' # Signs, needs ${SSLKEY} and ${FILE...
22,856,931
I am trying to insert `java.util.Date` after converting it to java.sql.Timestamp and I am using the following snippet: ``` java.util.Date utilDate = new java.util.Date(); java.sql.Timestamp sq = new java.sql.Timestamp(utilDate.getTime()); ``` But this is giving me `sq` as `2014-04-04 13:30:17.533` Is there any way ...
2014/04/04
[ "https://Stackoverflow.com/questions/22856931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1518078/" ]
Take a look at `SimpleDateFormat`: ``` java.util.Date utilDate = new java.util.Date(); java.sql.Timestamp sq = new java.sql.Timestamp(utilDate.getTime()); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); System.out.println(sdf.format(sq)); ```
The problem is with the way you are printing the Time data ``` java.util.Date utilDate = new java.util.Date(); java.sql.Timestamp sq = new java.sql.Timestamp(utilDate.getTime()); System.out.println(sa); //this will print the milliseconds as the toString() has been written in that format SimpleDateFormat sdf = new Sim...