CodeSpent

1

votes
1

answer
678

views

Handling CORS when developing from localhost using REST APIs - Streamlabs API

I'm sure this question will get flagged in some manner, however hours of searching has prompted no usable information. Many projects require me to use various APIs. The current project uses the Twitch and Streamlabs API. When trying to access the /authorize endpoints, I'm hit with a CORS policy rest...
CodeSpent
1

votes
1

answer
12

views

Django accepting QueryParams (Must be callable error)

I'd like http://example.com/view_item/4 to handle a view for a selected object by passing the object ID, but after trying every combination I've found online of what will work, I'm still getting the following error: TypeError: view must be a callable or a list/tuple in the case of include(). This is...
CodeSpent
1

votes
1

answer
31

views

Remove non-numerics from filename/string

Lets suppose I have a bulk of files that need to be formatted to be better accessible by an application. Currently a file name may look like this: 035 - Springfield, MA.pdf The way my application references an object is by that id the file is prefixed with, so I started embarking on bulk renaming b...
CodeSpent
1

votes
0

answer
22

views

Django Request - Catching # prefixed QueryParams

Take a url like so: http://localhost:8000/auth/twitch/#access_token= Using request.get['access_token'] won't catch this because it is invalid. Changing to http://localhost:8000/auth/twitch/?access_token= resolves the issue, but I wouldn't expect Twitch to do this unintentionally, so how do I catch...
CodeSpent
0

votes
1

answer
7

views

Catch empty list in While loop [duplicate]

This question already has an answer here: How do I check if a list is empty? 35 answers I am trying to get a list of subscribers via cursor based pagination. This is my first time using cursor based pagination, so I may be over complicating & I hope you'll identify that if so! Here is my function f...
CodeSpent
1

votes
1

answer
65

views

node-cron not executing script on interval only console.log

On initial run, it'll run app.js however, on interval it skips over it. What might I be doing wrong here? var cron = require('node-cron'); cron.schedule('*/10 * * * * *', function(){ var shell = require('./app.js'); commandList = [ 'node app.js' ] console.log('Bot successfully executed'); }); Log:...
CodeSpent
1

votes
2

answer
155

views

Twitter API - POST favorites/create Specific Rate Limit

