Constantly check for a change in the date

Question: I was wondering if I could continually check for when today's is matched up with a date in the future. For instance if the date set in the future was 1/8/2015 and the date today was 1/7/2015. Is there a way to automatically keep checking when today's date becomes 1/8/2015 (matching with the date set in the future).
I was thinking about using a while(true) loop but it didn't feel right because the loop would never end. How else would I do this?
EDIT : So based off some online research and answer here I did this.
Calendar cal2 = Calendar.getInstance();
    cal2.add(Calendar.DAY_OF_MONTH, 1);
    Date date = cal2.getTime();
    System.out.print(cal2.getTime().toString());
    Timer t = new Timer();
    t.schedule(new TimerTask() {
        public void run() {
            for (int i = 1; i < 1000; i++) {
                if (shelf.book[i] != null && shelf.book[i].overdue == true) {

                }
            }

        }
    }, date);

Note: I haven't tested it yet. (Also the run() method isn't done yet)
Comment: How about using a cron job ?
Comment: Busy waiting for an event is a bad thing. Instead, sleep or do something else until the time change happens.
Comment: The simplest answer is a permutation on your `while(true)` idea (add a Thread.sleep to break the CPU drain).  There's nothing innately wrong with a loop that never ends, if you're dealing with server scenarios.  The problem is this: how can ensure that your process stays alive long enough to fire?  There's any number of environmental issues that start popping up once you're dealing with "days/weeks/months" time scales.  What's your expected environment going to be like?
Comment: depending on the context you are running your Java App. You should look at Threading. http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html
Answer: For one time scheduling, an easy solution would be to use a Timer.
import java.util.*;
import java.text.*;

public class ScheduleTask {

   private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

   private static Timer timer = new Timer();

   private static class MyTimeTask extends TimerTask {
      public void run() {
         System.out.println("HOHO date just changed");
      }
   }

   public static void main(String[] args) throws ParseException {

      System.out.println("Current Time: " + df.format( new Date()));

      //Date and time at which you want to execute
      Date date = df.parse("2015-01-08 00:00:00");

      timer.schedule(new MyTimeTask(), date);
   }
}

Answer: Instead of actively checking, use a ScheduledExecutorService that executes a Runnable in the future:
ScheduledExecutorService ses = Executors.newSingleThreadScheduledExecutor();
long delay = dateInFuture.getTime() - new Date().getTime();
ses.schedule(new Runnable(){
    @Override
    public void run() {
        // do some work
    }
}, delay, TimeUnit.MILLISECONDS);

Answer: Busy waiting (aka polling) is generally a bad idea because it wastes resources.  In this specific case there's no need to poll because you know the current datetime as well as the future datetime that you want to trigger on.  Calculate the difference in time and use a timer to run your code at the necessary time.
Java timer class
For example, let's say the current time is Jan 7 @4pm.  You want to trigger on Jan 8 @12am.  The time difference is 8 hours (28800 seconds or whatever unit of time you need to pass to the timer).  Set a schedule for that duration and provide a callback function.


How to solve transcendental equations with MATLAB?

Question: Here's the equation:
$$ - \frac{MN}{\sqrt{2\pi \left( \sigma_1^2 + \sigma_2^2 \right)}} \frac d {dy} \exp \left( -\frac {y^2} {\left( \sigma_1^2 + \sigma_2^2 \right)} \right) = k \left( x-y \right) $$
About the equation(s):
The equation on the left side models an attraction force, the one on the right hand side a spring force. The parameters $ M, N, \sigma_1, \sigma_2 $ and $ k $ do not change. $ x $ is the distance to the initial position (fixed value, doesn't change) and $ y $ is the distance to the position (I'm looking for) where both forces are balanced.
I already tried solve, but that didn't really help me. I also read, that it should be solved numerically, but I don't really know how to do this in Matlab.
Thank you in advance
Comment: Do you want to find $y=f(x)$?
Comment: No I don't, $ x $ is just the starting value and does not change (sorry, I forgot to highlight this in my description), I want to find the solution of $ f \left( y \right) = f \left( y \right) $. I need to find the point $ y $ (or distance) where both forces are the same.
Answer: For ease of notation let
$$a = -\frac{MN}{k\sqrt{2\pi(\sigma_{1}^{2} + \sigma_{2}^{2})}}$$
and
$$b = (\sigma_{1}^{2}+\sigma_{2}^{2}).$$
Then we would like to find $y$ such that
$$- 2 y \frac{a}{b} \exp[-y^{2}/b] = x - y.$$
Equivalently, we would like to find the root of $f(y)$, where
$$f(y) = y - 2y\frac{a}{b}\exp[-y^{2}/b] - x.$$
There are a number of ways to find roots numerically e.g. the bisection method, secant method or Newton's method.
I suggest you don't implement any of these yourself: rather just use MATLAB's fzero command - read its documentation here.


Is there a repository of up to date .browser files for ASP.NET?

Question: Is there a repository of up to date .browser files for ASP.NET anywhere on the internet that would help with detecting modern mobile and tablet devices?
Answer: I believe that WURFL is a popular choice for getting the latest and greatest browser caps.
http://wurfl.sourceforge.net/dotnet_index.php


Google ComboChart not showing all data rows

Question: Google ComboChart is not showing all data rows when dealing with larger set of data and when using series type 'bars' and 'lines.'
I'm setting series 2 as type 'bars', but not all data is shown.
If I change series 2 as type 'lines', all data is shown.
Same applies when using simple ColumnChart - if date range is long (~3 years), not all data is shown.
Is there some option that is limiting date range of data?

