Posts

Gunicorn sever can not start in Ubuntu

Image
Clash Royale CLAN TAG #URR8PPP Gunicorn sever can not start in Ubuntu I am deploying a flask project with Nginx, Gunicorn and Ubuntu Linux server. Currently, I have already done something and the server can be started manually with the command gunicorn -w 4 -b 127.0.0.1:5000 run:app Followings is the content of nginx.conf user www www; worker_processes 2; error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; pid /usr/local/webserver/nginx/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; #charset gb2312; # server_names_hash_bucket_size

accessing custom method in model

Image
Clash Royale CLAN TAG #URR8PPP accessing custom method in model Im practicing laravel and im making a custom method for my user In my user model i have build a function like this public function employee(){ return $this->where('user_type','employee'); } and then in my controller I'm accessing the function like this public function index(){ $users = User::latest()->employee(); return UserResource::collection($users); } but it return an error Method IlluminateDatabaseQueryBuilder::employee does not exist. how to fix this? IlluminateDatabaseQueryBuilder::employee does not exist. 1 Answer 1 Use local scope instand public function scopeEmployee($query) { return $query->where('user_type', 'employee'); } Your controller can be as it was ! public function index(){ $users = User::latest()->employee()->get(); return ProductsReso

Recursively transfer strings from istream into array - C++

Image
Clash Royale CLAN TAG #URR8PPP Recursively transfer strings from istream into array - C++ I am trying to copy in strings from a .txt file (every word is on a new line) into an array. The main routine would look like this. .txt const int MAXDICTWORDS = 5000; int main() { string dict[MAXDICTWORDS]; ifstream dictfile; // file containing the list of words dictfile.open("words.txt"); if (!dictfile) { cout << "File not found!" << endl; return (1); } int nwords = dicReader(dictfile, dict); // dict should now hold array of words from words.txt // nwords will be the amount of words in the array } This is my current implementation of dicReader . dict will always be empty when passed to this function. I am practicing with recursion, so no while or for loops can be used. Any ideas on what I am missing? dicReader dict while for int dicReader(istream &dictfile, string dict) { int count = 0; // know this is w

Repository not found, but I can't add it either

Image
Clash Royale CLAN TAG #URR8PPP Repository not found, but I can't add it either After changing to 2 factory authentication, I get the following error when I try to pull/push to/from a remote branch such as git pull origin master : remote: Repository not found. fatal: repository 'https://github.com/my-organization/my-project.git/' not found However, when I try to add the repository git remote add origin https://github.com/my-organization/my-project.git I get an error fatal: remote origin already exists. I follow this document to resolve invalid username or password error. Now, How can I resolve this repository error? Update: I try to start out on the repository with git clone https://github.com/my-organization/my-project.git And I get the same error: Cloning into 'my-project'... git: 'credential-netrc' is not a git command. See 'git --help'. <-- don't know how this comes up Username for 'https://github.com': my-username remote: Repositor

How do I select drop down web browser C#

Image
Clash Royale CLAN TAG #URR8PPP How do I select drop down web browser C# I need to know how to select the month. I've tried: webBrowser1.Document.GetElementById("MonthDropdown").SetAttribute("value", "Jan"); I used something else: webBrowser1.Document.GetElementById("MonthDropdown").Children[1].SetAttribute("selected", "true"); But it doesn't recognize that it changed. HTML Code: Found rest of the HTML code, Don't know if what else I got will help or anything with what I'm trying to do.. <div class="birthday-container"> <div class="form-group" ng-class="{'has-error' : isBirthdayInvalid(), 'has-success' : isBirthdayFormDirty() &amp;&amp; !isBirthdayInvalid() }"> <label class="birthday-la

Java - Functional interface - The type parameter PacketIn is hiding the type PacketIn

Image
Clash Royale CLAN TAG #URR8PPP Java - Functional interface - The type parameter PacketIn is hiding the type PacketIn @FunctionalInterface public interface ProtocolNetworkHandler { void handle(ChannelHandlerContext ctx, P packet); } I got this functional interface but it's giving me a warning on PacketIn, any idea why? P, PacketIn with bigger/less than signs comes after ProtocolNetworkHandler (won't show up for some reason). (The type parameter PacketIn is hiding the type PacketIn) PacketIn is just a regular interface. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Read scientific formatted numbers from txt

Image
Clash Royale CLAN TAG #URR8PPP Read scientific formatted numbers from txt I would like to read and store scientific formatted numbers from a txt file, which is formatted and the numbers are separated by tabulator. This is what I have so far: IMPLICIT NONE REAL,ALLOCATABLE,DIMENSION(2) :: data(:,:) INTEGER :: row,column INTEGER :: j,i CHARACTER(len=30) :: filename CHARACTER(len=30) :: format filename='data.txt' open(86,file=filename,err=10) write(*,*)'open data file' read(86, *) row read(86, *) column allocate(data(row,column)) format='(ES14.7)' do i=1,row read(86,format) data(i,:) enddo close(86) This is how the txt file looks like: 200 35 2.9900E-35 2.8000E-35 2.6300E-35 2.4600E-35 2.3100E-35 2.1600E-35 ... The problem is that it doesn't read and store the correct values from the txt to the data variable. Is it the format causing the problem? I would also like to know how to count the number of co