I was having an issue with my script crashing on a message undefined error which was answered here: TypeError: Cannot read property 'message' of undefined - Twitter API It turned out that when hitting a rate limit, the error message is delivered differently thus console.log('Try Favorite - ', err[0]...
CodeSpent
1

votes
1

answer
1.5k

views

TypeError: Cannot read property 'message' of undefined - Twitter API

Below is the output when running app.js. This started occurring totally at random when everything was working fine. Absolutely no changes were made. TypeError: Cannot read property 'message' of undefined at /home/ec2-user/environment/rt-bot/app.js:78:48 at Request._callback (/home/ec2-user/environme...
CodeSpent
1

votes
1

answer
0

views

Adding values to Django QuerySet

Is there any way to append a non-Django supplied value to a query? For instance, to find out if a store closed, I may run a function called get_closed_stores() which returns a list of closed stores. Stores Closed [00090, 00240, 00306, 00438, 03005, 05524] Great, now we have store numbers for stores...
CodeSpent
1

votes
1

answer
35

views

Dry method for getting function name in logs

I am capturing the name of a function for the purpose of logging using $functionName = $MyInvocation.MyCommand in every function, then allowing my Write-Log function to get this value. Log Function: Function Write-Log { [CmdletBinding()] Param( [Parameter(Mandatory=$False)] [ValidateSet('INFO','WARN...
CodeSpent
1

votes
1

answer
29

views

Get count of related models

I have 2 models, Item which represents a product, and OnHand which represents each individual serialized product. They are bound by a ForeignKey of product_id. Item Model: class Item(models.Model): name = models.CharField(max_length=100) description = models.CharField(max_length=100) manufacturer =...
CodeSpent
1

votes
2

answer
41

views

Python - Validating Phone Number before returning

Considering the datasource I'm using is very dirty and can contain some of the following in the 'phone number' fields; empty (New Standard) !! CLOSED !! none I am doing a mass import and want to be sure to just not even bother with these. So I'm filtering through a class to format the numbers, but I...
CodeSpent
0

votes
1

answer
11

views

Django - Accepting full sentence in query parameters

I'm putting together a small API that just converts the message coming in to Spongebob mockcase. I've got everything rolling, but coming back I'm realizing I've been testing with a single value & thus just noticed the following URL entry will not be able to accept spaces/%20. url(r'^mock/(?P\w+)/$',...
CodeSpent
1

votes
0

answer
19

views

Django - Variable deleting itself prior to Object Create?

Consider this snippet: if fire_prim is not None: print('Fire Primary is definitely not Null, here is proof: {}'.format(fire_prim)) fire_primary_obj = LifeSafety.objects.create( name='Fire Primary', store=store_obj, phone_line=fire_prim, phone_line_provider=an_provider) We get the following output...
CodeSpent
0

votes
0

answer
3

views

Django served with Gunicorn as Systemd service starting, but app not running

[Unit] Description=IT Database Application Daemon After=network.target StartLimitIntervalSec=0 [Service] Type = simple Restart = always RestartSec = 1 User = WorkingDirectory = /home//applications/it-database ExecStart = /usr/bin/env gunicorn --bind 0.0.0.0:9001 dsg-it-database.wsgi [Install] Wante...
CodeSpent
0

votes
2

answer
75

views

Nginx running but not serving

I'm configuring a proxy pass for all HTTP traffic to port 9001. Nginx.conf #user nginx; worker_processes 1; #error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; #pid /var/run/nginx.pid; #include /etc/nginx/modules.c...
CodeSpent
1

votes
1

answer
19

views

Annotate but with non-Django supplied values

Is there any way to append a non-Django supplied value to a query? For instance, to find out if a store closed, I may run a function called get_closed_stores() which returns a list of closed stores. Stores Closed [00090, 00240, 00306, 00438, 03005, 05524] Great, now we have store numbers for stores...
CodeSpent
4

votes
1

answer
207

views

Swiper coverflow blank when in Div container

Let me prefix that I'm not very skilled nor know many good practices, I'm learning by doing as projects come about. I'm using Swiper for a game list slider, but when its put inside another Div it just disappears. I can position and size it correctly outside the Div, but I can't make it responsive th...
CodeSpent
3

votes
3

answer
64

views

Match input value to JSON object in array

I have an input for searching for a store number to find its position on the map. The JSON is hosted here, but I will leave a snippet below. '22': { 'Lat': '43.1022902', 'Address': '3065 NY-50 Saratoga Springs NY 12866 USA', 'Long': '-73.7377407' }, '23': { 'Lat': '40.3581539', 'Address': '2767 P...
CodeSpent
3

votes
2

answer
70

views

Code block unreachable when in if/else statement

When using an if/else statement to verify data was found to return the proper status code, my code within the loop to parse the response becomes completely unreachable. The following works as intended. class Circuit(Resource): def get(self, store): print('USAGE: Received a request at CIRCUIT for St...
CodeSpent
2

votes
1

answer
56

views

Leading 0 removed from argument in Powershell

New to Powershell, never needed it before I started this job. I'm just making an easier way for me to keep our stores pinging and kill some time learning. Some pretext; Our stores are always 4 numbers, so 1096 is 1096 but 704 is 0704. Here is my current script: $args.Length; foreach ($arg in $args)...
CodeSpent
2

votes
1

answer
49

views

MomentJS only showing time on load

Using momentjs to get current times, however, I'm noticing its only getting the values during load. What is causing this here? My suspicion is text() is not proper for a dynamic value? var zone = [ est = 'America/New_York', cen = 'America/Mexico_City', mount = 'America/Denver', pac = 'America/Los_An...
CodeSpent
2

votes
1

answer
489

views

Adding Jquery Mobile breaks CSS

When I add Jquery mobile to my HTML using CDN; It completely takes over my styles & breaks my design. Is there anything I can do so that way its not using Jquery's CSS for my whole project?
CodeSpent
1

votes
2

answer
50

views

SQL Query returning “None” instead of row

I'm working on a light login, and have a tabled titled Users. I'm trying to take my login form POST body and verify it across the database. Values from form: user = request.form['username'] password = request.form['password'] SQL Statement: conn = sqlite3.connect(db) cur = conn.cursor() cur.execute(...
CodeSpent
2

votes
2

answer
415

views

Format variable as 4 digits with leading zeroes

A store number could be 1-4 digits. Store #26 would be 0026 in respect to how devices are named, but I'd like to give the techs the ease of being able to type 26 to get the same result. How can I take this variable and format it to always be 4 digits by appending the leading zeroes? ## Ask user for...
CodeSpent
0

votes
2

answer
20

views

3 Divs equal width centered within Div (Clean without Floats) [duplicate]

This question already has an answer here: How to center 3 divs in the middle of the page 1 answer Align container with 3 divs horizontally 2 answers How to center three divs horizontally within a parent div? [duplicate] 7 answers I know this can be achieved with floats pretty easily, but I'm tryi...
CodeSpent
-13

votes
1

answer
120

views

Asking questions about APIs negatively perceived

I have to ask, as I see in a previous question that Software Recommendations is the appropriate place to ask questions about a specific library when we're talking about billing, changes, or anything that doesn't involve direct code, why is this the case? Shouldn't Stack Overflow be for coding/progra...
CodeSpent