<code>      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawVisualization);

      function drawVisualization() {
        // Some raw data (not necessarily accurate)
        var data = google.visualization.arrayToDataTable([[{label: 'date', type: 'string'}, {label: 'data1', type: 'number'}, {label: 'data2', type: 'number'}, {label: 'data3', type: 'number'}],['12.09.2011',8901.00,2967.00, null],['13.09.2011',17693.36,2948.89, null],['20.09.2011',28900.00,2890.00, null],['22.09.2011',2850.00,2850.00, null],['26.09.2011',2798.65,2798.65, null],['27.09.2011',5789.00,2894.50, null],['28.09.2011',5600.00,2800.00, null],['03.10.2011',7845.01,2615.00, null],['04.10.2011',5222.00,2611.00, null],['12.10.2011',5230.11,2615.06, null],['13.10.2011',2799.00,2799.00, null],['17.10.2011',2870.00,2870.00, null],['21.10.2011',51840.00,2880.00, null],['24.10.2011',39418.00,2815.57, null],['26.10.2011',16812.06,2802.01, null],['27.10.2011',44100.00,2940.00, null],['28.10.2011',20073.14,2867.59, null],['02.11.2011',2815.02,2815.02, null],['08.11.2011',31421.01,2856.46, null],['10.11.2011',2850.00,2850.00, null],['11.11.2011',20509.00,2929.86, null],['16.11.2011',11689.02,2922.26, null],['23.11.2011',5430.01,2715.01, null],['25.11.2011',14700.02,2450.00, null],['30.11.2011',50399.91,2800.00, null],['01.12.2011',14289.98,2858.00, null],['02.12.2011',2900.00,2900.00, null],['05.12.2011',8290.00,2763.33, null],['19.12.2011',2700.00,2700.00, null],['27.12.2011',132600.00,2600.00, null],['30.12.2011',5450.00,2725.00, null],['04.01.2012',23451.00,2605.67, null],['05.01.2012',69216.00,2563.56, null],['11.01.2012',25840.02,2584.00, null],['13.01.2012',20580.00,2572.50, null],['17.01.2012',12999.97,2599.99, null],['23.01.2012',14825.15,2470.86, null],['27.01.2012',7206.00,2402.00, null],['30.01.2012',5000.00,2500.00, null],['31.01.2012',38997.00,2599.80, null],['06.02.2012',31880.00,2656.67, null],['07.02.2012',26843.00,2684.30, null],['09.02.2012',49530.00,2751.67, null],['15.02.2012',70874.00,2834.96, null],['16.02.2012',35756.00,2979.67, null],['20.02.2012',50484.00,2969.65, null],['21.02.2012',5720.01,2860.01, null],['22.02.2012',161239.76,3042.26, null],['23.02.2012',21063.00,3009.00, null],['24.02.2012',22003.84,3143.41, null],['27.02.2012',15778.72,3155.74, null],['29.02.2012',3195.02,3195.02, null],['01.03.2012',63943.57,3197.18, null],['02.03.2012',6300.00,3150.00, null],['05.03.2012',22019.05,3145.58, null],['06.03.2012',9324.00,3108.00, null],['07.03.2012',30841.04,3084.10, null],['12.03.2012',34095.02,3099.55, null],['13.03.2012',12754.98,3188.75, null],['14.03.2012',180724.39,3409.89, null],['15.03.2012',10495.00,3498.33, null],['16.03.2012',19801.00,3300.17, null],['19.03.2012',34633.00,3463.30, null],['20.03.2012',21380.64,3563.44, null],['21.03.2012',44253.10,3404.08, null],['22.03.2012',47515.13,3393.94, null],['26.03.2012',40574.05,3121.08, null],['28.03.2012',6650.00,3325.00, null],['29.03.2012',6354.08,3177.04, null],['02.04.2012',80078.00,3203.12, null],['04.04.2012',3177.00,3177.00, null],['05.04.2012',27029.34,3378.67, null],['06.04.2012',38417.02,3201.42, null],['10.04.2012',31839.99,3184.00, null],['17.04.2012',48711.00,3247.40, null],['23.04.2012',31545.01,3154.50, null],['24.04.2012',9434.10,3144.70, null],['27.04.2012',6487.96,3243.98, null],['02.05.2012',15977.60,3195.52, null],['03.05.2012',12720.26,3180.07, null],['04.05.2012',9300.02,3100.01, null],['07.05.2012',12350.01,3087.50, null],['09.05.2012',3100.00,3100.00, null],['10.05.2012',6260.01,3130.01, null],['15.05.2012',18155.01,3025.84, null],['16.05.2012',6100.00,3050.00, null],['17.05.2012',71447.09,2976.96, null],['18.05.2012',9268.00,3089.33, null],['23.05.2012',17796.03,2966.01, null],['24.05.2012',20349.15,2907.02, null],['28.05.2012',2911.01,2911.01, null],['29.05.2012',26196.06,2910.67, null],['30.05.2012',25290.09,2810.01, null],['04.06.2012',8100.00,2700.00, null],['12.06.2012',2900.00,2900.00, null],['15.06.2012',10884.09,2721.02, null],['28.06.2012',5464.00,2732.00, null],['03.07.2012',13855.00,2771.00, null],['04.07.2012',56000.00,2800.00, null],['05.07.2012',95127.92,2882.66, null],['06.07.2012',29516.40,2951.64, null],['10.07.2012',33587.00,3053.36, null],['11.07.2012',90906.04,3134.69, null],['12.07.2012',9250.00,3083.33, null],['13.07.2012',31683.36,3168.34, null],['17.07.2012',2971.00,2971.00, null],['18.07.2012',29528.90,3280.99, null],['19.07.2012',12800.00,3200.00, null],['23.07.2012',91070.00,3252.50, null],['24.07.2012',9417.03,3139.01, null],['25.07.2012',25760.00,3220.00, null],['26.07.2012',49776.00,3111.00, null],['27.07.2012',13040.00,3260.00, null],['07.08.2012',138298.00,3292.81, null],['09.08.2012',44871.00,3451.62, null],['13.08.2012',158843.40,3694.03, null],['17.08.2012',3989.00,3989.00, null],['20.08.2012',95843.86,3993.49, null],['21.08.2012',153428.78,3934.07, null],['22.08.2012',3999.99,3999.99, null],['23.08.2012',3730.00,3730.00, null],['24.08.2012',40452.28,3677.48, null],['28.08.2012',248299.60,3598.54, null],['29.08.2012',34690.00,3469.00, null],['30.08.2012',10200.00,3400.00, null],['31.08.2012',35000.00,3500.00, null],['03.09.2012',27200.00,3400.00, null],['04.09.2012',6700.00,3350.00, null],['05.09.2012',3350.00,3350.00, null],['06.09.2012',9750.03,3250.01, null],['10.09.2012',23060.01,3294.29, null],['11.09.2012',40686.99,3390.58, null],['12.09.2012',21149.98,3525.00, null],['13.09.2012',32834.98,3648.33, null],['14.09.2012',21503.00,3583.83, null],['18.09.2012',26765.00,3345.63, null],['20.09.2012',53578.19,3348.64, null],['21.09.2012',19878.00,3313.00, null],['28.09.2012',3400.00,3400.00, null],['02.10.2012',76956.98,3498.04, null],['03.10.2012',112000.00,3500.00, null],['05.10.2012',107512.86,3468.16, null],['09.10.2012',7200.00,3600.00, null],['10.10.2012',3677.98,3677.98, null],['12.10.2012',6900.00,3450.00, null],['15.10.2012',6900.00,3450.00, null],['17.10.2012',3448.00,3448.00, null],['18.10.2012',34426.03,3442.60, null],['19.10.2012',3440.01,3440.01, null],['22.10.2012',31400.00,3488.89, null],['24.10.2012',14000.00,3500.00, null],['26.10.2012',10500.00,3500.00, null],['31.10.2012',154911.37,3442.47, null],['05.11.2012',906760.90,3584.04, null],['06.11.2012',7100.00,3550.00, null],['08.11.2012',3560.00,3560.00, null],['09.11.2012',3550.00,3550.00, null],['15.11.2012',3405.00,3405.00, null],['19.11.2012',7000.00,3500.00, null],['22.11.2012',31500.00,3500.00, null],['27.11.2012',28000.10,3500.01, null],['06.12.2012',3434.00,3434.00, null],['11.12.2012',20400.00,3400.00, null],['13.12.2012',10350.00,3450.00, null],['17.12.2012',44625.89,3432.76, null],['18.12.2012',3595.00,3595.00, null],['20.12.2012',89996.00,3749.83, null],['24.12.2012',11106.00,3702.00, null],['27.12.2012',40916.00,3409.67, null],['28.12.2012',51070.30,3404.69, null],['31.12.2012',7345.00,3672.50, null],['03.01.2013',10501.00,3500.33, null],['04.01.2013',84373.40,3515.56, null],['07.01.2013',47438.00,3649.08, null],['08.01.2013',11200.00,3733.33, null],['09.01.2013',30019.00,3752.38, null],['10.01.2013',297316.96,3861.26, null],['11.01.2013',120499.00,3887.06, null],['14.01.2013',52054.06,3718.15, null],['15.01.2013',56911.00,3794.07, null],['16.01.2013',38020.00,3802.00, null],['18.01.2013',4.00,3800.00, null],['21.01.2013',65926.98,3878.06, null],['22.01.2013',42602.00,3872.91, null],['23.01.2013',162577.50,4064.44, null],['24.01.2013',50545.00,4212.08, null],['25.01.2013',25160.00,4193.33, null],['29.01.2013',4160.00,4160.00, null],['30.01.2013',4000.00,4000.00, null],['01.02.2013',26410.00,3772.86, null],['04.02.2013',69103.13,3839.06, null],['05.02.2013',7800.00,3900.00, null],['06.02.2013',214800.00,3977.78, null],['07.02.2013',82827.47,3944.17, null],['08.02.2013',48499.95,4041.66, null],['11.02.2013',92148.92,4188.59, null],['12.02.2013',77960.09,4103.16, null],['14.02.2013',48780.98,4065.08, null],['19.02.2013',28000.00,4000.00, null],['22.02.2013',28050.01,4007.14, null],['25.02.2013',71345.47,4196.79, null],['26.02.2013',8300.00,4150.00, null],['28.02.2013',8102.10,4051.05, null],['05.03.2013',33150.00,4143.75, null],['06.03.2013',234162.79,4257.51, null],['07.03.2013',30983.00,4426.14, null],['13.03.2013',26100.01,4350.00, null],['14.03.2013',108446.01,4337.84, null],['15.03.2013',64800.00,4320.00, null],['18.03.2013',12960.00,4320.00, null],['19.03.2013',51621.00,4301.75, null],['21.03.2013',12862.00,4287.33, null],['22.03.2013',4300.00,4300.00, null],['29.03.2013',51521.00,4293.42, null],['02.04.2013',43000.00,4300.00, null],['03.04.2013',12621.02,4207.01, null],['04.04.2013',4300.00,4300.00, null],['08.04.2013',25210.04,4201.67, null],['09.04.2013',56052.18,4003.73, null],['10.04.2013',8600.00,4300.00, null],['12.04.2013',8110.02,4055.01, null],['15.04.2013',8100.03,4050.02, null],['19.04.2013',85413.69,4270.68, null],['23.04.2013',16640.04,4160.01, null],['29.04.2013',69424.00,4083.76, null],['02.05.2013',175913.06,3909.18, null],['03.05.2013',19037.06,3807.41, null],['07.05.2013',50250.88,3865.45, null],['09.05.2013',3840.00,3840.00, null],['10.05.2013',36000.00,4000.00, null],['13.05.2013',28000.00,4000.00, null],['14.05.2013',36000.00,4000.00, null],['15.05.2013',4000.00,4000.00, null],['16.05.2013',4020.00,4020.00, null],['17.05.2013',40170.01,4017.00, null],['21.05.2013',8000.00,4000.00, null],['22.05.2013',28000.00,4000.00, null],['03.06.2013',18780.10,3756.02, null],['07.06.2013',48851.01,3757.77, null],['11.06.2013',18540.13,3708.03, null],['12.06.2013',11100.00,3700.00, null],['13.06.2013',14400.10,3600.03, null],['14.06.2013',47200.00,3933.33, null],['17.06.2013',24293.91,4048.99, null],['19.06.2013',19800.00,3960.00, null],['20.06.2013',7600.00,3800.00, null],['21.06.2013',22778.00,3796.33, null],['26.06.2013',83600.00,3800.00, null],['27.06.2013',18572.00,3714.40, null],['01.07.2013',38000.00,3800.00, null],['08.07.2013',7400.00,3700.00, null],['09.07.2013',80476.30,3658.01, null],['10.07.2013',14400.42,3600.11, null],['11.07.2013',14798.00,3699.50, null],['12.07.2013',32073.29,3563.70, null],['16.07.2013',3540.00,3540.00, null],['17.07.2013',3611.02,3611.02, null],['22.07.2013',3553924.46,3600.73, null],['26.07.2013',36000.08,3600.01, null],['29.07.2013',51434.10,3598.14, null],['30.07.2013',14779.14,3597.05, null],['31.07.2013',390648.30,3551.35, null],['01.08.2013',3580000.00,3580.00, null],['07.08.2013',31784.05,3531.56, null],['08.08.2013',7200.00,3600.00, null],['13.08.2013',44623.97,3718.66, null],['16.08.2013',3700.00,3700.00, null],['20.08.2013',7280.00,3640.00, null],['22.08.2013',41622.00,3783.82, null],['23.08.2013',86721.00,3770.48, null],['26.08.2013',22430.01,3738.34, null],['28.08.2013',3750.00,3750.00, null],['04.09.2013',19597.31,3919.46, null],['05.09.2013',19150.00,3830.00, null],['06.09.2013',198452.00,3744.38, null],['09.09.2013',3800.00,3800.00, null],['10.09.2013',11697.00,3899.00, null],['11.09.2013',11697.00,3899.00, null],['12.09.2013',11550.00,3850.00, null],['13.09.2013',19649.00,3929.80, null],['16.09.2013',7850.00,3925.00, null],['17.09.2013',250170.00,3848.77, null],['18.09.2013',19479.97,3895.99, null],['19.09.2013',70200.00,3900.00, null],['20.09.2013',19495.97,3899.19, null],['23.09.2013',11738.00,3912.67, null],['24.09.2013',15696.00,3924.00, null],['25.09.2013',157235.00,3835.00, null],['26.09.2013',11401.00,3800.33, null],['27.09.2013',7600.00,3800.00, null],['30.09.2013',7799.88,3899.94, null],['01.10.2013',93620.20,3744.81, null],['02.10.2013',11669.94,3889.98, null],['03.10.2013',7779.96,3889.98, null],['04.10.2013',7500.00,3750.00, null],['07.10.2013',60527.01,3782.94, null],['09.10.2013',3755.00,3755.00, null],['10.10.2013',7700.00,3850.00, null],['11.10.2013',7760.00,3880.00, null],['14.10.2013',11569.98,3856.66, null],['15.10.2013',7759.98,3879.99, null],['16.10.2013',11639.93,3879.98, null],['17.10.2013',38799.85,3879.99, null],['18.10.2013',39317.96,3931.80, null],['21.10.2013',3968.60,3968.60, null],['22.10.2013',7937.10,3968.55, null],['23.10.2013',11925.58,3975.19, null],['24.10.2013',30171.43,3771.43, null],['25.10.2013',15600.00,3900.00, null],['28.10.2013',7940.00,3970.00, null],['29.10.2013',41374.50,3761.32, null],['30.10.2013',10750.00,3583.33, null],['31.10.2013',11195.00,3731.67, null],['04.11.2013',7539.99,3770.00, null],['05.11.2013',3774.00,3774.00, null],['06.11.2013',14603.01,3650.75, null],['07.11.2013',7499.00,3749.50, null],['08.11.2013',3769.99,3769.99, null],['11.11.2013',83914.09,3648.44, null],['12.11.2013',7499.00,3749.50, null],['13.11.2013',21712.02,3618.67, null],['14.11.2013',173380.35,3538.37, null],['15.11.2013',3608.01,3608.01, null],['18.11.2013',21360.00,3560.00, null],['19.11.2013',21000.06,3500.01, null],['20.11.2013',7336.02,3668.01, null],['21.11.2013',3668.01,3668.01, null],['22.11.2013',3686.00,3686.00, null],['25.11.2013',7374.99,3687.50, null],['26.11.2013',7377.98,3688.99, null],['27.11.2013',569800.00,3700.00, null],['28.11.2013',3700.00,3700.00, null],['29.11.2013',7399.98,3699.99, null],['02.12.2013',3699.99,3699.99, null],['03.12.2013',21738.06,3623.01, null],['04.12.2013',3600.00,3600.00, null],['05.12.2013',67496.34,3552.44, null],['06.12.2013',150756.01,3505.95, null],['09.12.2013',13975.00,3493.75, null],['11.12.2013',86653.70,3466.15, null],['12.12.2013',24180.10,3454.30, null],['16.12.2013',7000.00,3500.00, null],['17.12.2013',38500.00,3500.00, null],['18.12.2013',10766.68,3588.89, null],['19.12.2013',3588.80,3588.80, null],['20.12.2013',20945.01,3490.84, null],['23.12.2013',199809.51,3632.90, null],['27.12.2013',36589.04,3658.90, null],['30.12.2013',276531.42,3736.91, null],['31.12.2013',74816.54,3740.83, null],['02.01.2014',7599.98,3799.99, null],['03.01.2014',11273.18,3757.73, null],['07.01.2014',59199.97,3700.00, null],['08.01.2014',635615.72,3591.05, null],['09.01.2014',367406.55,3602.03, null],['10.01.2014',183574.01,3599.49, null],['13.01.2014',28409.03,3551.13, null],['14.01.2014',25010.80,3572.97, null],['15.01.2014',24777.98,3539.71, null],['16.01.2014',145499.41,3548.77, null],['17.01.2014',63248.64,3513.81, null],['20.01.2014',24524.24,3503.46, null],['21.01.2014',67478.99,3551.53, null],['22.01.2014',81572.19,3546.62, null],['23.01.2014',13965.00,3491.25, null],['24.01.2014',56729.01,3545.56, null],['28.01.2014',120344.00,3646.79, null],['29.01.2014',72365.00,3618.25, null],['30.01.2014',113490.05,3546.56, null],['31.01.2014',7195.98,3597.99, null],['03.02.2014',151627.06,3526.21, null],['04.02.2014',77612.08,3527.82, null],['05.02.2014',10740.00,3580.00, null],['06.02.2014',125314.49,3580.41, null],['07.02.2014',7216.00,3608.00, null],['10.02.2014',46310.00,3562.31, null],['11.02.2014',24842.02,3548.86, null],['13.02.2014',103820.00,3580.00, null],['14.02.2014',91770.06,3529.62, null],['17.02.2014',7139.66,3569.83, null],['18.02.2014',10555.03,3518.34, null],['19.02.2014',7099.46,3549.73, null],['20.02.2014',42578.00,3548.17, null],['21.02.2014',7100.00,3550.00, null],['24.02.2014',132156.09,3477.79, null],['25.02.2014',24366.24,3480.89, null],['26.02.2014',739002.95,3405.54, null],['27.02.2014',44459.99,3420.00, null],['28.02.2014',10259.98,3419.99, null],['03.03.2014',59907.02,3328.17, null],['04.03.2014',60088.99,3338.28, null],['05.03.2014',85538.20,3289.93, null],['06.03.2014',89702.32,3203.65, null],['07.03.2014',3328.88,3328.88, null],['10.03.2014',25875.59,3234.45, null],['12.03.2014',35042.30,3185.66, null],['14.03.2014',133441.13,3254.66, null],['17.03.2014',57834.33,3213.02, null],['18.03.2014',16160.10,3232.02, null],['19.03.2014',6580.00,3290.00, null],['21.03.2014',35719.00,3247.18, null],['24.03.2014',83470.00,3210.38, null],['25.03.2014',142265.00,3308.49, null],['26.03.2014',62943.20,3312.80, null],['27.03.2014',16935.66,3387.13, null],['01.04.2014',128422.90,3379.55, null],['03.04.2014',64402.00,3389.58, null],['04.04.2014',30501.00,3389.00, null],['07.04.2014',52819.08,3301.19, null],['09.04.2014',3300.00,3300.00, null],['15.04.2014',80173.13,3206.93, null],['16.04.2014',28502.00,3166.89, null],['18.04.2014',13000.00,3250.00, null],['28.04.2014',25206.15,3150.77, null],['29.04.2014',6387.93,3193.97, null],['30.04.2014',89489.43,3085.84, null],['02.05.2014',36059.00,3004.92, null],['05.05.2014',136634.21,2907.11, null],['08.05.2014',11453.05,2863.26, null],['09.05.2014',5865.99,2933.00, null],['12.05.2014',29144.52,2914.45, null],['13.05.2014',26940.99,2993.44, null],['14.05.2014',11728.12,2932.03, null],['15.05.2014',49405.76,2906.22, null],['16.05.2014',32056.05,2914.19, null],['21.05.2014',55955.83,2797.79, null],['22.05.2014',11243.90,2810.98, null],['26.05.2014',92501.43,2890.67, null],['28.05.2014',5795.98,2897.99, null],['29.05.2014',68444.93,2851.87, null],['02.06.2014',8428.53,2809.51, null],['03.06.2014',28092.47,2809.25, null],['04.06.2014',14085.04,2817.01, null],['06.06.2014',2800.03,2800.03, null],['09.06.2014',5789.60,2894.80, null],['10.06.2014',31968.05,2906.19, null],['11.06.2014',50176.02,2951.53, null],['13.06.2014',67871.18,2827.97, null],['16.06.2014',14198.77,2839.75, null],['18.06.2014',5920.00,2960.00, null],['20.06.2014',29529.70,2952.97, null],['23.06.2014',31367.44,2851.59, null],['24.06.2014',5919.89,2959.95, null],['26.06.2014',316756.81,3045.74, null],['27.06.2014',87289.97,3010.00, null],['30.06.2014',38045.98,2926.61, null],['08.07.2014',25590.53,2843.39, null],['10.07.2014',8607.01,2869.00, null],['11.07.2014',8349.02,2783.01, null],['14.07.2014',68505.15,2740.21, null],['15.07.2014',24554.81,2728.31, null],['17.07.2014',16522.10,2753.68, null],['18.07.2014',17099.28,2849.88, null],['21.07.2014',17076.99,2846.17, null],['23.07.2014',20174.51,2882.07, null],['25.07.2014',36778.00,2829.08, null],['28.07.2014',2890.00,2890.00, null],['29.07.2014',14449.00,2889.80, null],['30.07.2014',11575.70,2893.93, null],['31.07.2014',17328.00,2888.00, null],['04.08.2014',5607.00,2803.50, null],['08.08.2014',41765.45,2784.36, null],['11.08.2014',11389.80,2847.45, null],['14.08.2014',16800.32,2800.05, null],['18.08.2014',13931.28,2786.26, null],['19.08.2014',30429.00,2766.27, null],['21.08.2014',11173.87,2793.47, null],['22.08.2014',19425.00,2775.00, null],['26.08.2014',8482.90,2827.63, null],['27.08.2014',33943.90,2828.66, null],['28.08.2014',13161262.62,2949.63, null],['29.08.2014',29879.80,2987.98, null],['01.09.2014',2980.00,2980.00, null],['03.09.2014',176917.09,2808.21, null],['04.09.2014',279173.18,2848.71, null],['05.09.2014',199712.14,2894.38, null],['08.09.2014',37701.00,2900.08, null],['09.09.2014',254355.79,2857.93, null],['10.09.2014',87778.22,2831.56, null],['11.09.2014',2849.99,2849.99, null],['12.09.2014',86949.85,2804.83, null],['15.09.2014',2847.97,2847.97, null],['16.09.2014',166566.09,2823.15, null],['17.09.2014',5700.00,2850.00, null],['18.09.2014',14150.00,2830.00, null],['19.09.2014',19849.50,2835.64, null],['22.09.2014',14199.99,2840.00, null],['23.09.2014',70005.08,2800.20, null],['24.09.2014',338981.13,2801.50, null],['25.09.2014',221199.51,2799.99, null],['26.09.2014',63699.57,2769.55, null],['29.09.2014',5640.00,2820.00, null],['30.09.2014',2859.90,2859.90, null],['01.10.2014',128800.00,2800.00, null],['02.10.2014',1623278.42,2823.09, null],['03.10.2014',1569624.84,2906.71, null],['06.10.2014',132023.96,3000.54, null],['07.10.2014',41789.14,2984.94, null],['09.10.2014',655929.65,2954.64, null],['10.10.2014',285681.36,3071.84, null],['13.10.2014',341861.28,3025.32, null],['14.10.2014',15102.00,3020.40, null],['15.10.2014',290271.14,2961.95, null],['16.10.2014',127609.42,2900.21, null],['17.10.2014',29225.22,2922.52, null],['20.10.2014',50966.92,2998.05, null],['21.10.2014',9056.97,3018.99, null],['22.10.2014',6035.52,3017.76, null],['23.10.2014',9050.79,3016.93, null],['27.10.2014',230299.48,2915.18, null],['28.10.2014',9020.00,3006.67, null],['29.10.2014',35511.96,2959.33, null],['30.10.2014',2983.00,2983.00, null],['31.10.2014',8910.00,2970.00, null],['03.11.2014',11877.73,2969.43, null],['04.11.2014',51850.97,2880.61, null],['05.11.2014',22965.88,2870.74, null],['06.11.2014',2900.00,2900.00, null],['07.11.2014',5800.00,2900.00, null],['10.11.2014',20040.04,2862.86, null],['11.11.2014',5800.00,2900.00, null],['12.11.2014',8700.00,2900.00, null],['13.11.2014',8612.10,2870.70, null],['14.11.2014',91200.04,2850.00, null],['17.11.2014',62205.00,2827.50, null],['18.11.2014',2869.00,2869.00, null],['19.11.2014',2868.88,2868.88, null],['20.11.2014',282868.12,2800.67, null],['21.11.2014',5736.78,2868.39, null],['24.11.2014',5738.00,2869.00, null],['25.11.2014',475557.92,2764.87, null],['26.11.2014',144687.50,2782.45, null],['27.11.2014',5699.99,2850.00, null],['28.11.2014',189405.05,2785.37, null],['01.12.2014',165319.78,2802.03, null],['02.12.2014',5700.00,2850.00, null],['03.12.2014',37129.59,2856.12, null],['04.12.2014',58133.51,2906.68, null],['08.12.2014',8706.90,2902.30, null],['09.12.2014',22970.00,2871.25, null],['10.12.2014',14364.00,2872.80, null],['11.12.2014',60900.00,2900.00, null],['12.12.2014',14567.80,2913.56, null],['15.12.2014',64048.44,2911.29, null],['16.12.2014',63800.00,2900.00, null],['17.12.2014',50559.78,2974.10, null],['18.12.2014',5920.00,2960.00, null],['19.12.2014',5960.00,2980.00, null],['22.12.2014',8837.40,2945.80, null],['30.12.2014',14764.95,2952.99, null],['31.12.2014',49704.00,2923.76, null],['02.01.2015',14756.00,2951.20, null],['05.01.2015',169712.07,2977.40, null],['07.01.2015',20688.50,2955.50, null],['08.01.2015',30147.51,3014.75, null],['09.01.2015',26680.15,2964.46, null],['12.01.2015',94847.30,2963.98, null],['13.01.2015',14776.32,2955.26, null],['14.01.2015',449995.50,2999.97, null],['15.01.2015',5917.03,2958.52, null],['16.01.2015',5967.98,2983.99, null],['19.01.2015',8844.83,2948.28, null],['21.01.2015',158149.94,2928.70, null],['22.01.2015',5880.00,2940.00, null],['23.01.2015',8771.94,2923.98, null],['26.01.2015',14428.16,2885.63, null],['27.01.2015',5850.00,2925.00, null],['29.01.2015',104246.36,2817.47, null],['03.02.2015',2895.00,2895.00, null],['06.02.2015',14172.35,2834.47, null],['12.02.2015',217521.26,2753.43, null],['16.02.2015',42715.78,2847.72, null],['17.02.2015',149334.86,2871.82, null],['18.02.2015',281230.81,2899.29, null],['20.02.2015',28962.00,2896.20, null],['23.02.2015',59300.00,2965.00, null],['24.02.2015',38544.81,2964.99, null],['26.02.2015',31843.00,2894.82, null],['27.02.2015',8700.00,2900.00, null],['04.03.2015',5880.00,2940.00, null],['06.03.2015',14463.00,2892.60, null],['09.03.2015',58259.90,2913.00, null],['11.03.2015',8841.87,2947.29, null],['12.03.2015',23575.17,2946.90, null],['13.03.2015',26537.45,2948.61, null],['18.03.2015',26418.00,2935.33, null],['24.03.2015',2935.49,2935.49, null],['07.04.2015',48003.08,2823.71, null],['09.04.2015',39740.73,2838.62, null],['15.04.2015',43077.14,2871.81, null],['17.04.2015',28490.54,2849.05, null],['24.04.2015',11399.96,2849.99, null],['27.04.2015',16904.82,2817.47, null],['28.04.2015',19950.00,2850.00, null],['29.04.2015',17190.00,2865.00, null],['30.04.2015',57852.59,2892.63, null],['07.05.2015',86860.32,2801.95, null],['13.05.2015',8625.98,2875.33, null],['14.05.2015',8538.00,2846.00, null],['20.05.2015',11399.96,2849.99, null],['22.05.2015',81368.70,2805.82, null],['26.05.2015',8519.97,2839.99, null],['27.05.2015',2830.00,2830.00, null],['28.05.2015',5699.62,2849.81, null],['29.05.2015',97513.10,2786.09, null],['01.06.2015',19600.00,2800.00, null],['02.06.2015',131054.08,2788.38, null],['08.06.2015',24959.86,2773.32, null],['09.06.2015',30818.28,2801.66, null],['10.06.2015',11199.88,2799.97, null],['11.06.2015',33595.21,2799.60, null],['15.06.2015',75473.63,2795.32, null],['17.06.2015',157289.94,2808.75, null],['18.06.2015',126949.92,2821.11, null],['19.06.2015',36840.70,2833.90, null],['26.06.2015',8669.67,2889.89, null],['29.06.2015',126881.03,2819.58, null],['30.06.2015',28075.22,2807.52, null],['01.07.2015',84318.94,2810.63, null],['02.07.2015',75378.98,2791.81, null],['03.07.2015',5600.00,2800.00, null],['06.07.2015',14000.00,2800.00, null],['07.07.2015',30919.91,2810.90, null],['09.07.2015',11290.23,2822.56, null],['13.07.2015',16987.82,2831.30, null],['14.07.2015',195402.67,2873.57, null],['16.07.2015',14293.25,2858.65, null],['20.07.2015',45217.29,2826.08, null],['22.07.2015',2895.54,2895.54, null],['24.07.2015',17157.52,2859.59, null],['27.07.2015',28253.70,2825.37, null],['28.07.2015',8499.96,2833.32, null],['29.07.2015',90013.22,2812.91, null],['03.08.2015',14094.99,2819.00, null],['06.08.2015',14210.00,2842.00, null],['10.08.2015',50464.71,2803.60, null],['17.08.2015',14079.98,2816.00, null],['20.08.2015',8486.81,2828.94, null],['21.08.2015',14102.88,2820.58, null],['24.08.2015',96942.62,2769.79, null],['25.08.2015',8302.94,2767.65, null],['27.08.2015',13762.00,2752.40, null],['31.08.2015',153443.49,2645.58, null],['01.09.2015',13629.94,2725.99, null],['02.09.2015',13725.00,2745.00, null],['14.09.2015',13500.00,2700.00, null],['17.09.2015',78589.79,2619.66, null],['21.09.2015',13117.87,2623.57, null],['23.09.2015',51440.04,2572.00, null],['24.09.2015',7710.33,2570.11, null],['29.09.2015',17899.00,2557.00, null],['01.10.2015',2598.99,2598.99, null],['02.10.2015',2522.00,2522.00, null],['05.10.2015',41597.98,2599.87, null],['13.10.2015',10512.00,2628.00, null],['15.10.2015',41104.20,2569.01, null],['19.10.2015',170859.86,2588.79, null],['20.10.2015',34069.37,2620.72, null],['21.10.2015',154359.93,2616.27, null],['22.10.2015',2677.34,2677.34, null],['23.10.2015',181317.94,2706.24, null],['26.10.2015',108040.40,2701.01, null],['27.10.2015',617770.82,2709.52, null],['28.10.2015',105427.06,2849.38, null],['30.10.2015',64027.71,2783.81, null],['02.11.2015',61029.97,2774.09, null],['03.11.2015',32868.95,2739.08, null],['09.11.2015',42364.12,2824.27, null],['10.11.2015',8343.21,2781.07, null],['11.11.2015',8489.79,2829.93, null],['12.11.2015',22240.08,2780.01, null],['13.11.2015',27845.00,2784.50, null],['25.11.2015',46729.86,2748.82, null],['30.11.2015',27094.22,2709.42, null],['01.12.2015',5595.94,2797.97, null],['07.12.2015',13694.92,2738.98, null],['14.12.2015',5589.72,2794.86, null],['18.12.2015',47928.95,2662.72, null],['21.12.2015',35093.71,2699.52, null],['28.12.2015',2779.93,2779.93, null],['29.12.2015',2777.70,2777.70, null],['30.12.2015',41141.49,2742.77, null],['04.01.2016',15930.39,2655.07, null],['08.01.2016',2556.20,2556.20, null],['13.01.2016',7740.11,2580.04, null],['14.01.2016',23220.00,2580.00, null],['19.01.2016',63170.18,2526.81, null],['21.01.2016',74712.75,2490.43, null],['25.01.2016',13240.75,2648.15, null],['26.01.2016',26452.05,2645.21, null],['27.01.2016',26488.90,2648.89, null],['29.01.2016',13243.95,2648.79, null],['01.02.2016',18340.00,2620.00, null],['03.02.2016',66195.05,2647.80, null],['04.02.2016',93840.86,2681.17, null],['09.02.2016',2770.00,2770.00, null],['15.02.2016',10760.79,2690.20, null],['16.02.2016',11099.42,2774.86, null],['17.02.2016',8391.90,2797.30, null],['18.02.2016',41917.00,2794.47, null],['22.02.2016',27359.03,2735.90, null],['29.02.2016',28304.73,2830.47, null],['04.03.2016',5670.00,2835.00, null],['08.03.2016',5671.65,2835.83, null],['09.03.2016',11213.08,2803.27, null],['16.03.2016',116990.48,2658.87, null],['18.03.2016',11020.49,2755.12, null],['21.03.2016',5498.98,2749.49, null],['31.03.2016',16209.38,2701.56, null],['01.04.2016',10804.00,2701.00, null],['04.04.2016',101067.99,2731.57, null],['05.04.2016',13500.00,2700.00, null],['06.04.2016',21917.75,2739.72, null],['11.04.2016',48711.06,2706.17, null],['12.04.2016',2700.00,2700.00, null],['15.04.2016',16200.00,2700.00, null],['18.04.2016',8100.00,2700.00, null],['19.04.2016',8058.15,2686.05, null],['21.04.2016',27000.00,2700.00, null],['29.04.2016',2748.87,2748.87, null],['02.05.2016',2665.01,2665.01, null],['04.05.2016',2726.00,2726.00, null],['05.05.2016',49588.99,2754.94, null],['06.05.2016',479562.99,2837.65, null],['09.05.2016',36530.09,2810.01, null],['10.05.2016',25248.00,2805.33, null],['17.05.2016',25200.00,2800.00, null],['19.05.2016',20299.99,2900.00, null],['23.05.2016',17200.00,2866.67, null],['24.05.2016',11626.12,2906.53, null],['30.05.2016',28404.23,2840.42, null],['31.05.2016',39256.86,2804.06, null],['06.06.2016',5700.00,2850.00, null],['13.06.2016',11198.38,2799.60, null],['14.06.2016',2869.37,2869.37, null],['23.06.2016',30304.31,2754.94, null],['24.06.2016',8279.70,2759.90, null],['27.06.2016',2712.46,2712.46, null],['29.06.2016',11200.00,2800.00, null],['14.07.2016',13900.00,2780.00, null],['21.07.2016',8370.00,2790.00, null],['25.07.2016',2715.00,2715.00, null],['29.07.2016',53069.90,2793.15, null],['01.08.2016',24741.00,2749.00, null],['02.08.2016',5580.00,2790.00, null],['11.08.2016',13725.09,2745.02, null],['12.08.2016',2789.99,2789.99, null],['18.08.2016',8250.00,2750.00, null],['22.08.2016',125839.89,2796.44, null],['23.08.2016',25560.00,2840.00, null]]
      );

    var options = {
      title : 'w00t',
      vAxis: {title: ''},
      hAxis: {title: ''},
      seriesType: 'lines',
      series: {2: {type: 'bars'}},

    };

    var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  }</code>
