Posts

Showing posts from July 27, 2018

Python 3 cant find my own module

Image
Clash Royale CLAN TAG #URR8PPP Python 3 cant find my own module /database/frontend /database/backend Same file in same direct still cant import backend in front end I have tried setting the PYTHONPATH ; sys.append() method ; using from . Import backend but still cant figure it out PYTHONPATH sys.append() method from . Import backend Did you make some __init__.py files? – cricket_007 26 mins ago __init__.py 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.

Firefox axios post to a Nodejs server responds 200 without ever actually entering the post

Image
Clash Royale CLAN TAG #URR8PPP Firefox axios post to a Nodejs server responds 200 without ever actually entering the post I've got two Node Js servers running Express, one to manage the UI and a second to handle certain backend API calls. On Firefox, the UI will make an axios post to the backend and immediately get a 200. I've put tracing all over and the backend server is definitely not being touched. (I'm not familiar with any step-through debugging on Firefox) 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.

Phalcon behaviours not working

Image
Clash Royale CLAN TAG #URR8PPP Phalcon behaviours not working I'm trying to get some Phalcon PHP behaviour going, but it's not working in my model as expected. Here's the initialize function of my model: public function initialize() { $this->addBehavior( new Timestampable( [ 'beforeCreate' => [ 'field' => 'created_at', 'format' => 'Y-m-d H:i:s', ] ] ) ); $this->addBehavior( new Timestampable( [ 'beforeCreate' => [ 'field' => 'updated_at', 'format' => 'Y-m-d H:i:s', ] ] ) ); } This does not save the timestamps to the database when I create a new instance in my code. The lock is saved like this: $lock = new TradesLocks(); $lock->trad

How to get local heroku app to connect to remote REDIS?

Image
Clash Royale CLAN TAG #URR8PPP How to get local heroku app to connect to remote REDIS? I am new to Heroku/Redis. I have created a basic node.js and express APP to which I have added a REDIS addon. heroku addons:create heroku-redis:hobby-dev -a MyApp I have an index.js from which the server runs on port 5000 index.js const express = require('express') const path = require('path') const PORT = process.env.PORT || 5000 const client = require('redis').createClient(process.env.REDIS_URL); express() .use(express.static(path.join(__dirname, 'public'))) .set('views', path.join(__dirname, 'views')) .set('view engine', 'ejs') .get('/', (req, res) => res.render('pages/index')) .listen(PORT, () => console.log(`Listening on ${ PORT }`)) My repo is connected to my personal github from Heroku where the app runs fine, but whenever I try to run it locally it seems it tries to connect to REDIS locally so I h

Generating uniform random numbers in vb.net

Image
Clash Royale CLAN TAG #URR8PPP Generating uniform random numbers in vb.net I have arraylist which contains numbers with array index in the following order: 0 - 10000 1 - 10500 2 - 11000 3 - 11500 . . 99 - 59500 The logic here is that the starting numbers changes after the interval of 20. So i want to have atleast 1 number selected randomly from the 5 sets of 20 for any numbers of selection without repeating the numbers. For example if i select 6 numbers randomly then the numbers can be 10500 20000 30500 40500 50000 40000 here i got all the starting numbers present in the selection without repeating the numbers. if the number of selection is 10 then the selected numbers must contain 2 numbers from each 5 sets which means there will be 2 numbers starting with 1, 2 numbers starting with 2, 2 numbers starting with 3,.....All the selected numbers must be non repeating. Can anyone help me to achieve this using VB.NET. Heres my code and it works fine till it reaches around 50 then after t

get a single object from an array, according to condition by one of its keys

Image
Clash Royale CLAN TAG #URR8PPP get a single object from an array, according to condition by one of its keys I have an array of objects and I would like to obtain only the object that has the largest quantity, in this example the object with 'id': 4, and trying to use the filter property of javascript, but I have not achieved it, otherwise I can to achieve this? [ { "id": 1, "quantity": 10, "price": 80 }, { "id": 2, "quantity": 30, "price": 170 }, { "id": 3, "quantity": 50, "price": 230 }, { "id": 4, "quantity": 100, "price": 100 } ] If you only want one object, why use filter ? Why not use .find ? – CertainPerformance 2 mins ago filter .find

Smart Card APIs throw First Chance exceptions but program runs fine

