text:
Q: How to overload json deserialization of float? I try to get how can I deserialize json like
 '{…, "money":{"amount":1.45674,"currency":"ETH"}, …}'

to my custom class or struct or whatever, using my own function. The goal is to convert the float to integer without rounding errors, and  I want to use my own money classes, depending of currency name. So there must not interfere BigDecimal or other numeric in the middle of conversion.
Or maybe the 1.45674 can be inside quotes, it's not a problem in that case.

A: If you're using JSON from the Ruby standard library, the following should make Ruby use your class:

*

*Add a json_class key to the JSON object with a value of your class name (for example, '{"json_class":"Money::Ethereum","amount":1.45674}')

*Add a class method to your class called json_create that creates an object based on the JSON data (for example, new(json_data['amount']))

*When you do the parsing, add a "create_additions" option: JSON.parse(json_string, create_additions: true)
You can see an example of this in the JSON extension for Range, which has a json_create class method, as well as as_json and to_json instance methods that output the value that can be fed back into json_create.
require 'json/add/range'
output = (0..10).to_json
JSON.parse(output, create_additions: true) # Returns the range 0..10


text:
Q: using SVM for binary classification I am using sVM-light for binary classification.and I am using SVM in the learning mode.
I have my train.dat file ready.but when i run this command ,instead of creating file model ,it writes somethings in terminal:
my command:
./svm_learn   example1/train.dat example1/model
output:
Scanning examples...done
Reading examples into memory...Feature numbers must be larger or equal to 1!!!
: Success
LINE:   -1   0:1.0  6:1.0   16:1.0  18:1.0  28:1.0  29:1.0  31:1.0  48:1.0  58:1.0  73:1.0  82:1.0  93:1.0  95:1.0  106:1.0 108:1.0 118:1.0 121:1.0 122:1.0151:1.0  164:1.0 167:1.0 169:1.0 170:1.0 179:1.0 190:1.0 193:1.0 220:1.0 237:1.0250:1.0  252:1.0 267:1.0 268:1.0 269:1.0 278:1.0 283:1.0 291:1.0 300:1.0 305:1.0320:1.0  332:1.0 336:1.0 342:1.0 345:1.0 348:1.0 349:1.0 350:1.0 368:1.0 370:1.0384:1.0  390:1.0 394:1.0 395:1.0 396:1.0 397:1.0 400:1.0 401:1.0 408:1.0 416:1.0427:1.0  433:1.0 435:1.0 438:1.0 441:1.0 446:1.0 456:1.0 471:1.0 485:1.0 510:1.0523:1.0  525:1.0 526:1.0 532:1.0 540:1.0 553:1.0 567:1.0 568:1.0 581:1.0 583:1.0604:1.0  611:1.0 615:1.0 616:1.0 618:1.0 623:1.0 624:1.0 626:1.0 651:1.0 659:1.0677:1.0  678:1.0 683:1.0 690:1.0 694:1.0 699:1.0 713:1.0 714:1.0 720:1.0 722:1.0731:1.0  738:1.0 755:1.0 761:1.0 763:1.0 768:1.0 776:1.0 782:1.0 792:1.0 817:1.0823:1.0  827:1.0 833:1.0 834:1.0 838:1.0 842:1.0 848:1.0 851:1.0 863:1.0 867:1.0890:1.0  900:1.0 903:1.0 923:1.0 935:1.0 942:1.0 946:1.0 947:1.0 949:1.0 956:1.0962:1.0  965:1.0 968:1.0 983:1.0 986:1.0 987:1.0 990:1.0 998:1.0 1007:1.0    1014:1.0    1019:1.0    1022:1.0    1024:1.0    1029:1.0    1030:1.01032:1.0    1047:1.0    1054:1.0    1063:1.0    1069:1.0    1076:1.0    1085:1.0    1093:1.0    1098:1.0    1108:1.0    1109:1.01116:1.0    1120:1.0    1133:1.0    1134:1.0    1135:1.0    1138:1.0    1139:1.0    1144:1.0    1146:1.0    1148:1.0    1149:1.01161:1.0    1165:1.0    1169:1.0    1170:1.0    1177:1.0    1187:1.0    1194:1.0    1212:1.0    1214:1.0    1239:1.0    1243:1.01251:1.0    1257:1.0    1274:1.0    1278:1.0    1292:1.0    1297:1.0    1304:1.0    1319:1.0    1324:1.0    1325:1.0    1353:1.01357:1.0    1366:1.0    1374:1.0    1379:1.0    1392:1.0    1394:1.0    1407:1.0    1412:1.0    1414:1.0    1419:1.0    1433:1.01435:1.0    1437:1.0    1453:1.0    1463:1.0    1464:1.0    1469:1.0    1477:1.0    1481:1.0    1487:1.0    1506:1.0    1514:1.01519:1.0    1526:1.0    1536:1.0    1549:1.0    1551:1.0    1553:1.0    1561:1.0    1569:1.0    1578:1.0    1603:1.0    1610:1.01615:1.0    1617:1.0    1625:1.0    1638:1.0    1646:1.0    1663:1.0    1666:1.0    1672:1.0    1681:1.0    1690:1.0    1697:1.01699:1.0    1706:1.0    1708:1.0    1717:1.0    1719:1.0    1732:1.0    1737:1.0    1756:1.0    1766:1.0    1771:1.0    1789:1.01804:1.0    1805:1.0    1808:1.0    1814:1.0    1815:1.0    1820:1.0    1824:1.0    1832:1.0    1841:1.0    1844:1.0    1852:1.01861:1.0    1875:1.0    1899:1.0    1902:1.0    1904:1.0    1905:1.0    1917:1.0    1918:1.0    1919:1.0    1921:1.0    1926:1.01934:1.0    1937:1.0    1942:1.0    1956:1.0    1965:1.0    1966:1.0    1970:1.0    1971:1.0    1980:1.0    1995:1.0    2000:1.02009:1.0    2010:1.0    2012:1.0    2015:1.0    2018:1.0    2022:1.0    2047:1.0    2076:1.0    2082:1.0    2095:1.0    2108:1.02114:1.0    2123:1.0    2130:1.0    2133:1.0    2141:1.0    2142:1.0    2143:1.0    2148:1.0    2157:1.0    2160:1.0    2162:1.02170:1.0    2195:1.0    2199:1.0    2201:1.0    2202:1.0    2205:1.0    2211:1.0    2218:1.0
I dont know what to do.
p.s.when i make my train.dat very shorter ,everything works fine!!!
Thank you

A: From what I could interpret from the log, your training set has an issue.
The first few characters of the training row that has issue are
-1 0:1.0 6:1.0
The issue is not with the size but with feature indexing. You are starting your feature index at 0 (0:1) whereas svmlight requires that all feature index be equal or greater than 1.
Change the indexing to start at 1 and it should work fine.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to transfer data sequence between forms in Qt Assume I have 2 forms in a Qt application. I need to transfer data between 2 forms many times so I used the loop to do this. I just wanna get result from Form 2 before Form 1 is continue to loop. This is my desired intention:

When I used the loop normally, the loop began at i = 1 and sent data to Form 2. Before Form 2 returned result to Form 1, Form 1 was continue to send data with i = 2.
Could you give me some solutions?
Thanks!

A: You can use signal slot concept to achieve this,
if form1 has object of form2 (Composition)
you can do
 connect(this,SIGNAL(sendData(DataClass),ptr_form2,SLOT(receiveData(DataClass));
 connect(ptr_form2,SIGNAL(acknowledge()),this,SLOT(resendData()));

ptr_form2 is reference of form2
DataClass is you data this could be anytype.replace it with your class object or any data type
 //sendData is signal, in form1
 signals: void sendData(DataClass);

 //resendData is slot in form1
 private slots: void resendData()
 {
     emit sendData(objData); // objData is your data
 }

 //acknowledge is signal in form2
 signals: void acknowledge();

 //receiveData is public slot in form2
 public slots: void receiveData(DataClass data)
 {
     /*
           Do you activity here
      */
     emit acknowledge(); // Emit Acknowledge
  }

if you have reference of both forms in any third form or class then you can do
      let ptr_form1 is reference of form1
      let ptr_form2 is reference of form2
 connect(ptr_form1 ,SIGNAL(sendData(DataClass),ptr_form2,SLOT(receiveData(DataClass));
 connect(ptr_form2,SIGNAL(acknowledge()),ptr_form1 ,SLOT(resendData()));


text:
Q: MySql query to MS Access So I'm trying (actually made it work in MySql) to grab 3 columns from the source table, remove its duplicates just based on 2 of those 3 columns (that's why I need the partition and row_number), and once duplicates are dropped, I'm checking into the target table if those same 2 values are not already existing.
But now I have to get through MS Access and found out partition by and row_number() are not supported.
Any approach will be appreciated
Here's the query:
INSERT INTO TARGET_TABLE (COL1, CV1, CV2)
SELECT st.DontCareValue, st.CV1, st.CV2
FROM(
select DontCareValue, CV1, CV2,
row_number() over (partition by CV1, CV2 order by DontCareValue) as rn
From sourceTable
where length(CV1) >= 2) st
where st.rn = 1
and not exists(select 1 from TARGET_TABLE tt
where tt.CV1= st.CV1
and tt.CV2 = st.CV2)

A: This is what Shadow is saying:
Keep in mind prior to the new useful analytic features, the same problems existed in the past. You just need to find the appropriate design pattern from then.  You're getting RN=1 which would be the smallest value of DontCare for each CV1, CV2 group. so Just use a min in your su
INSERT INTO TARGET_TABLE (COL1, CV1, CV2)

SELECT st.MinDontCareValue, st.CV1, st.CV2
FROM (SELECT Min(DontCareValue) MinDontCareValue, CV1, CV2
      FROM sourceTable
      WHERE length(CV1) >= 2
      GROUP BY CV1, CV2) st

WHERE not exists (SELECT 1
                  FROM TARGET_TABLE tt
                  WHERE tt.CV1= st.CV1
                    AND tt.CV2 = st.CV2)


text:
Q: Describe locus of points $z$ that satisfy $|z+2|+|z-2|=5$ For this problem, as the question says, I am supposed to describe the locus of points $z$ that satisfy the equation:
$$|z+2|+|z-2|=5$$
Usually these problems aren't too difficult with a bit of algebra, but this one is just confusing me too much (it's getting way too messy).
When I rewrite the equation in terms of $z$'s $x$ and $y$ components, I get:
$$\sqrt{(x+2)^2 + y^2} + \sqrt{(x-2)^2 + y^2} = 5$$
From here, if I choose to square the entire equation, I will get a nasty term in a radical that's too much for me to work out. If I multiply the entire equation by the conjugate (not complex conjugate) of the left-hand side, I arrive at nearly the exact same problem on the right side.
Please give me some guidance. Is the algebra avoidable?

A: Let's try some messy algebra. You arrived at:
$$
\sqrt{(x+2)^{2}+y^{2}} = 5-\sqrt{(x-2)^{2}+y^{2}}
$$
Squaring both sides, we get:
$$
(x+2)^{2}+y^{2}=25-10\sqrt{(x-2)^{2}+y^{2}} + (x-2)^{2}+y^{2} \to
8x=25-10\sqrt{(x-2)^{2}+y^{2}}
$$
We move the $25$ to the LHS and square it again:
$$
(8x-25)^{2}=100((x-2)^{2}+y^{2}) \to \\
64x^{2}-400x+625=100x^{2}-400x+400+100y^{2} \to \\
100y^{2}=-36x^{2}+225
$$
Then, we have as possible for $y$:
$$
y=\pm\frac{\sqrt{-36x^{2}+225}}{10}
$$
We note that the expression inside the square root is $\geq 0$ only for $\frac{-5}{2}\leq x\leq \frac{5}{2}$. Therefore, the points that satisfy the condition are given by
$$
\{(x,y)\in \mathbb{R^{2}} | \frac{-5}{2}\leq x\leq \frac{5}{2}, y=\pm\frac{\sqrt{-36x^{2}+225}}{10}
\}
$$
The positive and negative signs on $y$ give you the upper and lower branches of the ellipse. Here is a link for a plot of the upper branch. Another way (and nicer) to see this is taking the equation involving the squares of $x$ and $y$ and putting it on this form:
$$
36x^2 + 100y^2 = 225
$$
You can then factor this into
$$
\frac{x^{2}}{a^{2}} + \frac{y^{2}}{b^{2}} = 1,
$$
where $a=5/2$ and $b=3/2$, which gives you geometric information about the ellipse much faster.

A:
$$|z+2|+|z-2|=5$$
This is an ellipse in the complex plane.
If you want to see it with in more details, choose $C=0,$ $$F_1=-2, F_2=2$$ and $$a=\frac{5}{2}.$$

A: Thinking of it conceptually, it says that the distance from z to -2 plus the distance from 2 is 5, a constant. This makes an ellipse. An ellipse is formed by taking two fixed points (foci) and taking the set whose sum to these two points is a constant.
So it's an ellipse with foci at 2, -2.
There are a lot of shapes you can make by making subtle changes to this equation.
If you try |z+2|-|z-2|=5, you'll get a hyperbola with the same foci.
You can do |z+2||z-2|=b for non-negative b would give you Ovals of Cassini.
|z+2|=b for non-negative b is a circle centered at -2 of radius b.
Edit: For Ovals of Cassini, it is the product, not the ratio of the distances to two fixed points (I have made the change in the post).
Also, I specified what b was and added a detail for the circle |z+2|=b example.


text: Q: How to put an image in the header in a HTML5 Boilerplate tempate I downloaded this HTML5 Boilerplate simple responsive template: http://www.initializr.com/try : how to put an image (image.jpg) in the header with background-image? I know, it's very simple, but I'm not able. I put background-image: url("image.jpg"); within the .header-container class. But nothing. I tried to remove quotes: nothing. I tried to use background (not background-image): nothing


text:
Q: How serve files in folder with case insensitive on linux with nginx I'm having a little problem. I need serve files with case insensitive for a folder, i use nginx:
Original:
https://example.com/media/catalog/product/b/t/bt2501_brandy.jpg
https://example.com/media/catalog/product/p/r/PR3027GUN_1.JPG
This picture above would works with this way (case insensitive):
https://example.com/media/catalog/product/b/t/BT2501_BRANDY.jpg or
https://example.com/media/catalog/product/b/t/bt2501_Brandy.jpg or
https://example.com/media/catalog/product/b/t/bt2501_Brandy.JPG
https://example.com/media/catalog/product/p/r/pr3027gun_1.JPG
Some idea for me?
I know linux is case sensitive. But i can deal with this with nginx?
Thanks

A: location ~* ^/media/catalog/product/ {
    # The tilde and asterisks ensure that this location will
    # be matched case insensitive. nginx does not support
    # setting absolutely everything to be case insensitive.
    # The reason is easy, it's costly in terms of performance.
}


text:
Q: t-sql process large set of SQL rows without cursor I need to loop through 16 million rows of SQL data. I have been told not to use a cursor for this because of performance issues. I have started with a WHILE loop but I can't figure out how to get the next row in the table using a WHILE loop. See my progress below. How do I get the AccountNames column for each row?
DECLARE @rowId INT = 1;
DECLARE @RowCnt BIGINT = 0;
DECLARE @source varchar(8000);
DECLARE @current_source varchar(8000);
DECLARE @search varchar(8000) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
DECLARE @replacement varchar(8000) = '22233344455566677778889999';
DECLARE @Converted varchar(8000) ;

SELECT @RowCnt = COUNT(0) FROM dbo.AccountNames;
select @source = AccountNumber FROM dbo.AccountNames where AccountNumber > ' ' order by Accountnumber;

WHILE @rowId <= 2
BEGIN

declare @i int, @iMax int;
set @iMax = len(@search);
set @i = 1;
while @i <= @iMax
begin
    set @Converted = replace(@source, substring(@search, @i, 1), substring(@replacement, @i, 1));
    set @i = @i + 1;
end

select @source = AccountNumber FROM dbo.AccountNames where AccountNumber > @current_source order by Accountnumber ;
print @source;
set @current_source = @source;
Set @rowId = @rowId + 1;
END

-edit
Thanks for the super fast comments. I will provide more detail based on the requests in the comments section.
I need to take the AccountNumber field from each record in AccountNames, convert it to the keypad value shown in my code, then insert that value into a different table that holds the AccountNumber and its Keypad equivalent. If cursors are OK for a table this large then I would appreciate someone showing me the proper syntax for that.
-edit 2
I can't use translate because I am using SQL Server 2016.

A: You can do this whole thing with one SELECT statement:
DECLARE @search varchar(8000) =      'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
DECLARE @replacement varchar(8000) = '2223334445556667777888999922233344455566677778889999';

SELECT  AccountNumber,
        TRANSLATE(AccountNumber, @search, @replacement) AS TranslatedAcctNum
FROM    dbo.AccountNames
WHERE   Accountnumber > 'DDDDDD'
order by AccountNumber;

Which can also be easily turned into a single INSERT statement.
As an added benefit, it will run 10-1000 times faster.
(Note: Without any test data, I could not test it, so there may be typos, but they should be easily fixable.)

A: While the "Translate" answer is obviously the more elegant solution, if you can't use it because of version compatibility you could replace it with nested REPLACE statements. It should still run much faster than a cursor or a while loop, and the results can be used in set operations like INSERT. I tested this on SQL 2014 and it worked, so 2016 should give you no problems
with cteSampleData as (
    SELECT *
    FROM (VALUES ('CXE-34-A5'), ('52Q-A6-brxt'), ('kqed-pc-12ALE')
         ) as Accts(AccountNumber)
), cteTranslated as (
 SELECT AccountNumber
    , REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(REPLACE(
      REPLACE(REPLACE(AccountNumber,
         'A', '2'), 'B', '2'), 'C', '2'),
         'D', '3'), 'E', '3'), 'F', '3'),
         'G', '4'), 'H', '4'), 'I', '4'),
         'J', '5'), 'K', '5'), 'L', '5'),
         'M', '6'), 'N', '6'), 'O', '6'),
         'P', '7'), 'Q', '7'), 'R', '7'), 'S', '7'),
         'T', '8'), 'U', '8'), 'V', '8'),
         'W', '9'), 'X', '9'), 'Y', '9'), 'Z', '9'
      ) as AcctTrans
 FROM cteSampleData
) --INSERT INTO DestTable (RawAcct, TranslatedAcct)
SELECT AccountNumber, AcctTrans
FROM cteTranslated