<code><script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
       <div id="chart_div" style="width: 900px; height: 500px;"></div></code>
Comment: Try removing hard-coded size from style attribute on div
Comment: @WhiteHat I did that, no change...
Answer: The problem is in chart_div (div that contains Google Chart) width - it's fixed on 900px, and all that data (columns) does not fit into that width. You have to extend width manually.


Is it possible to do this: MyInt.CustomMethod

Question: I am making a game in C#, where you have ammo and a max capacity of it.
Is it possible to make some kind of method like this
ammoInt.Maxed;
so that i can use it like this:
if (ammoInt.Maxed == true) etc.
to check if ammo int is equal to maxAmmoInt?
EDIT:
Thank you for the input, but one last question: do the extension have to be in a seperate class?
Comment: Look at extension methods
Comment: Yes extension methods need to be in a seperate class
Answer: You can create an Extension method for int. Like:
public static class MyExtensions
{
    public static bool Maxed(this int parameter)
    {
        return parameter > 100;
    }
}

Then you can call it like:
if(ammoInt.Maxed())

Answer: Technically, yes. Extension methods provide this in .Net. But this is bad design.
public static class MyExtensions
{
    public static public bool IsMaxed( this int value )
    {
        return value > 50; // or whatever
    }
}

int thing = 10;
bool result = thing.IsMaxed( );

