scope – Code to Show Groovy is a Statically Scoped Language

I want to double check that I understand this code correctly as it relates to Groovy and static scoping.

Because int b = 5 is declared outside of the int foo( ) method, ) will return 10.

Since int bar( ) returns int foo( ), ) will return 10.

If on the other hand, Groovy were dynamically scoped, ) would output 7 because b is not defined in foo( ).

As a result, the compiler would look to the value of b as it is defined in bar( ) and return 7.

The part I’m not certain of is whether ) would also return 7, or would it still return 10 under dynamic scoping rules?

I think I understand this, I just want to make sure my explanation is correct.

Any input and/or constructive criticism is welcomed and appreciated.


class ScopeExample {
    int b = 5
    int foo() {
        int a = b + 5
    int bar() {
        int b = 2
    static void main(String ... args) {
        def x = new ScopeExample()
        println //returns 10
        println //returns 10

mysql – Why my code only return 1 row? Leetcode#626

You are using an agregate function which causes the result to collapse to single row.
Possible solution:

(CASE WHEN mod(,2)=0 THEN
WHEN mod(,2)=1 AND != maxid.maxid THEN
END) AS id,
FROM seat s
join (select max( as maxId from seat) as maxId on 1=1

You are using it in the SELECT, not CONDITIONAL (WHERE).
Now, the question you ask is a good one and i would have to refresh my knowledge of inner workings of SQL.

I think its because the moment it hits MAX, its collapses the result set, as it doesnt “see” a need to return all rows.

Simply said, the query processor doesnt care if its a condition in case statement or value to be returned. It’s there and thats that.

Aggregation function without group by is a mysql thing, and not SQL standard, so the behaviour is specific to MySQL.

applescript – My Apple Script Editor code doesn’t work gives “Syntax Error Expected end of line but found identifier.”

The problem is Evernote is not AppleScript scriptable.

When trying to add Evernote to the Library in Script Editor, in order to review its AppleScript dictionary, it errs with: Add Item Unable to add the item because it is not scriptable.

Additionally, when running the following command in Script Editor:

tell application "System Events" to ¬
    get has scripting terminology of application process "Evernote"

Its result is: false

data structures – Reverse An Array whats wrong with this type of code?

data structures – Reverse An Array whats wrong with this type of code? – Computer Science Stack Exchange

forms – PHP Code Not Generating Results

I wanted to create a calculator on my WordPress website.

But, my code is not generating results on the page after the form Submission.

Please help,
Thank you


<form method="post" >
<label for="fname">Value</label>
<input id="value" name="inp1" type="number" value="" />
<label for="lname">Result</label>
<input type="submit" name="button1" value="Calculate" />


            function fact($x)
                                for ($i=$x; $i>0; $i--)
                                echo "Factorial of the number is $fact";

            {echo "Enter the number";}

mysql – Could anyone explain this code to me?Leetcode #180

select distinct Num as ConsecutiveNums
from (
  select Num, 
      when @prev = Num then @count := @count + 1
      when (@prev := Num) is not null then @count := 1
    end as CNT
  from Logs, (select @prev := null,@count := null) as t
) as temp
where temp.CNT >= 3

I found this in

It is really difficult to understand, especially this sentence

(select @prev := null,@count := null) as t

Why can variable declaration be put there?

javascript – How to divide the following code correctly into functions? Calculator /JS

javascript – How to divide the following code correctly into functions? Calculator /JS – Code Review Stack Exchange

random – This code is a non-static C# class for rolling a number of dice

Fellow human beings, today I present to you my dice rolling script! Behold, in my amateurish attempt at some raw C# code. Perhaps this will remain here regardless of the dozens of other dice rolling scripts out there.

Contains a ‘for’ loop, a ‘switch’, and a method that returns a value.

I have indeed read through other, similar iterations of this class, and I have found them to be lacking in what I might learn from, usually due to over-complication for my tiny brain, or because it invoked the use of libraries I have yet to hear of.

I did my best to make it easy to read for whichever intrigued person stumbles upon this. I deeply respect and appreciate any who may take the time to offer any criticism on my code. What did I do right? What did I do wrong? I don’t have anyone or anywhere else to share it with.

using System;

namespace C_
    class RollDice : Program


        int numOfDice;
        int numOfSides;

        int maxDice = 100;
        int minDice = 1;
        int maxSides = 100;
        int minSides = 1;
        int totalRolled;

        //Start method for number of Dice to throw - take the player input in InputMethod() which returns an int. If returning 0, then restart. Clamp the value between min/max. Continue to next function.

        public void GetDice()
            Console.WriteLine("Welcome to Roll Dice!");
            Console.WriteLine("How many dice do you want to throw?");
            numOfDice = InputMethod();
            if(numOfDice == 0)
            if (numOfDice > maxDice || numOfDice < minDice)
                numOfDice = Math.Clamp(numOfDice, minDice, maxDice);
                Console.WriteLine($"Number of Dice set to {numOfDice}");


        // Get the sides of each dice by using a similar process. Roll() for each dice, then sum the totals in RollTotal().

        public void GetSides()
            Console.WriteLine("How many sides does each dice have?");
            numOfSides = InputMethod();
            if(numOfSides == 0)
            if (numOfSides > maxSides || numOfSides < minSides)
                numOfSides = Math.Clamp(numOfSides, minSides, maxSides);
                Console.WriteLine($"Number of Sides set to {numOfSides}");

            for (int x = 1; x <= numOfDice; x++)


        // Create a new Random() instance for the number of sides and add it to the totalRolled variable.

         public void Roll()
            Random r = new Random();
            var result = r.Next(1, numOfSides + 1);
            Console.WriteLine($"You rolled {result}");
            totalRolled += result;
        // Output the total and prompt to roll again or quit. Reset the total..

        public void RollTotal()
            Console.WriteLine($"Total sum rolled is {totalRolled}");
            Console.WriteLine(" ");
            Console.WriteLine("Enter 1 to re-roll or 2 to quit.");
            var answer = InputMethod();

            switch (answer)
                case 0:
                case 1:
                totalRolled = 0;
                case 2:
                totalRolled = 0;

        //Convert the input to an integer if valid and return the value. Else return 0.

        public int InputMethod()
            var input = Console.ReadLine();
            if(!Int32.TryParse(input, out int convertedStringToInt))

                Console.WriteLine("You need to enter a valid number!");
                return 0;
                return Convert.ToInt32(input);



entities – Enable Layout Builder via code

I figured it out. You can enable Layout Builder by running the following code in a custom module:

$entity_type = 'node';
$content_type = 'article';
$view_type = 'default';


Hopefully this helps someone else. Having to do it via the UI is painful if you have a lot of content types. I’m actually surprised this isn’t a Drush command yet. Oh well.


DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive New Proxy Lists Every Day Proxies123