Java Socket - hanging on socket creation

Image
Clash Royale CLAN TAG #URR8PPP Java Socket - hanging on socket creation I have an Android device (client) and Ubuntu 16.04 machine (server). I'm trying to establish a socket connection to send messages to and from each. I had it working earlier on port 6943 , now it hangs somewhere. I am unsure how to proceed in debugging this, no exceptions or errors occur. It simply hangs up on Socket s = new Socket("192.168.0.216", 6943) (client), because the line Log.d(TAG, "Creating I/O streams"); no longer runs. 6943 Socket s = new Socket("192.168.0.216", 6943) Log.d(TAG, "Creating I/O streams"); Note: "xxx.xxx.x.xxx" is the IP address of my Ubuntu machine. "xxx.xxx.x.xxx" Client-side code: public class SocketManager { public static String TAG = "SocketManagerClass"; public static void createSocket() { try { Scanner scn = new Scanner(System.in); Log.d(TAG, "Creating new socket

Trying to run a command in a changing command prompt

Image
Clash Royale CLAN TAG #URR8PPP Trying to run a command in a changing command prompt I'm writing a powershell script that remotely gets the workspace info on a remote computer's TFS. What I need to do is either invoke-command or psexec the path of the batch file to open up the visual studio dev command prompt, and then run a command inside that prompt. What I'm having trouble with is executing the second command inside the dev command prompt. What is happing right now is I'm able to open the dev command prompt, but only when I exit it does the second command run. Below is some code I was trying. . Invoke-Command -ComputerName computer1 {cmd /k '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7ToolsLaunchDevCmd.bat" & tf'} ^ I get a tf is not recognized, which it isn't when in a normal command prompt. If it ran in the dev prompt I'd get some version info and help commands. . @echo off "C:UsersmeDownloadsPSToolsPsExec.exe

Angular set input on change equal to a variable holding a function

Image
Clash Royale CLAN TAG #URR8PPP Angular set input on change equal to a variable holding a function I know you can do something like <input (input)="doSomething($event)" /> <input (input)="boolVar = $event.target.value > 5" /> but how can I do something like funcVar = (e) => { console.log(e.target.value) } <input (input)="funcVar" /> I tried other things like <input [input]="funcVar" /> <input [(input)]="funcVar" /> but no luck. Reason I'm doing this is that our forms are being generated from a data set, so they only way I can add on stuff like is by passing in stuff through variables that will generate the forms. 1 Answer 1 The event handler should call the function. The markup would be: <input (input)="funcVar($event)" /> for the funcVar member defined as: funcVar public funcVar = (e) => {

flutter real time face detection

Image
Clash Royale CLAN TAG #URR8PPP flutter real time face detection I am currently developing an app that requires real time face detection. Right now I have the mlkit library in the app and I am using the firebase face detector. At the moment, it produces an error every time I try to detect a face from file: DynamiteModule(13840): Local module descriptor class for com.google.android.gms.vision.dynamite.face not found. As for the real time part, I tried using the RepaintBoundary in flutter to get a screenshot of the camera widget (almost)every frame and convert it into a binary file for face detection. But for some reason, flutter crashed every time I tried to screenshot the camera widget. It worked for other widgets. After coming across both of these problems and spending quite a while trying to solve them, I've been thinking about just doing the camera part of the app in android/iOS native code(I would do this with OpenCV so that I can have real time detection). Is there a way I coul

Javascript: Creating Functions in a For Loop

Image
Clash Royale CLAN TAG #URR8PPP Javascript: Creating Functions in a For Loop Recently, I found myself needing to create an array of functions. The functions use values from an XML document, and I am running through the appropriate nodes with a for loop. However, upon doing this, I found that only the last node of the XML sheet (corresponding to the last run of the for loop) was ever used by all of the functions in the array. The following is an example that showcases this: var numArr = ; var funArr = ; for(var i = 0; i < 10; ++i){ numArr[numArr.length] = i; funArr[funArr.length] = function(){ return i; }; } window.alert("Num: " + numArr[5] + "nFun: " + funArr[5]()); The output is Num: 5 and Fun: 10. Upon research, I found a a segment of code that works, but I am struggling to understand precisely why it works. I reproduced it here using my example: var funArr2 = ; for(var i = 0; i < 10; ++i) funArr2[funArr2.length] = (function(i){ return functio