EDIT: The output looks like this:

AccountNumber
AcctTrans

CXE-34-A5
293-34-25

52Q-A6-brxt
527-26-2798

kqed-pc-12ALE
5733-72-12253

A: I found a way to do it with a cursor. Instead of printing the account number, I will put an  insert statement into the final version of this code.
DECLARE @rowId INT = 1;
DECLARE @AccountNum varchar(8000);
DECLARE @c cursor;
DECLARE @search varchar(8000) =      'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
DECLARE @replacement varchar(8000) = '2223334445556667777888999922233344455566677778889999';
DECLARE @Converted varchar(8000) ;

SET @c = cursor LOCAL FAST_FORWARD FOR SELECT AccountNumber
FROM dbo.AccountNames
where Accountnumber > 'DDDDDD'
order by AccountNumber;

OPEN @c;
fetch next from @c into @AccountNum;

While @@fetch_status = 0
BEGIN
    print @AccountNum;
    declare @i int, @iMax int;
    set @iMax = len(@search);
    set @i = 1;
    while @i <= @iMax
    begin
        set @AccountNum = replace(@AccountNum, substring(@search, @i, 1), substring(@replacement, @i, 1));
        set @i = @i + 1;
    end

    print @AccountNum; --put insert statement here
    fetch next from @c into @AccountNum;

    set @rowId = @rowId + 1; --remove this test code after code is finished
    if @rowId > 1
    begin
        break
    end

END

close @c;
deallocate @c;


text:
Q: build cannot be found under team project Our coded ui tests take several hours to complete, if I launch run functional tests task from the build definition it looks like it is consuming build minutes and using build pipelines so wrote a small powershell script (and a console application in C#). the plan is to launch either ps1 or console app from the build definition and exit. the ps1 or exe takes a build name as a parameter and launches the vstestconsole with that name as one of the parameters. when I test this locally on azure VM test machine it works fine (updates the results) but when I launch the same through build definition with build name as the parameter I get build cannot be found under team project error:
Log:
[command]C:\Users\automation\Desktop\ps1\cmd\ExecuteVSconsole.exe UI_Automation_NoWait_20170621.9
Error: Build "UI_Automation_NoWait_20170621.9" cannot be found under team project "XXX"
arg list :C:\Uiautomationbinaries\UI.dll /logger:Tfspublisher;Collection=https://xxx.visualstudio.com/;BuildName=UI_Automation_NoWait_20170621.9;TeamProject="xxx"

The build task I am using is : Powershell on target machine.
The build number is unique (name of the def + day+rev)
I have tried some of the solutions I have found online.

A: Since running locally successful, suggest you RDP to the remote machine (the target machine of the task)with your build service account. Then manually run the powershell script to see whether it works.
Also pay attention to the permission of your build service account.
Besides, since you are using azure VM , also follow this tutorial To set up WinRM for Microsoft Azure Virtual Machines for PowerShell on Target Machines task.


text:
Q: making a log in as user in laravel i want to know if there is any way to simulate the login as user and make the session for that user .i want my help-desk to see the site from users vision so they need to log in as user as long as i cant show the user s password to the admin (its not possible as far as i know if its not that would be a good solution too ). i want to place a button with some text for example :
LoginAsThisUser

and when my help desk clicks on the button he logs in as the user is there any way to do that ??

A: It's possible, and it's fairly simple to do. All you need to do is to create a route, something like this:
Route::get('admin/login-as-user/{id}', 'Admin\UserController@loginAsUser')->name('login.as.user');

After that, pass the route to your LoginAsThisUser button with desired user id :
id}}" class="btn btn-default">LoginAsThisUser