This allows you to call that method on any int object. But like I said, you should probably reconsider the design of that, as that is a hack.
Comment: You really shouldn't be adding extensions to primitive types. In this context it may make sense to see if this int is at it's max. But this method doesn't really apply to ALL integers in the project. So at any random point he could be developing, have an integer, and see it has an IsMaxed method. No context there.
Comment: Why do you say that it is a hack? And the class has to be static also, FYI
Comment: You should specify that in your answer as this wouldn't be a hack if all ints in the OP's project have this property. That is why I had to ask the Q...it needs to be looked at from multiple angles :)
Answer: The way that I see it is that you have two options.
1) Create a wrapper class that has a bool property that check if its value if greater than 100
public class Ammo
{
    public int Value {get; set;}
    public bool Maxed
    {
       get
       {
         return Value > 100;
       }
    }
}

2) You can create an Extension Method
public static class CustomExtensions
{
   public static bool Maxed(this int value)
   {
      return value> 100;
   }
}

Comment: I wouldn't even call it `MyAmmoInt`, just call it `Ammo`.  (Also, it probably makes sense as an immutable struct, rather than a mutable class, even though making it a struct (properly) would take a fair bit more typing.
Comment: @Servy I totally agree, it was more for demonstration that it is in fact a simple wrapper class.
Comment: My point though is that you shouldn't think of it so much as a wrapper, but as the representation of "ammo", which just happens to have nothing more to it than an int.  Conceptually it's not a wrapper, it's just everything there is to know about ammo.


Como editar as rotas criadas pelo comando make:auth?

Question: Tenho um projeto no Laravel onde utilizei o comando make:auth para criar as views, rotas, controllers e etc, de um formulário de cadastro.
Preciso alterar o a view que é utilizada por padrão no login para uma view que criei a mão.
Dúvida:

Tem como editar essa view ou rota?
Se sim, onde?
Answer: Isso vai depender da versão do Laravel que você está usando.
Laravel 5.2
Você precisa adicionar a propriedade $loginView na classe AuthController.
Assim:
protected $loginView = 'nome_da_minha_view';

No código fonte do trait chamado Illuminate\Foundation\Auth\AuthenticatesUsers, há um método chamado showLoginForm, que está escrito assim:
/**
 * Show the application login form.
 *
 * @return \Illuminate\Http\Response
 */
public function showLoginForm()
{
    $view = property_exists($this, 'loginView')
                ? $this->loginView : 'auth.authenticate';

    if (view()->exists($view)) {
        return view($view);
    }

    return view('auth.login');
}

observe que, se existir a propriedade loginView na classe atual (nesse contexto seria AuthController), a view utilizada será a definida nessa propriedade, caso a view  também exista (conforme a verificação de view()->exists().
Laravel 5.3 e 5.4
Você precisa simplesmente sobrescrever o método chamado showLoginForm na classe de autenticação e retornar a view desejada.
  public function showLoginForm()
  {
        return view('minha_view_personalizada');
  }

Há ainda uma outra dica, que é de criar o método chamado getLogin retornando a view. Surtirá o mesmo efeito que o demonstrado acima com showLoginForm.
Comment: O meu Laravel está na versão 5.4... Por isso, onde encontro esse 'showLoginForm'?
Comment: Meu projeto n possui AuthController
Answer: Neste caso em específico de mudar as views você vai querer seguir a recomendação do amigo @Wallace Maxters. Este é o caminho recomendável. ;)
Na eventual necessidade de personalizar as rotas, você pode simplesmente comentar a linha Auth::routes() do arquivo routes/web.php e declarar as rotas manualmente seguindo o modelo de como elas foram declaradas (estou usando o Laravel 5.4 como referência):
// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');

Para não precisar mudar nada no código você só precisa manter os nomes das rotas e manter a mesma URL nas rotas que repetem a URL, de modo que você pode por exemplo traduzir a URL login para entrar desde que você faça isso tanto na rota GET como na rota POST.
De modo geral você não precisa trocar os métodos que as rotas apontam uma vez que você pode sobrecarregar eles diretamente nas classes que eles dependem. ;)
Comment: É sempre interessante trazer a informação de como o framework trabalha internamente. +1
Comment: Particularmente, eu sempre excluo tudo de  autenticação do Laravel e faço na mão. Sempre preciso personalizar alguma coisa, kkkkkkk
Comment: Como faço p/ após me logar ou registrar algum usuário, retorne para uma view criada por mim e não a \home?


Is there any way to export d3 output to visio file?

Question: Is there any way to export d3 output to a Visio file?
Comment: i think you can't. you can export to an image as mentioned here: http://stackoverflow.com/questions/3975499/convert-svg-to-image-jpeg-png-etc-in-the-browser
Answer: Output of d3.js is normally an SVG file.
You can open SVG files in Visio using File -> Open
Comment: You can open SVG and then save it as VDX using Visio 2003-2010. Note that VDX format is deprecated now and not supported for saving in Visio 2013.


Getting all the Term Stores in Sharepoint 2010 (web services or client-side object model)?

