James James
21450 questions
1
votes
1
answer
161
views
knitr kable and “*”
I am trying to produce a table with a '*' as a value in a cell:
---
title: 'Untitled'
author: 'James Durant'
date: 'November 7, 2017'
output: pdf_document
---
```{r arthmatic, echo=FALSE}
library(knitr)
dfx
1
votes
2
answer
1.7k
views
Using variables across Flask routes [duplicate]
This question already has an answer here:
Are global variables thread safe in flask? How do I share data between requests?
2 answers
I am learning Flask and have a question regarding use of variables in the context of routes.For Example, my app.py:
from flask import Flask, render_template
app = Fla...
1
votes
2
answer
77
views
How does Google App engines cold boot deal with global variables?
My python API initializes a global variable which takes about 10 seconds to fully initialize before the server starts running. I'm wondering if when GAE initializes a new instance, this same initialization is required? or am I able to access the same variable across multiple instances?
1
votes
1
answer
92
views
cProfile causes pickling error when running multiprocessing Python code
I have a Python script that runs well when I run it normally:
$ python script.py
I am attempting to profile the code using the cProfile module:
$ python -m cProfile -o script.prof script.py
When I launch the above command I get an error regarding being unable to pickle a function:
Traceback (most...
1
votes
1
answer
300
views
ESLint couldn't find the plugin “[email protected]”
I'm not sure if there's a bug with something I'm using or whether I've just set something up wrong here, but I'm getting this error from eslint when running eslint src --fix about '[email protected]'
I've specified the plugin as listed in the @TypeScript-eslint docs but I'm getting th...
1
votes
2
answer
44
views
Difference between getting bean through Controller method and applicationContext
Have issues getting bean instances from Controller methods over SpringApplicationContext. What I require in my Controller method is a well populated instance of class B. Definition of class B is below:
@Component
public class ADep {
}
@Component
public class A {
@Autowired
private ADep aDep;
public...
0
votes
0
answer
25
views
columns as a paramater in .at[] in python
I want to fill a dataframe's row proper values for proper columns
I am trying to reach a column by a parameter but I can not. If I send the name as string it works fine. The dataframe has the column that I am trying the reach.
list = key_queue.get()
column_name = column_name_queue.get()
print(column...
0
votes
1
answer
23
views
Using an Objective-C typedef void in Swift
I am using an Objective-C API in a new Swift environment. For the most part everything is working great but I'm getting stuck on a typedef issue.
The API has a typedef defined as:
typedef void* TESTHANDLE;
Usually in Objective-C I'd simply use this like declaring any kind of variable:
TESTHANDLE New...
0
votes
0
answer
6
views
Python - Django 1.5 Is there a possible workaround to fix database error
Im working a school management project and I integrated a forum app. It now pushes a database error even after I migrated / synced the database. Are there possible workarounds?
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/forums/category/add/
Django Version: 1.5.12
Excepti...
1
votes
1
answer
1.6k
views
How to get backend instance from python-social-auth
I am currently using python-social-auth and added a backend MyOAuth which BaseOAuth1, inside the BaseOAuth1 class there is a handy oauth_request instance method which I would like to make use of outside of the class.
https://github.com/omab/python-social-auth/blob/master/social/backends/oauth.py
I t...
0
votes
1
answer
1.3k
views
How do I add back elements with GWT after removing them with DOM.removeChild()?
I am using GWT 2.5 for an application. I have some static HTML with a specially named div, and I am using HTMLPanel.wrap() to replace that div with a GWT login panel. Once the user logs in I am using DOM.removeChild() to remove all the static elements from the page and use nothing but GWT widgets. T...
1
votes
1
answer
3.9k
views
Event handler function to wxButton with Bind() - wxWidgets 3.0
I am trying to create a simple, basic application to start off with wxWidgets. I can already set up a frame and put menu, menu items and buttons on it and it all displays properly.
However I have troubles using Bind() to attach an event handler to the button. To strip the code a bit, I have this :...
0
votes
1
answer
9
views
New to SignalR, is there a way to broadcast to others WHILE a user is doing an action, not just when they start and finish?
So what I'm trying to do, and I've made a small example project here, is when a user is editing a cell in a table, the cell disables for everyone else on that page. All good. Here I set it up so that when the user enters a cell, it disables for everyone else, and on blur/exiting the cell, it clears....
0
votes
0
answer
5
views
mongodump for collection larger than ram
I am using a command like this to dump data from a remote machine:
mongodump --verbose \
--uri='mongodb://mongousr:[email protected]:27017/somedb?authSource=admin' \
--out='$BACKUP_PATH'
This fails like so:
Failed: error writing data for collection `somedb.someCollection` to disk: error r...
1
votes
2
answer
461
views
Wrapping third party JS libraries in ReactJS
I am trying to learn how to use 3rd party APIs like Google Map, or BrainTree Dropin UI, and make them into ReactJS components.
Along my research, I came across such an example of a project that wraps the Braintree (payment gateway) - https://github.com/Cretezy/braintree-web-drop-in-react/blob/master...
1
votes
4
answer
603
views
Is golang defer statement execute before or after return statement?
I have a question about golang defer: Is golang defer statement execute before or after return statement?
I have read Defer_statements. But I do not got the answer.
I made a simple test:
func test1() (x int) {
defer fmt.Printf('in defer: x = %d\n', x)
x = 7
return 9
}
func test2() (x int) {
defer fu...
1
votes
2
answer
62
views
Spring validator custom HTTP status
I'd like to return a custom HTTP status 422 instead of a default 400 on a spring validation.
My validator:
@Component
@RequiredArgsConstructor
public class EmailUpdateDtoValidator implements Validator {
private Errors errors;
private EmailUpdateDto emailUpdateDto;
@Override
public boolean supports(C...
1
votes
1
answer
133
views
How to access a variable that was created in a transaction?
I'm using rails 4.2
I have two db calls that both need to exist OR both not exist, so I'm using transactions inside a method in order to do that. I also want the variable I am creating to be accessible by other places in the same method. Do I just need to use an instance variable instead of a local...
1
votes
3
answer
53
views
How to use asyncstorage in ReactNative
I made localstorage in ReactJS that works well.
But I want to use this code to React-native.
I am confused how I can apply to
This code is of ReactJs.
...
componentWillMount(){
const contactData = localStorage.contactData;
if(contactData){
this.setState({
contactData:JSON.parse(contactData)
})
}
}
....
1
votes
4
answer
101
views
Split multiple csv files by value from one csv file with c#
I need to open a csv file. Than I need filter each data and generate an output for each value of them.
◘ Example
•Input file = 'full list.csv'
NAME CITY
Mark Venezia
John New York
Lisa San Miguel
Emily New York
Amelia New York
Nicolas Venezia
Bill...
1
votes
2
answer
72
views
optimisation advice on value clamping in a loop
I have a tight loop exactly like what Chandler Carruth presented in CPP CON 2017:
https://www.youtube.com/watch?v=2EWejmkKlxs
at 25 mins in this video, there is a loop like this:
for (int& i:v)
i = i>255?255:i;
where v is a vector. This is exactly the same code used in my program which after profili...
1
votes
2
answer
31
views
Replacing null checks using ploymorphism
Recently I was reading through the book 'clean code' by Robert Martin, and in chapter 7 there was a section where he said you should try to replace null checks using the special case design pattern. I thought this was a great idea but then I thought about the following instance.
foreach(thing in so...
1
votes
2
answer
56
views
Retrieving recursively all elements in a list
I have a class 'Job' defined like this :
public class Job extends AbstractJob
{
private String name;
private String jobCount;
private String status;
private List children;
public Job(String name, String jobCount, String status, List children) {
this.name = name;
this.jobCount = jobCount;
this.status...
1
votes
1
answer
59
views
How to speed up a http c server on larger payload?
I have a http c server I got from https://rosettacode.org. I tried to test it for typical web page sizes on text payloads of 1MB to 3MB. However, it seems that as payload increases, the server performance decreases in terms of the maximum possible request/s it can handle.
What I am expecting is that...
1
votes
2
answer
41
views
Do git commits ever get deleted after resetting the branch?
Let's say I only have master branch, and I have made some commits: commit 1, 2 and 3.
If I do a git reset --hard to commit 2, then push and keep on committing code. Will commit 3 stay in the git database forever or will be deleted eventually?
2
votes
0
answer
14
views
Strings with newlines should not treated as numbers
I don't want strings with newlines treated as numbers.
This should be considered a string
notes = '3
';
The newline is preserved
|#notes#|
Number: #isNumeric(notes)#
|#replacelist(notes, chr(10) , '\n') #|
Number: #isNumeric(notes)#
1
votes
1
answer
48
views
How to wrap an OCaml expression with unit ()?
The following expression 3 ; () in utop results in the below response
utop # 3 ; ();;
Characters 0-1:
Warning 10: this expression should have type unit.
Characters 0-1:
Warning 10: this expression should have type unit.
- : unit = ()
How can we make a non-unit expression (like 3) return unit to work...
0
votes
0
answer
9
views
Getting past a login page in order to webscrape using JSoup
Sorry in advance if I am going about this completely wrong, as I am very new to jSoup.
I am trying to login to my school's grade website in order scrape grade data from it and display it in a program. The link to the login portal is 'https://portal.mcpsmd.org/public/' however the page I am trying to...
1
votes
2
answer
1.5k
views
jQuery slideUp and slideDown but with fadeOut and fadeIn?
i have done an Accordion style jQuery function which works lovely, but would like to add to it fadeOut and FadeIn here is the part of the code:
$('.product-accordion-trigger').click(function(){
if( $(this).next().is(':hidden') ) {
$('.product-accordion-trigger').removeClass('active').next().slideUp(...
1
votes
5
answer
8.2k
views
Styling <li> with background images in an <ul>
I'm setting up a footer for a site and using an unordered list with three list items as follows:
I am trying to use background images for the list items to display the social media icons and then I would like to apply a hover state to the list item for the button's 'on-state'. However, my three ico...
3
votes
0
answer
72
views
How do I get more debug information out of i18next?
I have upgraded an app from using webpack-i18n for translations to using i18next (13.1.5). For the most part, everything worked, but on one particular page, none of the text from one of my ejs files is loading. The js file for that page makes a few calls to i18next.t under specific circumstances, an...
1
votes
3
answer
1.1k
views
Ruby Data Structure - Queue with Maximum
I'm looking for a Ruby data structure with the following characteristics and am hoping to not have to roll my own:
First-in-first-out (i.e. a queue)
Allows specifying a max length
When the queue reaches capacity, the new item is pushed in and the oldest item is discarded.
I thought SizedQueue might...
1
votes
1
answer
1.8k
views
Bash Script to install PostgreSQL - Not working
I have a script which runs when my debian 6.0 server is deployed and it is designed to build postgreSQL from source, create a system user for it, create a database and start it running. I am new to this but I did a lot of homework and this is what I came up with:
# Initial
apt-get update
apt-get -y...
5
votes
5
answer
112
views
Does {m,n}? regex actually minimize repetitions or does it minimize number of characters matched?
According to the Python3 Regex documentation:
{m,n}?
Causes the resulting RE to match from m to n repetitions of the
preceding RE, attempting to match as few repetitions as possible. This
is the non-greedy version of the previous qualifier. For example, on
the 6-character string 'aaaaaa', a{3,5} wil...
1
votes
0
answer
374
views
React Native expo there was a prob loading this experience
When i run 'exp start' from command line. my react native app builds perfectly on simulator and on device. i also ran exp start --no-dev which i assumed was to show what would run with dev mode flag off when i run exp publish. When i run 'exp publish' i get
There was a problem loading this experienc...
1
votes
1
answer
456
views
VueJS, Apollo, Rails - Can't verify CSRF token authenticity
Here is my setup
const token = $('meta[name='csrf-token']').attr('content');
const authLink = setContext((_, { headers }) => {
// return the headers to the context so httpLink can read them
return {
headers: {
...headers,
credentials: 'same-origin',
'X-CSRF-Token': token,
'authenticity_token': token...
1
votes
0
answer
44
views
0
votes
0
answer
3
views
How do I install Dotfuscator in Visual Studio for Mac?
I'm currently using MacOS for my C# development environment, and have been pretty satisfied with the packages available. However, since my codebase is proprietary, my coworkers recommended that I obfuscate the code using Dotfuscator. I've gone over the Microsoft documentation for direct installation...
1
votes
0
answer
171
views
How CNNs achieve spatial invariance despite having a Fully Connected layer at the end for classification?
An image of a dog should be learnt by the network as being a dog irrespective of the spatial position and or rotation (maybe even deformation?). My question is how CNNs are able to achieve this? The convolution operations on input image successfully detect a feature that is characteristic of a parti...
1
votes
2
answer
239
views
Moving the Git Repository to a Child Folder
I'm using Github with my Wordpress website.
Currently it tracks the parent Wordpress folder, which essentially tracks everything.
I'd like it instead to have a git with only the theme, which is located at wp-content/themes/lighthouse
Is there a simple way to have this repository only be the theme r...