Image
Clash Royale CLAN TAG #URR8PPP Smart Card APIs throw First Chance exceptions but program runs fine INTRODUCTION I am learning how to use Smart Card API in order to obtain card number once it gets inserted into reader. So far I have managed to create a working application that runs (as far as I can see) without errors. PROBLEM During debugging I see various First chance exceptions, but every Smart Card API returns SCARD_S_SUCCESS and program never crashes nor exhibits any other erroneous behavior. SCARD_S_SUCCESS RELEVANT INFORMATION #include <Windows.h> #include <iostream> #include <iomanip> #include <winscard.h> #pragma comment(lib, "Winscard.lib") void f() // helper that transforms error code to meaningful message { LPSTR s = NULL; if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), s

How to Generate Halide Function with float argument

Image
Clash Royale CLAN TAG #URR8PPP How to Generate Halide Function with float argument I'm trying to create a (C++) helper function that transforms a lookup table that's computed in my C++ code into a Halide Func which takes a float as an argument and lerps between samples in the LUT. The use-case here is that the user has generated a tone curve using a spline with a bunch of control points that we want to apply with Halide. So I sample this spline at a bunch of points, and I want to write a Halide function that lets me linearly interpolate between these samples. Here's my current attempt at this: #include <Halide.h> using namespace Halide; using namespace std; static Func LutFunc(const vector<float> &lut) { Func result; Var val; // Copy the LUT into a Halide Buffer. int lutSize = (int) lut.size(); Buffer<float> lutbuf(lutSize); for(int i = 0; i < lut.size(); i++) { lutbuf(i) = lut[i]; } // Compute the offset into

foreach loop with $value didnot work together with sqlselect where $value

Image
Clash Royale CLAN TAG #URR8PPP foreach loop with $value didnot work together with sqlselect where $value I made foreach loop for index array to print a table. $value is also used for echo some values from next associative array(s)... I would use $value for MySQL select table where var $value is used for WHERE parameter. But nothing happend. Maybe could someone find the bug. Im helpless now, Im working on it last 14 hours and my brain is usless now. Can somebody help please? Its all in this part of code: foreach ($seraz_soupis_pot as $key => $value) { $sqlshowpotraviny = "SELECT nazev, jednotka, jednotkajeg FROM ft_potraviny WHERE nazev = $value"; $resultshowpotraviny = mysqli_query($link, $sqlshowpotraviny); $rowshowpotraviny = mysqli_fetch_assoc($resultshowpotraviny); if ($rowshowpotraviny['jednotka'] == "g") { $nasobek = ""; $jednotka = "";

How to create a hidden keystroke logger using Python 3.6.4? [on hold]

Image
Clash Royale CLAN TAG #URR8PPP How to create a hidden keystroke logger using Python 3.6.4? [on hold] 1- Creating a keystroke logger 2- Automatically saved in a file 3- Sent directly to your mail Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. I'm voting to close this question as off-topic because spam. – Sayse 5 mins ago 4- look for usernames & passwords 5- start blackmailing automatically – Massoud Hosseinali 4 mins ago

Angular 6 - Cannot Process data from web api

Image
Clash Royale CLAN TAG #URR8PPP Angular 6 - Cannot Process data from web api I am attempting to process some data from an api in Angular 6. However, even though I can see in Network tab that the data below is being returned, I cannot process the data after this call completes. My data returned by service: {"profile": "German DJ and producer based in Berlin. He is the founder of a label."} My fetch: public fetchData(): Observable<DiscogsRecord> { return this.http.get(this.url).pipe( map(response => response["profile"]), catchError(this.errorHandler("Error loading music data.", )) ); } My interface: export interface DiscogsRecord { profile: string; } My ngOnInit: ngOnInit() { this.recs = ; this.dataService.fetchData().subscribe(records => (this.recs = records)); console.log(this.recs); ... etc When I log this.recs, I get no data, just an empty array: . What am I doing wrong? Have you tri

Does runit support to delay to first start

Image
Clash Royale CLAN TAG #URR8PPP Does runit support to delay to first start I met a problem about the runit service bootstrap. The service will setup and curl an external service endpoint to get its data. It will restart over and over again and keep sending requests until the data is ready for the external service. So I thought there is remediation to reduce the requests which delay the runit service to run the script for the first time. But I could not find any way to delay the runit service. Does runit support delay its service to the first start? Or the solution has any improvement? BTW, the service will setup with system boot. 1 Answer 1 You might try changing the runlevel of runit so that it doesn't start too soon, but that depends on the dependent process running first. A better solution, described in the documentation, is to use the fact that runit will try to start a service again if it di