Question: Is it possible with Sharepoint 2010 (not 2013!) to get a list of all the Term Stores on the site using either the web services or the client-side object model?
I know 2013 has added a library for it, but that will not help me on 2010.
If not the whole list, how do I get the Term Store ID, if I know a Term (that might or might not be in the TaxonomyHiddenList)?
Answer: Someone mentioned checking out the TaxonomyFieldType fields, so I hacked together these 2 methods. I do not know if these will work under all circumstances.
First function just returns the Term Store ID which is stored in the info of the first TaxonomyFieldType* we come over.
public static string GetDefaultTermStore(string site) {
    var context = new ClientContext(site);
    var fields = context.Web.Fields;
    context.Load(fields, fs => fs.Include(f => f.SchemaXml, f => f.TypeAsString));
    context.ExecuteQuery();
    foreach (var field in fields) {
        if (field.TypeAsString.StartsWith("TaxonomyFieldType")) {
            var doc = XDocument.Parse(field.SchemaXml);
            var node = doc.XPathSelectElement("//Name[text()='SspId']/../Value");
            if (node != null && !string.IsNullOrEmpty(node.Value)) {
                return node.Value;
            }
        }
    }
    throw new Exception("Term Store ID not found!");
}

The second function goes through all the fields and gets all the possible Term Store IDs and returns them in a list.
public static List<string> GetTermStores(string site) {
    var context = new ClientContext(site);
    var fields = context.Web.Fields;
    context.Load(fields, fs => fs.Include(f => f.SchemaXml, f => f.TypeAsString));
    context.ExecuteQuery();
    var hashlist = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
    foreach (var field in fields) {
        if (field.TypeAsString.StartsWith("TaxonomyFieldType")) {
            var doc = XDocument.Parse(field.SchemaXml);
            var node = doc.XPathSelectElement("//Name[text()='SspId']/../Value");
            if (node != null && !string.IsNullOrEmpty(node.Value)) {
                if (!hashlist.Contains(node.Value)) {
                    hashlist.Add(node.Value);
                }
            }
        }
    }
    if (hashlist.Count == 0) throw new Exception("No Term Store IDs not found!");
    return hashlist.ToList();
}

Is this a correct answer to my question do anyone have a more sure way to get the IDs?
Does not seem like anyone else has a good answer for this question.
I have added the utility class I made from this below. Big block of uncommented code below for those who might need:
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web.Services.Protocols;
using System.Windows.Forms;
using System.Xml.Linq;
using System.Xml.XPath;

namespace VitaminTilKanbanPusher.Sharepoint {
    public class SharepointTaxonomyAgent {

        //URLS:
        //http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/
        //

        public static void Test() {

            var site = ConfigurationManager.AppSettings["VitaminSite"];
            //var list = ConfigurationManager.AppSettings["VitaminList"];
            //var id = GetDefaultTermStore(site);
            //var ids = GetTermStores(site);
            var rs = GetAllTermSetNames(site);
            var ts = GetTermSetTerms(site, "Some Name");
            //var ts = GetTermSetTerms(site, "Some other name");

            //var term = GetTermInfo(site, "Priority");
            //var term2 = GetTermInfo(site, "My term");
            //var termset = GetTermSetInfo(site, "My term");
            //var termsets = GetTermSets(site, "My term");

        }

        public static string GetDefaultTermStore(string site) {
            var context = new ClientContext(site);
            context.ExecutingWebRequest += ctx_MixedAuthRequest;
            var fields = context.Web.Fields;
            context.Load(fields, fs => fs.Include(f => f.InternalName, f => f.SchemaXml, f => f.TypeAsString));
            context.ExecuteQuery();

            foreach (var field in fields) {
                //field.InternalName== "TaxKeyword" -> possibly default?
                if (field.TypeAsString.StartsWith("TaxonomyFieldType")) {
                    var doc = XDocument.Parse(field.SchemaXml);
                    var node = doc.XPathSelectElement("//Name[text()='SspId']/../Value");
                    if (node != null && !string.IsNullOrEmpty(node.Value)) {
                        return node.Value;
                    }
                }
            }
            throw new Exception("Term Store ID not found!");
        }

        public static List<string> GetTermStores(string site) {
            var context = new ClientContext(site);
            context.ExecutingWebRequest += ctx_MixedAuthRequest;
            var fields = context.Web.Fields;
            context.Load(fields, fs => fs.Include(f => f.SchemaXml, f => f.TypeAsString));
            context.ExecuteQuery();

            var hashlist = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
            foreach (var field in fields) {
                if (field.TypeAsString.StartsWith("TaxonomyFieldType")) {
                    var doc = XDocument.Parse(field.SchemaXml);
                    var node = doc.XPathSelectElement("//Name[text()='SspId']/../Value");
                    if (node != null && !string.IsNullOrEmpty(node.Value)) {
                        if (!hashlist.Contains(node.Value)) {
                            hashlist.Add(node.Value);
                        }
                    }
                }
            }
            if (hashlist.Count == 0) throw new Exception("No Term Store IDs not found!");
            return hashlist.ToList();
        }

        private static List<TermSet> _termSets;
        public static List<TermSet> GetAllTermSetNames(string site, string onlySpecificTermSetName = null) {
            if (_termSets != null) {
                if (onlySpecificTermSetName == null) return _termSets;
                foreach (var ts in _termSets) {
                    if (ts.Name.Equals(onlySpecificTermSetName, StringComparison.InvariantCultureIgnoreCase)) {
                        return new List<TermSet>() { ts };
                    }
                }
                return new List<TermSet>();
            }

            var context = new ClientContext(site);
            context.ExecutingWebRequest += ctx_MixedAuthRequest;
            var fields = context.Web.Fields;
            context.Load(fields, fs => fs.Include(f => f.SchemaXml, f => f.TypeAsString));
            context.ExecuteQuery();

            var hashlist = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
            var termSets = new List<TermSet>();

            TermSet theChosenTermSet = null;

            foreach (var field in fields) {
                if (field.TypeAsString.StartsWith("TaxonomyFieldType")) {
                    var ts = new TermSet();
                    var doc = XDocument.Parse(field.SchemaXml);

                    var fn = doc.Element("Field");
                    if (fn == null) continue;

                    if (fn.Attribute("DisplayName") == null) continue;
                    if (fn.Attribute("ID") == null) continue;

                    ts.Name = fn.Attribute("DisplayName").Value;

                    //Only 1 set?
                    if (onlySpecificTermSetName != null) {
                        if (!ts.Name.Equals(onlySpecificTermSetName, StringComparison.InvariantCultureIgnoreCase)) {
                            theChosenTermSet = ts;
                        }
                    }

                    if (fn.Attribute("Description") != null) {
                        ts.Description = fn.Attribute("Description").Value;
                    }

                    var node = doc.XPathSelectElement("//Name[text()='SspId']/../Value");
                    if (node != null && !string.IsNullOrEmpty(node.Value)) {
                        ts.TermStoreId = node.Value;
                    }

                    var node2 = doc.XPathSelectElement("//Name[text()='TermSetId']/../Value");
                    if (node2 != null && !string.IsNullOrEmpty(node2.Value)) {
                        ts.Id = node2.Value;
                    }
                    else {
                        continue; //No ID found
                    }

                    //Unique hites
                    if (!hashlist.Contains(ts.Id)) {
                        hashlist.Add(ts.Id);
                        termSets.Add(ts);
                    }
                }
            }
            _termSets = termSets;

            if (onlySpecificTermSetName != null) return (theChosenTermSet == null ? new List<TermSet>() : new List<TermSet>() { theChosenTermSet });

            return termSets;
        }

        public static TermSet GetTermSetTerms(string site, string termName) {
            var ts = GetAllTermSetNames(site, termName);
            if (ts.Count == 0) throw new Exception("Could not find termset: " + termName);
            var theTermSet = ts[0];

            var proxy = new SharepointTaxWS.Taxonomywebservice();
            proxy.UseDefaultCredentials = true;
            proxy.PreAuthenticate = true;
            proxy.Url = Path.Combine(site, "_vti_bin/taxonomyclientservice.asmx");
            GetAuthCookie(proxy, site);

            var lciden = 1033; //var lcidno = 1044; // System.Globalization.CultureInfo.CurrentCulture.LCID

            var clientTime = DateTime.Now.AddYears(-2).ToUniversalTime().Ticks.ToString();
            var termStoreId = new Guid(theTermSet.TermStoreId);// Guid.Parse(theTermSet.TermStoreId);
            var termSetId = new Guid(theTermSet.Id);

            string clientTimestamps = string.Format("<timeStamp>{0}</timeStamp>", clientTime);
            string clientVersion = "<version>1</version>";
            string termStoreIds = string.Format("<termStoreId>{0}</termStoreId>", termStoreId.ToString("D"));
            string termSetIds = string.Format("<termSetId>{0}</termSetId>", termSetId.ToString("D"));
            string serverTermSetTimestampXml;
            string result = proxy.GetTermSets(termStoreIds, termSetIds, 1033, clientTimestamps, clientVersion, out serverTermSetTimestampXml);

            var term = ParseTermSetInfo(result);
            term.Description = theTermSet.Description;
            term.Id = theTermSet.Id;
            term.Name = theTermSet.Name;
            return term;
        }

        //public static Term GetTermSetInfo(string site, string termName) {

        //    var proxy = new SharepointTaxWS.Taxonomywebservice();
        //    proxy.UseDefaultCredentials = true;
        //    proxy.PreAuthenticate = true;
        //    proxy.Url = Path.Combine(site, "_vti_bin/taxonomyclientservice.asmx");

        //    GetAuthCookie(proxy, site);

        //    var lciden = 1033; //var lcidno = 1044; // System.Globalization.CultureInfo.CurrentCulture.LCID

        //    var sets = proxy.GetChildTermsInTermSet(Guid.Parse(""), lciden, Guid.Parse("termsetguid"));

        //    var term = ParseTermInfo(sets);

        //    return term;
        //}

        public static Term GetTermInfo(string site, string termName) {

            var proxy = new SharepointTaxWS.Taxonomywebservice();
            proxy.UseDefaultCredentials = true;
            proxy.PreAuthenticate = true;
            proxy.Url = Path.Combine(site, "_vti_bin/taxonomyclientservice.asmx");

            GetAuthCookie(proxy, site);

            var lciden = 1033; //var lcidno = 1044; // System.Globalization.CultureInfo.CurrentCulture.LCID

            var sets = proxy.GetTermsByLabel(termName, lciden, SharepointTaxWS.StringMatchOption.StartsWith, 100, null, false);

            var term = ParseTermInfo(sets);

            return term;
        }

        private static TermSet ParseTermSetInfo(string xml) {
            //Not done
            var info = XDocument.Parse(xml);
            var ts = new TermSet();
            ts.Terms = new List<Term>();

            var n1 = info.XPathSelectElements("//T");
            if (n1 != null) {
                foreach (var item in n1) {
                    var t = new Term();
                    t.Id = item.Attribute("a9").Value;
                    t.Name = item.XPathSelectElement("LS/TL").Attribute("a32").Value;
                    t.TermSet = ts;
                    ts.Terms.Add(t);
                }

            }
            return ts;
        }

        private static Term ParseTermInfo(string xml) {

            var info = XDocument.Parse(xml);
            var t = new Term();
            var ts = new TermSet();

            var n1 = info.XPathSelectElement("TermStore/T");
            var n2 = info.XPathSelectElement("TermStore/T/LS/TL");
            var n3 = info.XPathSelectElement("TermStore/T/TMS/TM");

            if (n1 != null && n1.Attribute("a9") != null) {
                t.Id = n1.Attribute("a9").Value;
            }
            if (n2 != null && n2.Attribute("a32") != null) {
                t.Name = n2.Attribute("a32").Value;
            }
            if (n3 != null && n3.Attribute("a24") != null) {
                ts.Id = n3.Attribute("a24").Value;
            }
            if (n3 != null && n3.Attribute("a12") != null) {
                ts.Name = n3.Attribute("a12").Value;
            }
            t.TermSet = ts;
            return t;
        }

        private static CookieCollection _theAuth;
        private static bool _bNoClaims;
        static void GetAuthCookie(SoapHttpClientProtocol proxy, string site) {
            return;
            //if (_bNoClaims) {
            //    return; //Ingen claims.
            //}
            //// get the cookie collection - authentication workaround
            //CookieCollection cook = null;
            //try {
            //    if (_theAuth == null) {
            //        cook = ClaimClientContext.GetAuthenticatedCookies(site, 925, 525);
            //    }
            //    else {
            //        cook = _theAuth;
            //    }

            //    _theAuth = cook;
            //    _bNoClaims = false;
            //}
            //catch (ApplicationException ex) {
            //    if (ex.Message.Contains("claim")) _bNoClaims = true;
            //    Console.Write("Auth feilet: " + ex.Message + " - ");
            //    //IGNORE
            //}
            //if (_theAuth != null) {
            //    proxy.CookieContainer = new CookieContainer();
            //    proxy.CookieContainer.Add(_theAuth);
            //}
        }