And create a function in your controller:
public function loginAsUser($id)
{
     $user = User::findOrFail($id);
     Auth::login($user);
     return redirect('/');
}

Note: this is not tested, let me know if you encounter any errors.

A: use Illuminate\Support\Facades\Auth;

//use user_id
Auth::loginUsingId(1);

// Login and "remember" the given user...
Auth::loginUsingId(1, true);

$user=User::find($userId);

//use Authenticatable user
Auth::login($user);

// Login and "remember" the given user...
Auth::login($user, true);

also use
Auth::guard('notDeafault')->login($user);
if you want switch default guard

A: With the Auth facade, you can use the loginUsingId method
Auth::loginUsingId($user_id);

This method allows you to force login without a password. But it does not allow you to retrieve cookies or cache from your user's browser that may impact their viewing.


text:
Q: Show Log not showing all revisions I have an issue with Subversion not showing all revisions I'd expect to see when I look further down in the directory tree.
Let this be my directory structure:
trunc
  |____ src
         |____Folder1
                 |______File1

For File1 we have revisons 1, 2, and 3.
We're using Tortoise-SVN 1.8.11, current version at this moment, SVN 2.7.6.
In Windows 8.1's file explorer, when I do SVN Show Log off the trunk folder, it shows me all revisions. However, off src it only shows me revisions 1 and 3. (Same when I start in Folder1 or File1).
I did the same in Tortoise's repository browser, same result. Did a fresh checkout, same result.
I also use the AnkhSVN plugin for Visual Studio. This shows me all revisions (1,2,3) wherever I look!
This Tortoise issue is nasty because I prefer Tortoise over Ankh to merge branches. Of course I don't want to miss revisions while merging.
Does anyone know what's going on here and whether this can be fixed in any way?

A: After a lot of head-scratching while I was preparing this question, I concluded that this had to be a machine-specific issue, because on another machine all revisions were shown irrespective of the folder where I did "Show Log".
I found out here that Tortoise caches log messages. Now when I cleared these...

...I finally saw al revisions again.
I figured I'd still post this question, now with the answer, for others running into this deceptive issue.


text:
Q: Use Webpack to bundle client code while using node and express without webpack I have a node/express app. I serve a single html page which then uses sockets.io to the node server to get update the page. I have modules I want to bundle for the client only. I want to use webpack to do this. I do not want to use webpack to bundle my server code.
I'm attempting to run this using "npm start" where "start" is a script defined in package.json (see below).
How can I bundle my client JS without bundling all the node_modules?
Application File Structure:
-client
  -index.js <- main client entry file
  -mapActions.js
  -socketActions.js
-src
  -<serverModules>.js
-index.html
-package.json
-server.js <--main server entry
-webpack.config.js

webpack.config.js
module.exports = {
     entry: './client/index.js',
     output: {
         path: './dist',
         filename: 'app.bundle.js'
     }
 };

client/index.js
var mapActions = require('./mapActions');
var socketActions = require('./socketActions');

/**
 * client entry point
 */
module.exports = function(){
    //this function should initialize the app
    mapActions.initialize();
    socketActions.initialize();
}

index.html
<!DOCTYPE html><html><head></head>
<body >
  <script src="dist/app.bundle.js"></script>
</body>
</html>

package.json
//edited for brevity
"scripts": {
    "start": "npm run dev",
    "dev": "./node_modules/.bin/webpack"
  },
//edited for brevity

The Error:
Hash: 2c5042c2f89359320fa9
Version: webpack 1.13.1
Time: 710ms
        Asset    Size  Chunks             Chunk Names
app.bundle.js  790 kB       0  [emitted]  main
   [0] ./client/index.js 306 bytes {0} [built]
   [1] ./client/mapActions.js 3.6 kB {0} [built]
   [2] ./client/socketActions.js 892 bytes {0} [built]
    + 131 hidden modules

WARNING in ./~/socket.io/~/socket.io-client/socket.io.js
Critical dependencies:
1:475-482 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 @ ./~/socket.io/~/socket.io-client/socket.io.js 1:475-482

WARNING in ./~/socket.io/~/engine.io/~/ws/lib/BufferUtil.js
Module not found: Error: Cannot resolve module 'bufferutil' in D:\Node Practice\batweb\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib
 @ ./~/socket.io/~/engine.io/~/ws/lib/BufferUtil.js 10:19-40

WARNING in ./~/socket.io/~/engine.io/~/ws/lib/Validation.js
Module not found: Error: Cannot resolve module 'utf-8-validate' in D:\Node Practice\batweb\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib
 @ ./~/socket.io/~/engine.io/~/ws/lib/Validation.js 10:19-44

WARNING in ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/BufferUtil.js
Module not found: Error: Cannot resolve module 'bufferutil' in D:\Node Practice\batweb\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\lib
 @ ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/BufferUtil.js 10:19-40

WARNING in ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/Validation.js
Module not found: Error: Cannot resolve module 'utf-8-validate' in D:\Node Practice\batweb\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\lib
 @ ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/Validation.js 10:19-44