Schema, table and column names processing via custom migration class with Fluent Migrator

Image
Clash Royale CLAN TAG #URR8PPP Schema, table and column names processing via custom migration class with Fluent Migrator I'm writing a migration tool for modular applications which are intended to use internal modules, each with its own set of migrations. Our applications are all based on dotnet core, may use different dbms and can use different conventions: each module in its own schema or not, custom table prefix per module, upper or lower case table names, etc. Thus these conventions need to be told by the application itself while needing to write only once each migration in each module. I'd like not to have to call a method call each time we insert a column name, table name, etc, for the developer not to have to have all this stuff in mind. I started to reimplement each expression builder, but I feel it's very wrong and error-prone. I also made a custom generic Migration class, inheriting Migration and having a naming convention interface as a generic type (which as thr

How to let a chatbot use a model already trained

Image
Clash Royale CLAN TAG #URR8PPP How to let a chatbot use a model already trained I am trying for the first time to build a chatbot. Following this tutorial, I already have a jupyter notebook solution that is working with a model already trained. import nltk from nltk.stem.lancaster import LancasterStemmer import numpy as np import tflearn import tensorflow as tf import random import json from ._conv import register_converters as _register_converters stemmer = LancasterStemmer() with open('intents.json') as json_data: intents = json.load(json_data) words = classes = documents = ignore_words = ['?'] # loop through each sentence in our intents patterns for intent in intents['intents']: for pattern in intent['patterns']: # tokenize each word in the sentence w = nltk.word_tokenize(pattern) # add to our words list words.extend(w) # add to documents in our corpus documents.append((w, intent['tag']

Error on EF migration - Azure - MySql on App

Image
Clash Royale CLAN TAG #URR8PPP Error on EF migration - Azure - MySql on App I'm trying to run all pending migrations on my web app asp.net core 2.1 on Azure using MySql on App, free tier (always on not enabled) but I receive an error, as in the log file: "Microsoft.EntityFrameworkCore.Database.Connection: An error occurred using the connection to database '' on server '127.0.0.1:54184'" The mysql package I'm using is Pomelo.EntityFrameworkCore.MySql, version 2.1.1. I'm running this code in the Configure method of the Startup class: using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) { using (var context = serviceScope.ServiceProvider.GetService<SandroDbContext>()) { context.Database.Migrate(); } } It seems to get the correct server and port from the environment variable for MySql in App , but not the database name. UPDATE: It doesn't work even if i remove th

No recent versions appear in Crashlytics (was “HTTP error 403…”)

Image
Clash Royale CLAN TAG #URR8PPP No recent versions appear in Crashlytics (was “HTTP error 403…”) Edit / Update: This error "failed to download settings..." is probably not related to the missing info in Crashlytics since the error is maybe permissible? (Though worth mentioning the error sometimes says code=2 now and sometimes code=-5 ) code=2 code=-5 Crashlytics is still not showing any recent versions. Most all of my users are on Version 1.1 build #267, and we are testing Version 1.2. The latest build in the Crashlytics dashboard is way out of date at #239. At first I thought this was because we started using Firebase without upgrading to the Firebase version of Crashlytics, but upgrading to Firebase-Crashlytics didn't fix it. Log with debugging enabled: https://gist.github.com/lacyrhoades/9c8cf5afc6a885fbca1f50cf26170ac6 Noticing this error now: 2018-07-27 15:07:06.093192-0400 Fobo[1742:525256] [Crashlytics:Crash] Unable to read identifier at path /var/mobile/Containers

Order of key values in mongoDb [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP Order of key values in mongoDb [duplicate] This question already has an answer here: mongo code : db.temperature.insert({"x":3,"y":4}); db.temperature.find(); OUTPUT { "_id" : ObjectId("52b418fb132c1f3236831447"), "y" : 4, "x" : 3 } Please help me to understand why in my case(above.) The find method is showing Y value first and x value later even when while inserting the order is different. Appreciate any help. This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. 1 Answer 1 Quoting https://stackoverflow.com/a/6453755/1150636 Both document structure and collection structure in MongoDB based on JSON principles. JSON is a set of key/value pairs (in particular fieldName/fieldValue for document and index/document for collectio