        static void ctx_MixedAuthRequest(object sender, WebRequestEventArgs e) {
            //add the header that tells SharePoint to use Windows Auth
            e.WebRequestExecutor.RequestHeaders.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
        }

    }

    public class TermSet {
        public string Id { get; set; }
        public string Name { get; set; }
        public List<Term> Terms { get; set; }
        public string TermStoreId { get; set; }

        public string Description { get; set; }

        public override string ToString() {
            int tc = 0;
            if (Terms != null) tc = Terms.Count;
            return Name + "|" + Id + " (" + tc + "terms)";
        }
    }

    public class Term {
        public string Id { get; set; }
        public string Name { get; set; }
        public TermSet TermSet { get; set; }
        public override string ToString() {
            return Name + "|" + Id;
        }
    }

}

Comment: Hi @Wolf5 I am also kind of struggling with the same scenario I have a Term Store called Products under Taxonomy and need to get all the fieldValues from this store, was wondering if you had finally discovered a solution to this blood sucking problem ?
Comment: No. Sorry. Ended up using the above code. Worked for my problem.
Comment: I have added the resulting code from my work. Lets me extract all the info I need from a sharepoint list (taxonomy fields and whatnot).
Comment: Thanks @Wolf5 I'll try to get benefited out of the above code but non of the function above seems to be to getting the TermStore Values.


Tajo: how update (from S3) is triggered?

Question: I set up a Tajo table from a S3 path and my understanding is that any changes in the S3 will be automatically applied to the Tajo table. Does Tajo poll status of the S3 object and see whether there is any change? How does that work in more detail? Thanks in advance!
Answer: When a user submits a SQL query to Tajo cluster running on Amazon EC2 and S3, Tajo directly reads and processes dataset stored in Amazon S3. So, latest queries always read updated data set on Amazon S3. You don't need to concern about how to update Tajo tables on updating objects in Amazon S3.


How to find optimal values for the tuning parameters in boosting trees ?

Question: I realise that there are 3 tuning parameters in the boosting trees model, i.e.

the number of trees (number of iterations)
shrinkage parameter
number of splits (size of each constituent trees)

My question is: for each of the tuning parameters, how should I find its optimal value ? And what method ?
Note that: the shrinkage parameter and the number of trees parameter operate together, i.e. a smaller value for shrinkage parameter leads to a higher value for the number of trees. And we need to take this into account too.
I am particularly interested in the method to find the optimal value for the number of splits. Should it be based on cross-validation or domain knowledge about the model behind?
And how are these things carried out in the gbm package in R ?
Answer: The caret package in R is tailor made for this.
Its train function takes a grid of parameter values and evaluates the performance using various flavors of cross-validation or the bootstrap. The package author has written a book, Applied predictive modeling, which is highly recommended. 5 repeats of 10-fold cross-validation is used throughout the book.
For choosing the tree depth, I would first go for subject matter knowledge about the problem, i.e. if you do not expect any interactions - restrict the depth to 1 or go for a flexible parametric model (which is much easier to understand and interpret). That being said, I often find myself tuning the tree depth as subject matter knowledge is often very limited.
I think the gbm package tunes the number of trees for fixed values of the tree depth and shrinkage.
Comment: Yes it does. Check out the book's webpage http://appliedpredictivemodeling.com for more info.
Comment: Does the book include R code as well?
Comment: I mean worked example that includes R code so we understand how the models are implemented computationally and applied on a dataset
Answer: There are two good sources for the boosted regression trees and gbm package. For the explanation of BRT and the optimization of the number of trees (nt), learning rate (lr) and tree complexity (tc) see A working guide to boosted regression trees Although it is focusing on ecology I think you wilĺ not find a better introduction to BRT.
For the implementation of BRT in the gbm package, see Boosted Regression Trees for ecological modeling
In short, a rule of thumb is to select a learning rate that allows the BRT model to
fit at least 1000 trees, so propably you will need  a low learning rate, maybe 0.001 to accomplish that. But it depends on the size of your data, see fig. 2 and 3 in the Working guide to BRT. I think one possible way would be the set up different models in BRT according to you data size, for example combine different lr (0.1, 0.01, 0.001), tc (1, 3, 5, 7, 9, 20) with different bag.fractions(0.5, 0.7, 0.9) and choose the best one according to lowest deviance or highest ROC score. Maybe it helped.
Comment: For reference, `BRT_MODEL$self.statistics$correlation[[1]]` is the correlation of testing to training data, which is a good test metric.
Comment: sounds like a statistical design of experiment to me.  :P


Can $L1$-regularization be applied in general case?

Question: I am not very clear about how far $L1$-regularization can work. For example, let $x\in \mathbb{R}^n$.
\begin{equation}\label{eq:Lasse1}
\begin{aligned}
&\max_{\mathbf{x}}
& &  f(\mathbf{x}) + \lambda\|\mathbf{x}\|_1\\
&\text{ s.t.} & & \|\mathbf{x}\|_1 \leq k \\
& & &  0\leq x_i\leq 1, \, i = 1, \ldots, n
\end{aligned}
\end{equation}
$f(\mathbf{x})$ is any nonconvex polynomial function of $x_i$, $i = 1, \ldots, n$.
$k\leq  n$.
Note that it is a maximization problem.
Suppose the optimal solution $\mathbf{x}^*$ exists when $\lambda = 0$.
In this case, can we get a sparsity approximated optimal solution $\mathbf{x}^*_{sp}$?
Note: in my research problem, it looks like that the solution does not change if I add $\lambda \|\cdot\|_1$ or not. I am not sure if it depends on the choice of $\lambda$
Answer: The whole idea with $L_1$ regularization is that you add a penalty on the variable in order to encourage sparsity when minimizing some objective. As you are doing it know, you are saying that a larger 1-norm is good. To obtain a regularization, you should subtract the norm when maximizing.
The fact that your solution is unaffected by your addition could be due to several reasons, one being that you are solving a nonconvex problem and thus easily could be stuck in some local minima.


need help to create regular expression

Question: i need regular expression which is not allow &#39
Comment: What's the *actual* problem you are trying to solve? Perhaps SQL injection? If so, then there are certainly better solutions than what you're proposing.
Comment: Yes, please give more detail on what you want to do and why.  That will get you the best possible answer.
Comment: i try this and it solved my problem