ERROR in ./~/socket.io/~/socket.io-client/package.json
Module parse failed: D:\Node Practice\batweb\node_modules\socket.io\node_modules\socket.io-client\package.json Unexpected token (2:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:8)
    at Parser.pp$4.raise (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp.unexpected (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:603:10)
    at Parser.pp.semicolon (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:966:10)
    at Parser.pp$1.parseStatement (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:730:24)
    at Parser.pp$1.parseBlock (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:981:25)
    at Parser.pp$1.parseStatement (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:709:33)
    at Parser.pp$1.parseTopLevel (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:638:25)
    at Parser.parse (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:516:17)
    at Object.parse (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:3098:39)
    at Parser.parse (D:\Node Practice\batweb\node_modules\webpack\lib\Parser.js:902:15)
    at DependenciesBlock.<anonymous> (D:\Node Practice\batweb\node_modules\webpack\lib\NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (D:\Node Practice\batweb\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
    at nextLoader (D:\Node Practice\batweb\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
    at D:\Node Practice\batweb\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
    at Storage.finished (D:\Node Practice\batweb\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
    at D:\Node Practice\batweb\node_modules\webpack\node_modules\enhanced-resolve\node_modules\graceful-fs\graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
 @ ./~/socket.io/lib/index.js 10:20-55

ERROR in ./~/socket.io/~/engine.io/~/accepts/~/mime-types/~/mime-db/db.json
Module parse failed: D:\Node Practice\batweb\node_modules\socket.io\node_modules\engine.io\node_modules\accepts\node_modules\mime-types\node_modules\mime-db\db.json Unexpected token (2:40)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:40)
    at Parser.pp$4.raise (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp.unexpected (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:603:10)
    at Parser.pp.semicolon (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:966:10)
    at Parser.pp$1.parseStatement (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:730:24)
    at Parser.pp$1.parseBlock (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:981:25)
    at Parser.pp$1.parseStatement (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:709:33)
    at Parser.pp$1.parseTopLevel (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:638:25)
    at Parser.parse (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:516:17)
    at Object.parse (D:\Node Practice\batweb\node_modules\webpack\node_modules\acorn\dist\acorn.js:3098:39)
    at Parser.parse (D:\Node Practice\batweb\node_modules\webpack\lib\Parser.js:902:15)
    at DependenciesBlock.<anonymous> (D:\Node Practice\batweb\node_modules\webpack\lib\NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (D:\Node Practice\batweb\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
    at nextLoader (D:\Node Practice\batweb\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
    at D:\Node Practice\batweb\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
    at Storage.finished (D:\Node Practice\batweb\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
    at D:\Node Practice\batweb\node_modules\webpack\node_modules\enhanced-resolve\node_modules\graceful-fs\graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
 @ ./~/socket.io/~/engine.io/~/accepts/~/mime-types/~/mime-db/index.js 11:17-37

A: In your webpack.config.js you need to exclude your node modules.
For example:
module: {
 loaders: [{
  exclude: /node_modules/,
  loader: '/* your loader */',
}]

See the documentation here on using loaders

A: This post by caranicas solved my problem.
I removed
var io = require('socket.io');

from my socketActions.js file and added
  <script type="text/javascript" charset="utf-8" src="/socket.io/socket.io.js"></script>

to my index.html, which exports io as a global. Requiring it seems to make webpack try to bundle it.


text:
Q: How reload system ENV in RubyMine? I try to set ENV variable in ~/.bash_profile, for example export foo='42'.
If RubyMine was running, I can't read this foo variable as ENV['foo'].
If I restart RubyMine, I can read foo from system ENV.
How can I say RubyMine, that it must to reload system ENV?

A: You can't. Environment variables are inherited by newly started subprocesses. After the subprocess has started, it has its own independent set of environment variables.


text:
Q: Text string returned by request won't ast.literal_eval to list Calling an API with requests to look up the description of a code. API returns string that looks like list. I am having trouble converting the string to a list with ast.literal_eval. I have tried many variations on response type (.text, .raw, etc.) and variations of map, str, etc. to convert the string. Would like to get the response into any usable Python object.
import requests
import ast

burl = "https://clinicaltables.nlm.nih.gov/" \
"api/icd10cm/v3/search?sf=code,name&maxList=1&terms="

dotted_code = "W59.21XS"

r = requests.get(burl+dotted_code).text

print(r)

response is:
[1,["W59.21XS"],null,[["W59.21XS","Bitten by turtle, sequela"]]]
but if I add:
l = ast.literal_eval(r)
print(l)

I get:
File "D:\Local\Continuum\anaconda3\lib\ast.py", line 55, in _convert_num
    raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Name object at 0x0000015A01B670B8>
Any better way to get the return text into a usable Python object?

A: That's JSON:
>>> import json
>>> json.loads("""[1,["W59.21XS"],null,[["W59.21XS","Bitten by turtle, sequela"]]]""")
[1, ['W59.21XS'], None, [['W59.21XS', 'Bitten by turtle, sequela']]]

A: The reason why literal_eval does not work is becuase null does not exist in Python so literal_eval has no idea what to do with it. If you were to change null to None (or to the string 'null') then literal_eval would have worked:
>>> literal_eval('''[1,["W59.21XS"], None, [["W59.21XS","Bitten by turtle, sequela"]]]''')
[1, ['W59.21XS'], None, [['W59.21XS', 'Bitten by turtle, sequela']]]

You can use response.json:
>>> r = requests.get('https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&maxList=1&terms=W59.21XS')
>>> r.json()
[1, ['W59.21XS'], None, [['W59.21XS', 'Bitten by turtle, sequela']]]
#                 ^ Note that null was automatically converted to None


text:
Q: What are the intel hex records type 03 or 05 doing in iHex program for ARM? What are the intel hex records type 03 or 05 doing in iHex program?

Record type 03: Start Segment Address     For 80x86 processors, specifies the initial content of the CS:IP registers. The address field is 0000, the byte count is 04, the first two bytes are the CS value, the latter two are the IP value.
Record type 05: Start Linear Address  The address field is 0000 (not used) and the byte count is 04. The four data bytes represent the 32-bit value loaded into the EIP register of the 80386 and higher CPU.

Do these even make sense for an ARM program?
Whenever I generate .hex to program embedded ARM, the ending looks something like this:

:10851400B4040020BC040020BC040020C4040020D7
  :10852400C4040020CC040020CC040020D404002087
  :10853400D4040020DC040020DC040020E404002037
  :10854400E4040020EC040020EC040020F4040020E7
  :10855400F4040020FC040020FC040020FFFFFFFFC3
  :048564000000020011
  :0400000508002910B6
  :00000001FF

I've edited the programming app to ignore this record, and just today a coworker reported his compiler produced a 03 type record on the second-to-last line, which prevented programming the MPU.
Why does objcopy create these records? Can I stop it from doing it?
Relevant Makefile lines:
 FORMAT = ihex
 OBJCOPY = arm-elf-objcopy

  %.hex: %.elf
    @echo
    @echo $(MSG_FLASH) $@
    $(OBJCOPY) -O $(FORMAT) $< $@

A:
Do these even make sense for an ARM program?

An ARM program will always have an entry point set, even if you provided a vector table in the bare metal case.
The arm-*-objcopy program is not very intelligent and just produces the 03 record when the entry address is within the first megabyte for compatibility reasons, and the 05 otherwise.
A flash tool can safely ignore these record types on bare metal ARM, because the vector table contains the required addresses already. You could try filtering the hex file to remove these records, e.g. using sed.


text:
Q: Object Not Adding in the collection I have a an Object in the Session namely currentCustomer as follows.
public Customer currentCustomer
        {
            get
            {
                if (Session["currentCustomer"] == null) return new Customer();
                else
                   return (Customer)Session["currentCustomer"];
            }
            set
            {
                Session["currentCustomer"] = value;
            }
        }

And also I have an MVC4 action to add the Address into Customer's address List.
    [HttpPost]
    public JsonResult CustomerAddressSave()
    {
            Address address  = new Address();
            if (TryUpdateModel<Address>(address))
            {
                UpdateModel<Address>(address);
            }
            currentCustomer.AddressList.Add(address); //Not Adding into the List.
            return Json(new { success = true }, JsonRequestBehavior.AllowGet);
    }

Surprisingly the above code is not adding the Address to the List AddressList;
I have no clue to follow up.
Could anyone had faced the same kind of issue in the past and assist me what went wrong.
Thanks in Advance,
Saravnakumar

A: get
{
    if (Session["currentCustomer"] == null) return new Customer();
     else
     return (Customer)Session["currentCustomer"];
}

You want to fix that. That just returns a new Customer object into limbo. You want to assign it to the session
get
{
    Customer customer = null;
    if (Session["currentCustomer"] == null)
    {
          customer = new Customer();
          Session["currentCustomer"] = customer;

    }
    else
    {
       customer= (Customer)Session["currentCustomer"];
    }
    return customer;
}

It was saving the address before, you just saved it to a new instance each time. The above code should fix it - hopefully.


text:
Q: Multiple subqueries to same table - performance My company recently change database engine from paradox to ms sql 2008. It is way more faster, but we have problem with one query with low performance.
Query searches if fields NUMER from DM201211 table not exists in any of DO_WZ1, DO_WZ2 ... DO_WZ6 fields in DOK_SP table.
SELECT
Z.STATUS,COUNT(K.NUMER) AS DOC_COUNT, MIN(K.ZDNIA) AS OLDEST
FROM DM201311 K LEFT OUTER JOIN ZLEC Z ON K.DO_ZAMOWIENIA=Z.NR
WHERE NUMER NOT IN (SELECT DO_WZ1 FROM DOK_SP WHERE DO_WZ1 IS NOT NULL AND ID_DOK<>'-1') AND NUMER NOT IN (SELECT DO_WZ2 FROM DOK_SP WHERE DO_WZ2 IS NOT NULL AND ID_DOK<>'-1') AND NUMER NOT IN (SELECT DO_WZ3 FROM DOK_SP WHERE DO_WZ3 IS NOT NULL AND ID_DOK<>'-1') AND NUMER NOT IN (SELECT DO_WZ4 FROM DOK_SP WHERE DO_WZ4 IS NOT NULL AND ID_DOK<>'-1') AND NUMER NOT IN (SELECT DO_WZ5 FROM DOK_SP WHERE DO_WZ5 IS NOT NULL AND ID_DOK<>'-1') AND NUMER NOT IN (SELECT DO_WZ6 FROM DOK_SP WHERE DO_WZ6 IS NOT NULL AND ID_DOK<>'-1')
GROUP BY Z.STATUS

That worked pretty well in paradox (few secs of execution). Now in MS SQL 2008 it executes about 17 seconds. After my short investigation I've find out that multiple subqueries cause this situation. Is there any chnce to optimize it with removing subqueries?
As you see all subqueries are done for the same table. I've tried with EXIST clause but I've only get down from 17 secs to 14 secs. I believe that there is better solution.
NOTE: T-SQL is not allowed for me to approach this!

A: SELECT Z.STATUS,COUNT(K.NUMER) AS DOC_COUNT, MIN(K.ZDNIA) AS OLDEST
FROM DM201311 K LEFT OUTER JOIN ZLEC Z ON K.DO_ZAMOWIENIA=Z.NR
WHERE NUMER NOT IN (SELECT COALESCE(DO_WZ1, DO_WZ2, DO_WZ3, DO_WZ4, DO_WZ5, DO_WZ6)
                    FROM DOK_SP WHERE COALESCE(DO_WZ1, DO_WZ2, DO_WZ3, DO_WZ4, DO_WZ5, DO_WZ6) IS NOT NULL
                    AND ID_DOK<>'-1')
GROUP BY Z.STATUS

A: Try to update your query with this version
SELECT  Z.STATUS ,
        COUNT(K.NUMER) AS DOC_COUNT ,
        MIN(K.ZDNIA) AS OLDEST
FROM    DM201311 K
        LEFT OUTER JOIN ZLEC Z ON K.DO_ZAMOWIENIA = Z.NR
WHERE   NUMER NOT IN ( SELECT   DO_WZ1
                       FROM     DOK_SP
                       WHERE    (DO_WZ1 IS NOT NULL AND DO_WZ2 IS NOT NULL AND DO_WZ3 IS NOT NULL AND DO_WZ4 IS NOT NULL AND DO_WZ5 IS NOT NULL AND DO_WZ6 IS NOT NULL)
                                AND ID_DOK <> '-1' )
GROUP BY Z.STATUS

If ID_DOK is a number you can change the <> '-1' to >= 0
Try to avoid negations, this will hit your performance.

A: Try to rewrite the NOT IN parts of your query with NOT EXISTS like this:
WHERE   NUMER NOT IN (SELECT DO_WZ1 FROM DOK_SP
                    WHERE DO_WZ1 IS NOT NULL AND ID_DOK<>'-1')

becomes
NOT EXISTS(SELECT DO_WZ1 FROM DOK_SP
    WHERE DO_WZ1 = NUMER
        AND ID_DOK<>'-1')

see here
.
And if there is still performance problems, check the query plan and add missing index if needed
If your DOC_SP is large, some indexes on (DO_ZW1, ID_OK), (DO_ZW2, ID_OK) etc could help
(or one with all to make a seek+scan, depends of the data)
Another solution: add LEFT OUTER JOINS for each NOT IN and test nulls (ie not found).
This is a common pattern
LEFT OUTER JOIN (SELECT DO_WZ1 FROM DOK_SP WHERE ID_DOK<>'-1') W1 ON NUMER=DO_WZ1
LEFT OUTER JOIN (SELECT DO_WZ2 FROM DOK_SP WHERE ID_DOK<>'-1') W2 ON NUMER=DO_WZ2
...
WHERE
  W1.DO_WZ1 IS NULL
AND W2.DO_WZ2 IS NULL
..

Or, to avoid multiple joins, only one with OR in JOIN (will probably lead to a scan, an index with included columns will help)
SELECT
    Z.STATUS,COUNT(K.NUMER) AS DOC_COUNT, MIN(K.ZDNIA) AS OLDEST
FROM DM201311 K
LEFT OUTER JOIN ZLEC Z ON K.DO_ZAMOWIENIA=Z.NR
LEFT OUTER JOIN ( SELECT 1 as X, DO_WZ1, DO_WZ2 DO_WZ3, DO_WZ4, DO_WZ5, DO_WZ6
                    FROM DOK_SP
                    WHERE ID_DOK<>'-1') WZ
                       ON NUMER = WZ.DO_WZ1
                        OR NUMER = WZ.DO_WZ2
                        OR NUMER = WZ.DO_WZ3
                        OR NUMER = WZ.DO_WZ4
                        OR NUMER = WZ.DO_WZ5
                        OR NUMER = WZ.DO_WZ6
WHERE
    WZ.X IS NULL
GROUP BY Z.STATUS

A: SELECT
Z.STATUS,COUNT(K.NUMER) AS DOC_COUNT, MIN(K.ZDNIA) AS OLDEST
FROM DM201311 K
LEFT OUTER JOIN ZLEC Z
ON K.DO_ZAMOWIENIA=Z.NR
WHERE NUMER NOT IN (
SELECT DO_WZ1 FROM DOK_SP WHERE DO_WZ1 IS NOT NULL AND ID_DOK<>'-1'
UNION
SELECT DO_WZ2 FROM DOK_SP WHERE DO_WZ2 IS NOT NULL AND ID_DOK<>'-1'
UNION
SELECT DO_WZ3 FROM DOK_SP WHERE DO_WZ3 IS NOT NULL AND ID_DOK<>'-1'
UNION
SELECT DO_WZ4 FROM DOK_SP WHERE DO_WZ4 IS NOT NULL AND ID_DOK<>'-1'
UNION
SELECT DO_WZ5 FROM DOK_SP WHERE DO_WZ5 IS NOT NULL AND ID_DOK<>'-1'
UNION
SELECT DO_WZ6 FROM DOK_SP WHERE DO_WZ6 IS NOT NULL AND ID_DOK<>'-1')
GROUP BY Z.STATUS

A: @Alain_Deloin suggested that you replace "not in" with "not exists".  The reason is that "not in" is slow.  However, "not in" and "not exists" do not always represent the same logic.  That being the case, here is a very unintuitive yet effective way to replace "not in".
Do not do this, it's too slow.
where somefield not in
(select somefield
 from sometable
 where whatever
 )

Do this instead.
where somefield in
(select somefield
from sometable
except
select somefield
 from sometable
 where whatever
 )

A: Paradox!? Oh my... are you still using Delphi 5 also?
Anyway I guess if Paradox can handle it its not a large DB. Did you created indexes for that tables?
A good indexing can solve performance issues.
Just in case remember: with MS SQL creating FKs ill NOT create the indexes.


text:
Q: SQL Server slow results with parameters I have a query which selects some data, I pass some parameters in it:
DECLARE @FromAccDocNo     INT = 1,
        @ToAccDocNo       INT = 999999999,
        @FromDate         CHAR(10) = '1900/01/01',
        @ToDate           CHAR(10) = '2999/12/30',
        @L1Code           INT = 129

SELECT ad.AccDocNo,
       ad.AccDocDate,
       add1.Row,
       add1.RowComment,
       add1.Debit,
       add1.Credit
FROM   AccDoc ad
       INNER JOIN AccDocDetail add1
            ON  add1.AccDocNo = ad.AccDocNo
       INNER JOIN Topic t
            ON  t.TopicCode = add1.TopicCode
WHERE  t.L1Code = @L1Code -- here is the difference
       AND add1.AccDocNo BETWEEN @FromAccDocNo AND @ToAccDocNo
       AND ad.EffectiveDate BETWEEN @FromDate AND @ToDate
ORDER BY
       ad.AccDocNo

In first, I write the value 129 explicitly as @L1Code (it takes 0.010 sec)
In second form I pass @L1Code into query (it takes 2.500 sec)
Can anyone explain what happens?

A: Please read the canonical reference: Slow in the Application, Fast in SSMS? (specifically this bit)
One way to fix, is to add OPTION (RECOMPILE) at the end of the query.


text:
Q: This sends the message from one side to other side but cant send from other side So in this code I used replits database extension
and Channel_IDS is a list of channel ids
from discord.ext import commands
from replit import db
import asyncio

bot = commands.Bot(command_prefix = ">>>")
Channel_IDS = []
db["Channels"]
Channel_IDS = db["Channels"]
@bot.event
async def on_ready():
  print("logged in as "+str(bot.user))

YES = ["Yes","yes","YES"]
NO = ["No","no","NO"]

@bot.event
async def on_guild_channel_create(channel):
  #channel = discord.utils.get(channel.guild.channels, name='channel name')
  if channel.name == "global-chat":
    id = channel.id
    Channel_IDS.append(id)
    await channel.send("successfully set <#"+str(id)+"> as global chat")
  id = channel.id
  print (Channel_IDS)

@bot.event
async def on_guild_channel_delete(channel):
  if channel.id in Channel_IDS:
    Channel_IDS.remove(channel.id)
  print(Channel_IDS)
@bot.event
async def on_message(message):
  if message.author == bot.user:
    return
    print("bot msg")
  else:
    if message.channel.id in Channel_IDS:
      print("message received"+str(message.content))
      for chann in Channel_IDS:
        if chann == message.channel.id:
          break
        chenl = bot.get_channel(chann)

        await chenl.send("**"+str(message.author)+"**  :globe_with_meridians: " + str(message.content))
        print("message sent" +str(message.content))

db["Channels"] = Channel_IDS
bot.run(".g1e5fCvWLnHBHCWoLBLhmEmWFNk")

Now the thing is if server 1 sends a message server 2 receives it but if server 2 sends a message the bot sees the message but never sends it to server 1.

A: You have wrong logic here:
if chann == message.channel.id:
    break

You need to use continue keyword instead of break to skip only 1 channel because break stops the loop.


text:
Q: When to use `>` sign in CSS?
Possible Duplicate:
What does ">" mean in CSS rules?

I came across many many websites and I saw many of them use this type of notation in their css file for creating navigation bar like :
#navigation ul li > ul {
  /* some code in between */
}

but when i omit the > sign as
#navigation ul li ul {
  /* some code in between */
}

this still works the same way.
what is the difference and when to use > sign ?

A: The > means a child element - it is the child selector. That is, directly / immediately nested after.
So, in your first example, the ul at the end of the selector must be directly descending from the li.

A: > Means the direct child of a selector, so
li > a will ONLY match an  which is directly inside an
 for example.
If the html was
 the  would not be matched.
Removing the > will match any  nested inside an
, irrespective of other things around it, so li a would match the  in

 but also in
, for example.
Here's more information on direct Child selectors: https://developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors

A: The "li > ul" syntax specifies that the ul must be a child of li. "li ul" instead says that the the styled ul is descendant of li, no matter how many levels below.

A: selector[1] > selector[2]{
[property]: value
}

This is called the child selector. In browsers that support it, it applies the styles to selector2 child elements of selector1.
Edit:
The second one you use I believe is called the Descendant selectors.
They should work identically, but it's there's a little difference. The decendant selector will apply to ALL decendants ,whereas the child selector applies only to the direct children of the parent.

A: You would use > when you want to target a direct descendant.
For example, .foo > .bar would target .bar only if it is the direct child, while .foo .bar would target any descendant of .foo that has the class .bar.

A: > is to be used when the second operand/element is a child of the first operand/element. When it's omitted; descendants are matched, which includes children.

Therefore, if your HTML is structured as you suggested (#navigation ul li ul) then if you have  the following in your CSS:
#navigation ul {color:red;}

Then both #navigation ul AND #navigation ul li ul will be coloured red (the text) as they BOTH are descendants of #navigation ul.
But if you had the following in your CSS:
#navigation > ul {color:red;}

Then only #navigation ul would be coloured red as it is the only ul which is a direct child of #navigation

A: > is the child selector.
It will only select immediate children of the previous element. If it there is a
#navigation ul li ul li ul

element it will not be affected by the
#navigation ul li > ul

selector. But the
#navigation ul li ul

will be.

EDIT: @Nix is right, but he isn't telling the whole truth it seems. *Why isn't the p-enclosed ul ignored but only the span-enclosed? display: block vs inline perhaps? Who knows?

A: The ">" selector is the child selector, space is the descendant selector. If tag3 is inside of tag2, which is inside tag1, and you use a child selector, then your css rule won't apply to tag3 if you refer to tag3 inside of tag1, however, if you use the descendant selector, tag3 will be transitively inside tag1. This means that he descendant selector is more general than the child selector.
#navigation ul li > ul {
  /* some code in between */
}

is more specific than
#navigation ul li ul {
  /* some code in between */
}

because between the li tag inside the ul tag inside the tag with the id of navigation needs ul to be a direct child in the first example and in the second example ul doesn't need to be directly the child of li, li might have a child which is the parent of ul.


text:
Q: C++ convert char[] from network to host order and assign to unsigned int I have an array of characters that are in network byte order. I'm trying to convert the characters stored in indices [4-7] into host order and assign it to an unsigned int. I have the following function:
unsigned int parse_num_bytes(char buf[]){
  unsigned int num_bytes = ((unsigned int)buf[7] << 24) | ((unsigned int)buf[6] << 16) | ((unsigned int)buf[5] << 8) | (unsigned int)buf[4];
  return num_bytes;
}

From GDB (acutally LLDB because I'm on a mac) I can see that the operation generates the correct result, but after assignment, the value is wrong:
   81
   82   unsigned int parse_num_bytes(char buf[]){
   83     unsigned int num_bytes = ((unsigned int)buf[7] << 24) | ((unsigned int)buf[6] << 16) | ((unsigned int)buf[5] << 8) | (unsigned int)buf[4];
-> 84     return num_bytes;
   85   }
(lldb) p num_bytes
(unsigned int) $0 = 4294967170
(lldb) p ((unsigned int)buf[7] << 24) | ((unsigned int)buf[6] << 16) | ((unsigned int)buf[5] << 8) | (unsigned int)buf[4]
(unsigned int) $1 = 2434

For clarification, 2434 is the correct value.
Here is where I generate the network ordering (in a server application):
return_buf[4] = index & 0xff;
return_buf[5] = (index >> 8) & 0xff;
return_buf[6] = (index >> 16) & 0xff;
return_buf[7] = (index >> 24) & 0xff;

And from GDB I can show you the value of index (it's an unsigned int)
   142    return_buf[4] = index & 0xff;
   143    return_buf[5] = (index >> 8) & 0xff;
   144    return_buf[6] = (index >> 16) & 0xff;
-> 145    return_buf[7] = (index >> 24) & 0xff;
   146
   147    in_file.close();
   148    Rio_writen(connfd, return_buf, MAXLINE);
(lldb) p index
(unsigned int) $0 = 2434

A: Guess your char type is signed, so it can contain negative values. Those don't convert well to unsigned int.
You might want to use unsigned char for your buffer type.


text:
Q: Fstream fails to create new file I'm using a FileManager for a project so that reading and writing is less of a hassle for me. Or would be, if I didn't spend all this time debugging it. So, this comfort-class actually caused me stress and time. Awesome.
The problem seems to be the fstream. Before I continue further, here is the structure of my FileManager class.
class FileManager : Utility::Uncopyable
{
public:
    FileManager();

    void open(std::string const& filename);
    void close();

    void read(std::string& buffer);
    void write(std::string const& data);

private:
    std::fstream stream_;
};

Very simple. The buffer is loaded with data during the read function, the data parameter is what's to be written to file. Before reading and writing you must open the file or risk getting a big, fat exception in your face. Kind of like the one I'm getting now.
Scenario:  Simple command-line registering of a user, then writing the data to file. I ask for a name and password. The name is copied and appended with .txt (the filename). So it looks like this:
void SessionManager::writeToFile(std::string const& name,
                                 std::string const& password)
{
    std::string filename = name + ".txt";
    std::string data;
    data += name +", " +password;

    try
    {
        fileManager_->open(filename);
        fileManager_->write(data);
        fileManager_->close();
    }
    catch(FileException& exception)
    {
        /* Clean it up. */
        std::cerr << exception.what() << "\n";
        throw;
    }
}

Problem:  the open fails. The file is never created, and during the write I get an exception for not having an open file.
FileManager::open() function:
void FileManager::open(std::string const& filename)
{
    if(stream_.is_open())
        stream_.close();

    stream_.open(filename.c_str());
}

and write
void FileManager::write(std::string const& data)
{
    if(stream_.is_open())
        stream_ << data;
    else
        throw FileException("Error. No file opened.\n");
}

However, if I create the file beforehand, then it has no troubles opening the file. Yet, when I check, the default std::ios::openmode is std::ios::in | std::ios::out. I can create the file just fine when I only tag std::ios::out, but I want to keep the stream in a read/write state.
How can I accomplish this?

A: Best method:
void FileManager::open(std::string const& filename)
{
    using std::ios_base;
    if( stream_.is_open() )
        stream_.close();

    stream_.open( filename.c_str() ); // ...try existing file
    if( !stream_.is_open() ) // ...else, create new file...
        stream_.open(filename.c_str(), ios_base::in | ios_base::out | ios_base::trunc);
}

So the code tests for an existing file and, if not, creates it.

A: You have to call fstream::open with an explicit openmode argument of
ios_base::in | ios_base::out | ios_base::trunc

Otherwise open will fail due to ENOENT.
Table 95 of the draft C++ standard lists possible file open modes and their equivalent in stdio. The default, ios_base::out | ios_base::in is r+. The one I listed above is equivalent to w+. ios_base::out | ios_base::app is equivalent to a. All other combinations involving ios_base::app are invalid.
(At the risk of being scoffed at: you could switch to stdio and use the file mode a+, which reads from the start and appends at the end.)

A: You cannot use std::ios::in on a non-existing file. Use
std::ios::in | std::ios::out | std::ios::trunc

instead (but make sure it doesn't exist or it will be truncated to zero bytes).

A:
How can I accomplish this?

std::ofstream file("file.txt");
file << data;

Isn't that simpler?

A: That's the way the library works: std::ios::in | std::ios::out opens it in the equivalent of stdio's "r+", that is it will only open an existing file. I don't believe there's a mode that will do what you are wanting, you'll have to us an OS-specific call or check the file for existence (again, using an OS-specific call) and open it in one mode or the other depending on whether it already exists.
Edit: I assumed that you didn't want the file truncated if it already exists. As other people have noted, if you're happy to truncate any existing file then in | out | trunc is an option.

A: Just get your function to open
void FileManager::open(std::string const& filename)
{
    using std::ios_base;
    if(stream_.is_open())
        stream_.close();

    stream_.open(filename.c_str(), ios_base::in | ios_base::out | ios_base::trunc);
}

if that is the mode you require.
There is no magic way to open a file for read/write creating it if it does not exist but not truncating it (removing its content) if it does. You have to do that in multiple steps.


text:
Q: How do I use Recruit Cards in Grand Battle? I'm playing Grand Battle on Android, and yesterday I got a high level Recruit Card in my bag. However, I don't know how to actually use the card. Could anybody help me?

A: Go Generals icon and go to Recruit Generals section, and you will see "One in a Million", then select "Priority Use High Level Recruit" card, and that means you are using this card in priority. Then use it. Accordingly this card in your bag will be gone.