^[\s\w!"#$%&'()*+,-.<=>?.]{0,450}$
Answer: If you want to say "match any character but zzz," use [^].
<code>[^']+</code> will match one or more characters, up until it hits a '.
If you want to make sure the entire string does not contain the specified character:
<code>^[^']*$
</code>
Answer: This will match only strings that do not contain a single quotation mark (your question is very unspecific so I have no idea if that's what you want, please be as specific as possible and describe what you really want to do):
<code>/^[^']*$/
</code>

need help to create regular expression


How to get signal from AKAI MPK Mini MK3 in Ableton Live 11 Suite

Question: Just plugged in a new MPK Mini MK3. Opened Ableton Live 11 Suite, using the trial version not sure if that matters. See settings below and armed track. When touching the keys or any of the beat pads, there is no signal being shown in Ableton.
What else is required to have the signal from the MPK Mini available in Ableton? Any other details missing?
MIDI settings:

Track is "armed"
Answer: Seems to have been conflicting with other software. Just closed the following applications:
Adobe Premiere Pro CC
Adobe After Effects CC
OBS Studio
Adobe Audition
Hope this helps someone else. Try closing all other applications if you are not getting a signal.


Iterating through object properties and setting nullable properties through user input

Question: I am trying to iterate through an object's properties and prompt the user to input their value in each iteration. Some of my properties are nullable and with my current code I'm getting an error, specifically where I try to convert the user's input to a property type which is a nullable.
Is there something I can use to make the user input convert to nullable datatype please?
Here is my code:
someClass newObject = new someClass();

foreach(PropertyInfo prop in newObject.GetType().GetProperties()) {
  do {
    try {
      Console.WriteLine($"Enter {prop.Name} for new Object:");

      string input = Console.ReadLine();
      var convertedInput = Convert.ChangeType(input, prop.PropertyType);

      prop.SetValue(newObject, convertedInput);

      valid = true;
    } catch {
      Console.WriteLine($"INVALID INPUT - PLEASE INPUT A VALID {prop.Name} WHICH IS OF TYPE: {prop.PropertyType}");
      valid = false;
    }
  } while (!valid);
}

Answer: Use Nullable.GetUnderlyingType() to get the underlying type of a nullable type. If it's not a nullable type, it returns null, so you can check for null and use the actual property type instead. Like this:
var convertedInput = Convert.ChangeType(input,
              Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);

Comment: This worked however, when I enter empty inputs now I am getting an error there since it's still not nullable.
But I guess I can check whether the user's input is NullOrEmpty and just set it to null. Is that a good approach?
Comment: I think you mean that the type cannot have a null value (like `DateTime`) but the input is null? What does the actual exception say?
Comment: No I mean that since you're still converting to the underlying type, if the user inputs "" it will not be accepted. But I have figured it out so it's okay.

Thanks again for your help though :)


What is the probability that Bond will be injured?

Question: James Bond is recording. On a break he crosses an avenue. The cars pass according to a homogeneous Poisson Process with intensity $\lambda = 6$ per minute. He takes $s$ seconds to cross and can dodge (only) one car during his crossing. If a car passes that point and you don't dodge it, then you will get injured. What is the probability that Bond will be injured? (for $s = 10, 20$).
I have problems doing this exercise, honestly I don't know how to do it, the fact of working with minutes and seconds causes me a lot of conflict, can you help me?
My idea was to say that since the cars pass according to a poisson process of intensity $\lambda=6$ per minute then, the cars pass according to a poisson process of intersity $\lambda=\frac{6}{60} =0.1$, then the probability we are looking for is $P[N(t)\geq 2]$, In this case $P[N(10)\geq 2]$ and $P[N(20)\geq 2]$, is this correct?
Comment: That sounds correct to me, yes. (although it seems there was a slight typo and you meant $P[N(t) \geq 2]$ the first time, which does appear to be the right form)
Answer: Your reasoning is correct. Let $X_s$ be the number of cars that arrive in $(0,s)$ - this has Poisson distribution with parameter $\frac {\lambda s}{60}$ (with $\lambda = 6$, this reduces to $\frac s{10}$). The desired probability is then
$$
\mathbb P(X_s\geqslant 2) = 1-(\mathbb P(X_s=0)+\mathbb P(X_s=1))\\
= 1 - e^{-\frac s{10}}\left(1 + \frac s{10}\right)\\
$$
For $s=10$ this is $1-2e^{-1}\approx0.264241$ and for $s=20$ this is $1-3e^{-2}\approx0.593994$.


how to count results in a Calendar view?

Question: I enable the calendar module, then "Add view from template" on /admin/structure/views/add-template, but I cannot count nodes published at the same day in the month view by following this tutorial.
I want events occurred in the same day can be counted like "3 events occurred" other than the original output in the red box, and the counted field can be rewritten.

I tried aggregation feature of views, but no luck.
Answer: Finally, I get it working.
After I turn on View's setting "Show the SQL query", I notice there is an unnecessary GROUP BY field "nid" in the Calendar view, then I unset this field in a hook_query_alter(QueryAlterableInterface $query) as below:
<code>if ($query->hasTag('views_' . $view_name)) {
    $fields =& $query->getGroupBy();
    unset($fields['nid']);
}
</code>
Comment: fishfree, please add detalis on how you did manage to count results, i allready unset group by nid, but i cant go further, i tryed aggregation, no luck, i override every teamplate in month-calendar view and nothing.


Problemas com OpenCV(python3 e ROS)

Question: eu estou usando ROS para um projeto na faculdade, mas quando vou tentar usar python 3 para chamar o opencv, ocorre esse problema
"ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type"
 Já estou a quase uma semana tentando resolver e não consigo.
Answer: Segundo essa página, não existe uma distribuição oficial do ROS pro Python 3, mas pode ser possível fazer funcionar se você compilar o ROS da fonte.

Problemas com OpenCV(python3 e ROS)


How do you redirect to CGI only on a query?

Question: I'm replacing index.cgi of gitweb with a static index.html page.
However I don't want links to gitweb repositories to break, such as http://example.com/?p=foobar;
My non-working .htaccess currently looks like:
DirectoryIndex index.html index.php
RewriteCond %{QUERY_STRING} p
RewriteRule ^/ /index.cgi

What am I missing?
Comment: When you say "non-working", what exactly do you see?  The only obvious thing I see missing is `RewriteEngine on`.
Comment: Oh, also in a directory context (i.e. In a .htaccess file) URIs don't start with a slash.  In the server context they do.
Answer: By my reading of the RewriteRule docs ("What is matched?" box), if your RewriteRule is in a Directory section or .htaccess file, then the leading / will be stripped away, so the pattern in your rule won't match.  You could try replacing the pattern by just ^, i.e.
RewriteRule ^ /index.cgi

Comment: Request exceeded the limit of 10 internal redirects due to probable configuration error. :(
Answer: With that rule you will never be able to access the index.html page as the redirect will match anything.
You would need to do something along the lines of
RewriteCond %{QUERY_STRING}      ^$
RewriteRule ^/                   /index.html [L]
RewriteRule ^/                   /index.cgi

Which should work out similar to 'if you don't have a querystring go to index.html, otherwise go to index.cgi and pass the rest of the string along too!'
Answer: It will match any URI that is not index.cgi or index.html beginning with a p query string and rewrite it to your cgi.
RewriteCond %{QUERY_STRING} ^p
RewriteRule !(index.cgi|index.html) /index.cgi [L]

The L option means that Apache stops processing rewrite rules.
Comment: Stangely I get a 404 The requested URL /srv/www/wac2tests/index.cgi was not found on this server.
Comment: but x220:~$ file /srv/www/wac2tests/index.cgi
/srv/www/wac2tests/index.cgi: symbolic link to `/srv/http/gitweb/gitweb.cgi'
Comment: That's not a URL, that's a file path.  I'm not sure why it's doing that.  I've seen Apache do that before but I can't remember what caused it.
Comment: Nice, short and sweet! QSA is unneeded and won't match example.com/ however.
Comment: actually this seems to redirect and file query string, even on say /ui/?foobar to /index.cgi... urgh :(


413 request entity too large

Question: Eu tenho um serviço de emissão de notas que estava funcionando normalmente em uma VM no azure. Migramos para uma VM da Google e agora apresenta este erro quando a nota possui muitos produtos:

413 request entity too large

Já tentei várias possibilidades procurando no Google e verificamos que, a princípio, as configurações do Serviço e do IIS estão iguais nas duas VMs, mas a do Azure funciona e Google não.
Esta pergunta pode parecer duplicada, mas as soluções que encontrei em outras questões do mesmo problema não me ajudaram.
Comment: Mas está por POST.
Comment: Está passando os parâmetros pela url ao invés do POST, aí dá nisso! Provavelmente o servidor pode estar configurado para aceitar um número menor de caracteres do que antes.
Comment: Se você habilitar o trace no serviço WCF, ele chega a logar a mensagem? Se não souber como habilitar pode ver nesse link: https://msdn.microsoft.com/pt-br/library/ms733025(v=vs.110).aspx
Pergunto isso para saber quem está limitando seu post, se é o IIS ou o WCF.
Comment: O mesmo WCF em outro servidor não apresenta esse erro. É a mesma publicação do WCF (mesmos arquivos) nos dois servidores e apenas no da Google apresenta o erro.
Comment: Se você tem a mesma aplicação e config, então provavelmente o problema é com o hosting na VM do Google. Já tentou obter suporte deles?
Comment: Ainda não tentamos suporte direto deles. Identificamos que ao tentar importar o serviço WCF instalado na VM da Google, apresenta um erro, mas ao apenas trocar o endpoint ele funciona (mas com o erro 413). Vimos aqui que o DNS da máquina foi trocado e talvez o IIS tivesse desconfigurado. Estamos reinstalando tudo e vendo se o problema é esse. Se não funcionar, procurar o  suporte da Google pode ser uma boa ideia.
Answer: Como última tentativa, resolvemos apagar todas as referências e usos do WSDL em nosso projeto e refazê-la, porém ao tentarmos deu erro. Identificamos que o erro era por um problema no DNS. Corrigimos o problema, atualizamos as referências e tudo voltou a funcionar normalmente.

413 request entity too large


How does SatoshiDice work?

Question: I'm sure this is a silly and banal question next to all the crazy string theory and lambda calculus questions on this site. Perhaps it's a nice, easy, refreshing break. Anyway, on to the casino...
SatoshiDice is a betting website. You expose your money to risk and gamble for a reward.
I know the house maintains an edge, but I'm just having trouble reasoning through it. Would someone mind explaining it to me with a simple example?
For example, say I wager 1 bitcoin on the "lessthan 48000" bracket. I have a 73% chance of winning, but the payout is only "1.323x", and the house takes a 3% rake. So, 73 out of 100 times playing I'll win slightly over 1%, and 27/100 times I'll lose everything, so... well, here's where my brain pretty much shuts down. Maybe it's just time to get some sleep. :)
I asked this question here instead of http://bitcoin.stackexchange.com because it seems more about math than bitcoin.
Answer: the table says that your chance to win is 73.2422 % and then you get 1.323 times of your bet. then you win about 32,3% ($(1.323-1)*100$). Because of $0.732422*1.323 = 0.968994306$ the casino wins about $1-0.968994306=0,031005694$ that is about 3.1%
Comment: In particular, OP should notice that the house 3% rake is built into the payoff odds, and not excised separately.

How does SatoshiDice work?


unable to run generated python (selenium) script from PHP

Question: I have an Ubuntu machine for headless selenium tests.
I generate a python script in /var/www/tmp/random123name.py via PHP and execute them. The script works when run from command line user, fails when run from web (apache www-data:www-data user).
The script recalls some system / python modules:
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from time import sleep, strftime
import os, json
from pyvirtualdisplay import Display

This code returns 1:
$python = "sudo /usr/bin/python /var/www/tmp/random123name.py";
exec($python, $output, $return);
echo "OUT
".print_r($output,1)."
"; #returns empty
echo "RET
".print_r($return,1)."
"; #returns 1

I modified /etc/sudoers this way, without luck:
www-data ALL=(ALL:ALL) NOPASSWD: /usr/bin/python

I also tried
www-data ALL=(ALL:ALL) NOPASSWD: /usr/bin/python /var/www/tmp/

added www-data to dialout group and some other tries.
Thank you for your support.
Comment: Have you tried running the script from the command line as the www-data user? You can use su -s /bin/bash www-data to become the correct user.
Comment: What is in `$python`? Are you specifying the full path to your python interpreter and the full path the script? It might be that the command is not found.
Comment: Thank you guys for the replies. I tried to run the script and it doesnt work. $python = "sudo /usr/bin/python /var/www/tmp/random123name.py" (I update my question)
Comment: Have you tried calling `/usr/bin/sudo` rather than `sudo`?
Answer: I solved: it's not enough to exit back to youruser / root, you need to exit ssh session and reopen it in order to load everything needed for visudo to work.
Answer: As you yourself have figured out, changes to sudoers don't get applied to running sessions, only to new sessions. So you need to logout and login again to see it.
But much more importantly, you shouldn't need sudo for this purpose,
and allowing www-data user to run python as root without password is extremely scary. Surely there is a way to make your script work without needing root privileges, as a regular user, and I strongly urge you to try to figure that out, rather than resorting to sudo for this purpose.
Comment: luckily this VM is not exposed outside the LAN, but I'm willing to try any suggestion which would come, in order to have the lesson learned.


Multithreading code too slow with many workers but fast with few

Question: I wrote a code to speed up a brute force algorithm, i decided to use multithreading. Though I'm new to multithreading, and I understand that by creating large pools of workers(threads), and dividing jobs to them, the brute force should be super fast. Well, my code below works faster with few workers(10 or less), but slower with lots of workers(1000). Why the strange behaviour and where is the mistake?
<code>ExecutorService executor = Executors.newFixedThreadPool(1000);
            List<Callable<Integer>> callList = new ArrayList<>();
            Callable<Integer> worker;
            for (int i = 0; i < 1000; i++) {
                worker = new WorkerThread(start, end, id);
                Thread.currentThread().setName("Staff  "+i);
                callList.add(worker);
                start = end;
                end = end + addition + 1;
            }
            int result = executor.invokeAny(callList);
            System.out.println("Done Work");

            System.out.println(result);
            executor.shutdownNow();
            executor.awaitTermination(5, TimeUnit.NANOSECONDS);
</code>
Comment: The level of parallelism is limited by the computer's hardware. For instance, if you only have 8 processors then only 8 threads can run at a time (across all processes). Having too many more threads than available processors introduces overhead—especially when the task is CPU-bound.
Comment: There are probably a lot of overheads in the task scheduler and threads accessing data. You probably want as many workers as logical CPU cores.
Comment: @Slaw I'm using mac with only 2 cores and 1 processor (Intel Core i5 2.4 GHz). Those that mean I can only run 1 thread at a time?
Comment: It's possible I'm using the wrong terminology. If your computer has two cores then it should be able to run at least two threads in parallel. For another example, on my Windows 10 machine I have four cores but eight logical processors, which I believe means I can run eight threads in parallel.
Comment: No, 2 cores means that 2 threads can execute in parallel. When they need to do do something what doesn't need the CPU (typically IO), then having more of them is better. Typically, 2 * numberOfCores threads are used. `+++` Concerning hyperthreading, Slaw is right, the virtual cores (logical processors) count, so they really can run 8 threads in parallel. There are cases when not using all virtual cores is better, but they're rare.
Answer: To elaborate on Slaw's comment, when you run a process in parallel, there is a limited amount that the processor can actually do in parallel. When using a number of threads less than or equal to the number the computer has, the processor can (if not given other tasks) theoretically run the code at the same time. However, above this, and the processor has to start switching back and forth between threads to make it appear as if the program is running in parallel (when in reality, it is running sequentially). This switching between processes takes time (and slows down the program).

For more on this read about:
  schedulers and dispatchers


Issues with json_encode array

Question: I am having issues with my JSON_encode and jQuery, I am getting it to post the full array with the following code, but I can't get it to echo just the one array I need.
$.get("/indexget.php", { page: "goals" },function(data) {
$('#bodyContentStuff').text(data);

Full jQuery code
$("#navLinkGoals").click(function () {
    $("#bodyTitleBar").text("Goals");
    $.get("/indexget.php", { page: "goals" },function(data) {
        $('#bodyContentStuff').text(data);
    }
);

Full PHP code
if($_REQUEST['page'] = 'goals'){
    $result = mysql_query("SELECT * FROM content WHERE page='indexGoals'")
    or die(mysql_error());
    $row = mysql_fetch_array( $result );
    $message = $row['message'];
}
echo json_encode(array("content"=>"$message"));

I am sort of a noob with programming, but the site is http://www.gronge.com if you'd like to see what it is doing, just click the goals link.
Edit: Oh, I have also tried
$('#bodyContentStuff').text(data['content']);

But it didn't work.
Answer: have you tried putting ", 'json'" like so:
$.get("/indexget.php", { page: "goals" },function(data) {
    $('#bodyContentStuff').text(data.content);
}, 'json')

without that jquery makes an intelligent guess as to what the format is...
and as mentioned it should be data.content
and as mentioned use console.log(data) to see what data really is (maybe a string while it should be a json object?)
Comment: And the guess is based on what the PHP sends as the `Content-type` header. So the other option is to add `header("Content-type: application/json");` to the PHP script.
Answer: If that was a verbatim paste there is a missing closing parenthesis on the call to $.get
$("#navLinkGoals").click(function () {
    $("#bodyTitleBar").text("Goals");
    $.get(
        "/indexget.php",
        {
            page: "goals"
        },
        function(data) {
            $('#bodyContentStuff').text(data);
        }
    ); // <== Right here
);

(Code reformatted to highlight difference)
Just noticed a potential issue with the PHP:
if($_REQUEST['page'] = 'goals'){ //<== are you assigning or comparing?
    $result = mysql_query("SELECT * FROM content WHERE page='indexGoals'")
    or die(mysql_error());
    $row = mysql_fetch_array( $result );
    $message = $row['message'];
}
echo json_encode(array("content"=>"$message"));

Comment: I missed the last line on accident.
Answer: instead of get use $.post
 $("#navLinkGoals").click(function () {
   $("#bodyTitleBar").text("Goals");
    $.post("/indexget.php", { page: "goals" },function(data) {
    $('#bodyContentStuff').text(data);
}
);

Comment: That actually didn't change any of the actions at all. :) Still have the issue with it posting the full array ({"content":"It works!"}).
Comment: Just dump your `$row` variable, to ensure you're accessing the data correctly
Answer: Have you logged the data variable? What does it log? Also: mysql_* is deprecated, steer clear and start using PDO. But I think you meant to assign $row[0]['message'] to the $message variable. If memory serves me well, mysql_* always returns either an array of assoc arrays, or an array of arrays.
While we're on the subject: JavaScript doesn't have assoc arrays, only objects, so rather then accessing the data like data['content'], use data.content. The bracket notation is there for convenience, so you can use the value of a variable as property name (without eval), which is EVIL, of course.
Comment: Using data.content brings back nothing. Using (data) brings back {"content":"It works!"}.
Comment: Your memory does not serve you well. `mysql_fetch_array()` returns a one-dimensional array. What's confusing you is that this array has BOTH numeric and associative keys (unless you use the optional second argument to specify MYSQL_ASSOC or MYSQL_NUM to select just one of them).
Comment: @Alcapwn: in which case try: `data = JSON.parse(date);` before `.text(data.content);` and you're all set (it's still a string, and needs to be parsed before you can access it as an object
Comment: It was multiple issues but I now have it working! data = JSON.parse(data); worked on removing the "s. And echo json_encode($message); worked on removing the other stuff, thank you so much!
Comment: @Barmar, you're right, should've read the man pages before making assumptions. In my defence: `mysql_*` _is_ deprecated, I haven't used it in years, since php5.1 actually
Comment: @Alcapwn: since you are using jQuery, best replace that `JSON.parse()` call with `$.parseJSON(data);`. Older IE's (IE<9) don't have native `JSON` support, so you either have to include json2.js for them (json.org), but jQ fixes this X-browser issue... just so you know: still ~+10% IE8 users on the planet, and no known cure for stupidity...
Comment: Also you probably don't need to jsonparse at all if you tell your get function you expect a json object by putting 'json' as the format (as explained below)
Answer: Also on your php:
$row = mysql_fetch_assoc($result);

And not mysql_fetch_array, if you want to use the $row['message'] notation.
Comment: No true. By default `mysql_fetch_array()` returns an array with both indexed and associative keys.
Comment: True I just read. But for a strange reason when I use it on my server php it returns nothing, unless noted MYSQL_BOTH, or MYSQL_ASSOC on mysql_fetch_array :/

Issues with json_encode array


Map subdomain to local IP through public IP

Question: I want to map subdomain to local IPs on my machine to achieve a IP for each of my virtual machines.
I know I can setup a DNS on my own machine but that will only resolve the domain on my own machine.
subdomain.domain.com -> Public IP -> Internal IP 1
subdomain2.domain.com -> Public IP -> Internal IP 2
subdomain2.domain.com -> Public IP -> Internal IP 3

is there anything that might achieve the same goal?
Note: I don't want only port 80 I want something like a NAT or Reverse proxy for all TCP payloads.
Thank you for reading.
Answer: You can't.
The "trick" that is normally used to simulate what you ask for (with a reverse proxy) works (only) with HTTP(S) because the protocol includes the requested DNS host name in each request. That is what allows a HTTP reverse proxy running on the primary IP-address to identify that a request is for a specific site and forward it to correct back-end server.
Most other protocols do not include the DNS hostname the client used to connect to a server. The client locally resolves whatever DNS hostname is used to an IP-address and attempts to make a connection to that IP-address. The original hostname information is "lost" and the only information carried in the (initial) request are the resolved IP-address and port number.
For every protocol that isn't natively hostname aware there won't be any way to correctly map the  request to a specific back-end server.
Also see: How do I make protocol foo hostname-aware?
Do the SSH or FTP protocols tell the server to which domain I am trying to connect?

The solution is to use IPv6 on all your servers and map each of your DNS hostnames to the IPv6 address of the correct back-end server.
Comment: You can make proxying "work" for none HTTP protocols if you use TLS and SNI, but it gets complicated quickly.
Comment: Indeed. Although AFAIK most if not all commonly used SSL/TLS libraries support SNI and have included that support for many years, that doesn't automatically translate into support for applications linked to those libraries. Each client needs to make code changes to leverage SNI and those don't make sense when the server side code  doesn't provide SNI support (yet) either. And  the urgency to adapt SNI seems less for many other applications than it was for web servers and browsers and even for those it took years.


How to properly override a box-shadow bootstrap mixin?

Question: This is the code:

And this is the LESS style:
ul li { .box-shadow(0 1px 3px rgba(0,0,0,.25)); }

I want to override/cancel the mixin on the sub-list, so I tried this:
ul ul li { .box-shadow(none); }

...but it didn't work. The only way I got it to work was by explicitly overriding each line on the mixin:
ul ul li {
          -webkit-box-shadow: none;
             -moz-box-shadow: none;
                  box-shadow: none;
         }

So wha'ts wrong with ul ul li { .box-shadow(none); }?
Answer: Too bad I didn't check the bad output when it broke the whole compilation, but
ul ul li { .box-shadow(none); }
...is working just fine. :P
Answer: If you use twitter bootstrap with SCSS/SASS, I would use the builtin mixins, which handels browser specific flags:
ul ul li { @include box-shadow(none); }


Is there a way to check for the good amount of replicates for let's say T test or just mere One-Way anova (a priori)?

Question: I have already asked this in Reddit but I really cannot find the answer
I know you can check for amount of sample sizes in G power but not really for experiments.
I can't be using a minimum of 100 replicates per group if I am testing efficacy of three fertilizers with medium effect size lol.
Also if replicates is different to sample size, how come we can use the same tests (let's say t test) to experimental units and sampling units if they don't follow the same concept? I know in essence they are different but statistically speaking?
I can use T-test to find difference between general weighted average of school 1 vs. school 2. I can also use t-test to find the difference between dry weight of lettuce after addition of fertilizer 1 and fertilizer 2. The first one is mere data collection while the other is experimentation. Yet I know I need large sample sizes in the first one and not that much replicates ( I reckon 5 is kinda acceptable don't you think? ) for the second one. Why is this so?
My understanding when it comes to computation(not concept) is that replicates per group/treatment = sample size per group. Is this wrong? Whenever I Google "replicates for t test" they always puts me to sample size search results. Even Google doesn't know the difference apparently.
Answer: Your question asks about several different issues involving the power of various tests. I will try
to give some useful answers. (You might also want to look at other links on this site under 'Related' in the margin.)
Consider a two tailed, balanced, pooled two-sample t test (same sample size $n$ for each group and samples from normal populations with the same variance $\sigma^2).$ You will test $H_0: \mu_1=\mu_2$ against $H_a:\mu_1 \ne \mu_2.$
Then the power (probability of rejection when $\mu_1 \ne \mu_2$) depends on the significance level $\alpha$ (often chosen
to be 5%), the sample size $n,$ the common variance $\sigma^2,$ and the size of the specific difference $\Delta = |\mu_1 - \mu_1|$ to be detected.
Many mathematical statistics books and advanced books
on design of experiments have an exact formula
relating these quantities, which involves a
non-central t distribution.
If sample sizes differ, population variances differ, or a one-sided test is to be done, then
power computations are somewhat more intricate.
A Welch t test (not assuming equal variances)
has slightly lower power than a pooled t test
in case population variances are equal.
The following simulation in R finds the approximate power for the case $\alpha = 0.05, \sigma=5, \Delta = 4, n = 30.$ The method is to do 100,000 t tests
to these specifications and note the proportion of tests that reject $H_0.$ The approximate power is $86\%.$
<code>set.seed(2022)
pv = replicate(10^5,
      t.test(rnorm(30,50,5),rnorm(30,54,5),
      var.eq=T)$p.val)
mean(pv <= 0.05)
[1] 0.86067
</code>
Notes: (1) It turns out that the power for
a specified sample size is the same for any specific value of $\Delta/\sigma,$ if all other parameters remain the same.
(2) An unbalance test, with $n_1 \ne n_2,$ is somewhat less efficient. That is, other parameters being equal, a test with $n_1 = n_2 = 30$ has noticeably
higher power than a test with $n_1 = 15, n_2 = 45,$
which also uses $60$ subjects overall.
(3) Considerations for a one-factor ANOVA are similar. Formally, the power depends on $\theta = \frac 1 g
\sum_{i=1}^g (\mu_i -\bar\mu)^2,$ where there are
$g$ levels of the factor and $\bar\mu = \frac 1 g \sum_i \mu_i.$ But some 'power and sample size' procedures look at $\Delta = |\mu_i = \mu_{i^\prime}|,$ the largest difference among the $\mu_i$ that one wants to detect. If ad hoc comparisons of pairs of levels is envisioned, it is important to set $\Delta$ with that in mind.
Comment: Sorry I am not really familar with math thingies since my stat training is just JMP/R/SPSS go brr and just read the p-value. Now that the idea of power and sample size come in mind, this all looks very complicated.
Comment: In testing a hypothesis, there are two possible wrong decisions: (a) Reject $H_0$ when it's true and (b) fail to reject $H_0$ when it's false. Significance level, often set at 0.05 = 5% is probability of (a). Power often sought to be 80%, 90%, 95% (according to needs and budget) is probability of not making mistake (b) when $H_0$ false is interpreted to mean false in a particular way specified as a particular distance of the parameter from the value in $H_0.$ // Low sig level, Hight power, and small sample size are all "good". Any one experiment has to be designed to balance the three 'good's.


Dúvida POO Javascript

Question: Estou praticando POO em JavaScript e, procurando alguns exemplos na internet, me deparei com a prática abaixo:

function Product(name, price) {
    this.name = name;
    this.price = price;
    //this.discount = 0; // <- remove this line and refactor with the code below
    var _discount; // private member
    Object.defineProperty(this, "discount", {
        get: function () { return _discount; },
        set: function (value) { _discount = value; if (_discount > 80) _discount = 80; }
    });
}

//  the client code
var sneakers = new Product("Sneakers", 20);
sneakers.discount = 50; // 50, setter is called
sneakers.discount += 20; // 70, setter is called
sneakers.discount += 20; // 80, not 90!
console.log(sneakers.discount); // getter is called

Eu refiz o exemplo sem olhar pra ele e funcionou numa boa.
No entanto, quando tentei uma abordagem diferente para o mesmo exemplo, eu já me perdi um pouco.
O que eu tentei fazer foi ao invés de definir uma nova propriedade usando o método 'defineProperty' dentro da função construtora, definir externamente, como se eu fosse implementar essa propriedade um tempo depois.
Só que o log está dando 'undefined'.
Alguém poderia me ajudar? Estou praticando POO há pouco tempo.
Segue a diferente abordagem que tentei:

function Product(name, price) {
    this.name = name;
    this.price = price;
    var _discount;
}

Object.defineProperty(Product, 'discount', {
    get: function () {
        return this._discount;
    },
    set: function (value) {
        _discount = value;
        if (_discount > 80) {
            _discount = 80;
        }
    }
})

var television = new Product('samsung_a3045', 1000);

television.discount += 50;
console.log(television.discount)
Answer: Você precisa ter em mente que em JavaScript algumas coisas são diferentes da maioria das linguagens que trabalham com OO. As propriedades são membros definidos diretamente nos objetos e não nas classes como seria em outras linguagens.
Por isso, o primeiro parâmetro de Object.defineProperty é o objeto onde a propriedade será definida, não uma definição de classe. Na sua tentativa, ao invés de passar o objeto você passa a função que define a classe.
No exemplo abaixo, o objeto a contém a propriedade discount, já o objeto b não.

function Product(name) {
    this.name = name
}

var a = new Product('Teste 1')
var b = new Product('Teste 1')

Object.defineProperty(a, 'discount', {
    get: function () {
        return 'TESTE'
    }
})

console.log(a.discount)
console.log(b.discount)
Comment: E se eu quiser 'exportar' essa nova propriedade para outro objeto que possui a mesma base construtora? Ou seja, outro objeto criado com a função 'Product'?
Comment: @LucasStellet Você faz como no seu primeiro exemplo. Lá o defineProperty será executado para todos os objetos que forem criados...
Comment: Obrigado pela ajuda! :)

Dúvida POO Javascript