WhereIsAI/github-issue-similarity huggingface dataset:
Issue 1:
In other languages like C++, Java, C# etc dependency injection can be a big pain; you want your class Foo to use class Bar in production, but class MockBar in tests. This is usually enabled by explicit dependency injection support in class Foo (through ctor/setter/interface injection) and the code that uses Foos. It's a fairly big hassle and requires a ton of boilerplate code.

I'd like to see Rust provide compiler-level support for swapping types when cfg(test). Something like this:

#[cfg(test)]
mod testmod {
struct MockBar {
...
}

#[test]
#[swap(Bar, MockBar)]
fn testfunc() {
// Foo::new() now creates MockBars instead of Bars internally
let foo = Foo::new();
assert_eq!(foo.frobulate(), 5);
}
}

The idea is to swap any uses of Bar with MockBar in all the code that's executed through the annotated test function. The beauty lies in not having to mangle the production code just so we can isolate only the parts we want to test.

I'm not sure how difficult it would be to implement this and I don't have this idea fully fleshed out, but the gist should be apparent. It doesn't even have to be an attribute; frankly I don't care how this is implemented as long as I can replace one type with another type that implements the same interface[s] for the purpose of test code and that I don't have to change the production code to do it.

Any such support should of course only work when cfg(test). Enabling this in production code would IMO be a bad idea.

EDIT: Forgot to mention, being able to swap functions in this way and not just types would make this feature even more awesome.

Issue 2:
struct Foo<'a> {
_s: &'a str
}

struct Bar<H: Handler> {
handler: H
}

trait Handler {
fn handle<'a>(&'a self, foo: Foo<'a>);
}

impl<F> Handler for F where F: Fn(Foo) {
fn handle<'a>(&'a self, foo: Foo<'a>) {
self(foo)
}
}

fn main() {
let foo = Foo { _s: "foo" };
let bar = Bar { handler: |_f /*: Foo*/| {} }; // uncomment to work
(bar.handler)(foo);
}

Gives:

error: type mismatch: the type `[closure test.rs:8:23: 20:6]` implements the trait `core::ops::Fn<(_, _)>`, but the trait `for<'r,'r,'r> core::ops::Fn<(hyper::server::request::Request
<'r, 'r>, hyper::server::response::Response<'r>)>` is required (expected concrete lifetime, found bound lifetime parameter ) [E0281]

Playpen: http://is.gd/E7sskd

Couldn't tell if this was #16473, @reem thinks it might be different. Either way, this hurts using hyper's server easily: Server::http(|req, res| {}).listen(8080).
Issue 1:
Challenge Size your Images has an issue.

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36.

Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}

.smaller-image {
width: 100px;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image" src="https://bit.ly/fcc-relaxing-cat" />

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Issue 2:
It seems I don't have any problem in this code, what is the problem?

<style>
.red-text {
color: red;
}

.smaller-image{
width: 100px;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
</style>

CatPhotoApp

Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.

Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.
Issue 1:
Migrated issue, originally created by Adrian (@thiefmaster)

from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base

def _column_names(constraint, table):
return '_'.join((c if isinstance(c, basestring) else c.name) for c in constraint.columns)

naming_convention = {
'fk': 'fk_%(table_name)s_%(column_names)s_%(referred_table_name)s',
'ix': 'ix_%(table_name)s_%(column_names)s',
'column_names': _column_names,
}

Base = declarative_base()
Base.metadata.naming_convention = naming_convention

class A(Base):
__tablename__ = 'test_very_long_name_abcdefghijklmnopqrstuvwxyz'
__table_args__ = Index(None, 'abcdefghijklmnopqrstuvwxyz'),

id = Column(Integer, primary_key=True)
abcdefghijklmnopqrstuvwxyz = Column(Integer)

class B(Base):
__tablename__ = 'test_very_long_name_abcdefghijklmnopqrstuvwxyz_b'

id = Column(Integer, primary_key=True)
abcdefghijklmnopqrstuvwxyz = Column(Integer, ForeignKey('test_very_long_name_abcdefghijklmnopqrstuvwxyz.id'))

e = create_engine('postgresql:///test', echo=True)
Base.metadata.create_all(e)
raw_input('check the names...')
e.execute('DROP TABLE test_very_long_name_abcdefghijklmnopqrstuvwxyz, test_very_long_name_abcdefghijklmnopqrstuvwxyz_b')

This results in the following SQL (removed unrelated parts):

CREATE INDEX ix_test_very_long_name_abcdefghijklmnopqrstuvwxyz_abcde_5f65 ON test_very_long_name_abcdefghijklmnopqrstuvwxyz (abcdefghijklmnopqrstuvwxyz)

CREATE TABLE test_very_long_name_abcdefghijklmnopqrstuvwxyz_b (
...
CONSTRAINT fk_test_very_long_name_abcdefghijklmnopqrstuvwxyz_b_abcdefghijklmnopqrstuvwxyz_test_very_long_name_abcdefghijklmnopqrstuvwxyz FOREIGN KEY(abcdefghijklmnopqrstuvwxyz) REFERENCES test_very_long_name_abcdefghijklmnopqrstuvwxyz (id)
)

SQLAlchemy properly truncates the index name and appends a hash for uniqueness, but the constraint name is left unmodified, resulting in Postgres truncating it to 63 characters (without adding a hash to the end to ensure uniqueness).

I think this behavior is quite inconsistent and may even result in problems depending on the structure since it may result in two truncated names being the same even though they were different before. It's also somewhat ugly in Alembic migration scripts as you'll have to use op.f('...') for the index to ensure it's truncated by SA while it's optional for FK names since they are not touched even if too long.

Issue 2:
Migrated issue, originally created by whereswalden

Currently, MetaData.naming_convention does not support composite indexes or foreign keys, so those must be named explicitly. It'd be nice to be able to provide a template for those to be automatically named as well.

It would likely be necessary for users to define a function to provide the name, since the constraint/index could include any number of columns, but a fairly simple example could be provided in the documentation that simply ','.join()s the column names.
Issue 1:
Preflight Checklist

I have read the Contributing Guidelines for this project.

I agree to follow the Code of Conduct that this project adheres to.

I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

Electron Version:

6.0.0-beta.13

Operating System:

Windows 10 (1903)

Last Known Working Electron version:

Expected Behavior

Use the worker in the background thread.

Actual Behavior

Webpack generated this 2 files:

dist_electron\index.js 2235.09 KiB 503.87 KiB
dist_electron\test.worker.js 0.01 KiB 0.03 KiB

It compiled successfully.

I use node 12.6.0 so i have worker_threads and vscode detect it fine.

BUT when i launch electron i get this:

App threw an error during load
ReferenceError: Worker is not defined
at new ./node_modules/worker-loader/dist/cjs.js!./src/test.worker.ts.module.exports (c:\Users\myname\Desktop\my-project\dist_electron\index.js:56406:3)
at Module../src/background.ts (c:\Users\myname\Desktop\my-project\dist_electron\index.js:60661:16)
at __webpack_require__ (c:\Users\myname\Desktop\my-project\dist_electron\index.js:20:30)
at Object.0 (c:\Users\myname\Desktop\my-project\dist_electron\index.js:60752:18)
at __webpack_require__ (c:\Users\myname\Desktop\my-project\dist_electron\index.js:20:30)
at c:\Users\myname\Desktop\my-project\dist_electron\index.js:84:18
at Object.<anonymous> (c:\Users\myname\Desktop\my-project\dist_electron\index.js:87:10)
at Module._compile (internal/modules/cjs/loader.js:815:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:677:32)

To Reproduce

npm install -g @vue/cli

vue create vue_app

cd vue_app

vue add electron-builder

In background.ts i add this:

import workerPath from "file-loader?name=[name].js!./test.worker";
import { Worker } from 'worker_threads';

const worker = new Worker(workerPath);

The file-loader module looks like this:

declare module "file-loader?name=[name].js!*" {
const value: string;
export = value;
}

The test.worker file is empty for the test.

The last step is: npm run serve:electron

TS Config:

{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"mocha",
"node",
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"es6",
"es7",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
]
}

Issue 2:
Issue Details

Electron Version:

v5.0.2

Operating System:

Windows 10

Expected Behavior

On app ready start nodejs worker which consoles string.

Actual Behavior

App crash immediately after run

To Reproduce

git clone https://github.com/BorysTyminski/electron-issue.git

cd electron-issue

npm install

npm run start

Additional Information

I used electron-forge to quick build app.
Issue 1:
fmt doc says: Scanf, Fscanf and Sscanf require newlines in the input to match newlines in the format; the other routines treat newlines as spaces.

The following program spits out error (should not according to doc):

package main

import (
"fmt"
"log"
)

func main() {
var a, b int
_, err := fmt.Sscanf("1\n2", "%d %d", &a, &b)
if err == nil {
log.Fatalf("got - %q, expected - %q", err, "unexpected newline")
}
}

on commit 335e44d

Issue 2:
I got different fmt.Scanf behavior depending on the line endings style.

My go version is go1.3.3 darwin/amd64 on a Mac with OSX 10.10

To reproduce the problem, here is a short go program:

package main

import "fmt"

func main() {
var steps, i int
fmt.Scanf("%d", &steps)

var a, b int
for i = 0; i < steps; i++ {
fmt.Scanf("%d", &a)
fmt.Scanf("%d", &b)
fmt.Println(a + b)
}
}

And an input file

2
2 5
4 8

go run test.go < input

I expect to see regardless of the line endings been \r\n or \n:

7
12

But I see

2
7

when in the input file the line endings are \r\n .

If the line endings are \n it works fine.
Issue 1:
On 0.7.0

using SparseArrays
m, n = 2, 2
A = ones(m, n)
B = ones(Int8, m, n)
C = sparse(1:min(m, n), 1:min(m, n), ones(Int8, min(m, n)), m, n);

julia> A
2×2 Array{Float64,2}:
1.0 1.0
1.0 1.0

julia> B
2×2 Array{Int8,2}:
1 1
1 1

julia> C
2×2 SparseMatrixCSC{Int8,Int64} with 2 stored entries:
[1, 1] = 1
[2, 2] = 1

I would expect (A .>= 0) .& (B .& 1 .== 1) .& (C .& 1 .== 1) to return either a BitArray or a SparseMatrixCSC of Bool-type (but not Any) entries. However,

julia> (A .>= 0) .& (B .& 1 .== 1) .& (C .& 1 .== 1)
2×2 SparseMatrixCSC{Any,Int64} with 2 stored entries:
[1, 1] = true
[2, 2] = true

Caching each term within parentheses first

I_A = A .>= 0
I_B = B .& 1 .== 1
I_C = C .& 1 .== 1
I_BC = (B .& 1 .== 1) .& (C .& 1 .== 1);

would produce

julia> I_A .& I_B .& I_C
2×2 BitArray{2}:
true false
false true

that is somehow inconsistent with

julia> (A .>= 0) .& I_BC
2×2 SparseMatrixCSC{Bool,Int64} with 2 stored entries:
[1, 1] = true
[2, 2] = true

Issue 2:
First of all, I'm no Julia expert, so please forgive me if this is user error.

Under the following circumstances, i am unable to use pmap to call an anon function within an anon function.

The following error is displayed:

UndefVarError: 27#54 not defined

in #26 at [file.jl:pmap line of code]

When running the following code:

pmap(arg -> method1(() -> method2(arg)), input_args_array, err_stop=true)

@everywhere function method1(sub_func)
sub_func()
end`

@everywhere function method2(arg)
println(arg)
end

Note this only occurs if I run up julia with -p 1. If i don't include -p 1 everything works fine.

This also only occurs with -p 1 if i use 2x anon funcs. If i do the following it works fine:

arg -> method1()

arg -> method1(method2)

Thanks,

Jon
Issue 1:
I completed HTML5 and CSS challenges, then it was marked completed, but when I saw today, its unmarked.

FreeCodeCamp Issue template

To Use this Template:

Fill out what you can

Delete what you do not fill out

NOTE: ISSUES ARE NOT FOR CODE HELP - Ask for Help at https://gitter.im/FreeCodeCamp/Help

Issue Description

When Issue Happens

Steps To Reproduce

Browser Information

Browser Name, Version

Operating System

Your Code

If relevant, paste all of your challenge code in here

Screenshot

Issue 2:
It's not possible to mark some Computer Basics as completed. I tried to complete them many times. No success.

Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36

OS: OS X 10.11.3

Screenshot:
Issue 1:
OpenAPI allows describing multiple accepted content-types for a request.

Is it possible via FastAPI means?

I'd like to make a password login endpoint accepting both application/json and application/x-www-form-urlencoded using a single handler.

Issue 2:
It seems that swagger interface cannot send Authorization header.

I added test_auth endpoint with required header authorization like that:

async def check_auth(
authorization: str = Header(...)
):
pass

@router.post("/test_auth")
async def test_auth(
auth = Depends(check_auth)
):
pass

This works perfectly if I use REST-client with set Authorization header. But, if I use swagger UI it seems that Authorization header always missing. Server responses with status code 422 and:

"detail": [
{
"loc": [
"header",
"authorization"
],
"msg": "field required",
"type": "value_error.missing"
}
]
}

Another observation is if I change the header name to something else (not authorization) it works. But my goal is using Authorization...

FastAPI version: 0.49.0
Issue 1:
I have a program based on electron8.2.5, read the local pictures dragged and previewed, everything works fine. But after upgrading to electron9.0.0 today, the picture preview does not show up. It looks as if the parameter ‘webSecurity: false’ does not work.

Issue 2:
Preflight Checklist

I have read the Contributing Guidelines for this project.

I agree to follow the Code of Conduct that this project adheres to.

I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

Electron Version: 9.0.0

Operating System: Windows 10 (1904)

Last Known Working Electron version: 8.2.0

Expected Behavior

Setting BrowserWindow webPreferences: { webSecurity: false } should disable the CORS policy

Actual Behavior

Although I am receiving the electron security warnings for "Disabled webSecurity","allowRunningInsecureContent" and "Insecure Content-Security-Policy" in the console I am still getting COR policy errors on my requests.

Here is an example:

Access to XMLHttpRequest at 'http://localhost:8080/users/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Issue 1:
hi, when I say install npm install package, it gives error. not loaded.

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:

npm ERR! https://npm.community

npm ERR! A complete log of this run can be found in:

what should I do?

Issue 2:
npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:

npm ERR! https://npm.community

npm ERR! A complete log of this run can be found in:

npm ERR! /home/festus/.npm/_logs/2019-11-10T20_01_15_638Z-debug.log

Has this issue been solved yet?
Issue 1:
TypeScript Version: 1.8.7

Code

function make_component<A, B extends A>(arg: () => B) {
}

h<{x: string}>(() => {
return {
x: "hello",
y: 10,
};
});

I have a function that produces a higher-order react component by taking a function that knows how to take a set of "external props", run a function taking the external props returning "computed props". The union of the external props and the computed props is a set of "internal props", which the internal React component can rely on.

I want the caller to specify just one of these property sets, and have everything else be inferred by the function argument passed in. The code above is a simplified example of this.

Note that only one type parameter is specified -- I would hope the second could be inferred by the function argument (like C++).

However, instead I get a "Supplied parameters do not match any signature of call target." error.

Issue 2:
TypeScript Version:

1.8.0

Code

interface Class<T> {
new(): T;
}
declare function create1<T>(ctor: Class<T>): T;
declare function create2<T, C extends Class<T>>(ctor: C): T;

class A {}
let a1 = create1(A); // a: A --> OK
let a2 = create2(A); // a: {} --> Should be A

Context

The example above is simplified to illustrate the difference between create1 and create2. I need both type parameters for the use case I have in mind (React) because it returns a type which is parameterized by both T and C:

declare function createElement<T, C extends Class<T>>(type: C): Element<T, C>;
var e = createElement(A); // e: Element<{}, typeof A> --> Should be Element<A, typeof A>

declare function render<T>(e: Element<T, any>): T;
var a = render(e); // a: {} --> Should be A

Again, this is simplified, but the motivation is to improve the return type inference of ReactDOM.render.
Issue 1:
TypeScript Version: 1.8.29.0 (default for Visual Studio 2015 Update 2)

Code

// worked on TS 1.8.4.0
let promises: Promise<number>[];
let promiseall: Promise<number[]> = Promise.all(promises)

Expected behavior: No compilation error.

Actual behavior:

Type 'Promise<Promise<number>[]>' is not assignable to type 'Promise<number[]>'.
Type 'Promise<number>[]' is not assignable to type 'number[]'.
Type 'Promise<number>' is not assignable to type 'number'.

Issue 2:
TypeScript Version:

1.8.9

Code

Promise.all([Promise.resolve('')]); // has type Promise<Promise<string>[]>

Expected behavior:

The expression has type Promise<string[]> as in 1.8.7

Actual behavior:

The expression has type Promise<Promise<string>[]>
Issue 1:
This issue seems to occur only when using a computed property in generator/async function and running in loose mode:

function *foo() {
return {
['x']: null
};
}

Compiles to:

var marked0$0 = [foo].map(regeneratorRuntime.mark);
function foo() {
return regeneratorRuntime.wrap(function foo$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
return context$1$0.abrupt('return', (_ref = {}, _ref.x = null, _ref));

case 1:
case 'end':
return context$1$0.stop();
}
}, marked0$0[0], this);
}

Note that _ref is used but never declared. With a regular function, this compiles correctly to:

function foo() {
var _ref;

return (_ref = {}, _ref.x = null, _ref);
}

PS I couldn't figure out how to add this as a test case. Adding to fixtures/esnext/es6-computed-properties seems like the right thing, but how do I get this to compile in loose mode?

Some guideline in CONTRIBUTING.md would help.

Also, can't make test figure out all the dependencies (that it needs to build lib/acorn)?

Issue 2:
function *x() {
[].concat(...[])
}

-->

function x() {
return regeneratorRuntime.wrap(function x$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
(_ref = []).concat.apply(_ref, []);

case 1:
case "end":
return context$1$0.stop();
}
}, marked0$0[0], this);
}

note the undeclared _ref.

Previously: #438, #803
Issue 1:
When im going to the next challenge and have to type in the note pad document, i cant click the cursor and start typing where it wants me to. i have to hit enter or something first then the cursor will allow me to click anywhere in the document to start typing my challenge.

Challenge Create a Set of Radio Buttons has an issue.

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36.

Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}

.smaller-image {
width: 100px;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#">cat photos</a>.</p>

<a href="#"><img class="smaller-image thick-green-border" alt="A cute orange cat lying on its back" src="https://bit.ly/fcc-relaxing-cat"></a>

<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
<form action="/submit-cat-photo">
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>

Issue 2:
In all the exercises, we the users are forced to press the enter key before writing any code.

Update:

We have locked the conversation temporarily on this thread to collaborators only, this has been resolved in staging, and will be live soon.

The fix can be confirmed on the beta website.

The workaround currently on production website is:

Press the Enter key on the challenge editor and then proceed with the challenge.

Apologies for the inconvenience meanwhile.

Reach us in the chat room if you need any assistance.
Issue 1:
I have searched the issues of this repository and believe that this is not a duplicate.

The following code

<Hidden lgDown implementation="css" />

will render CSS code

@media (max-width:1279.99px) {
.MuiHiddenCss-lgDown-116 {
display: none;
}
}

which is matched on Safari with 1280px width.

You can test on browser console:

window.matchMedia('(max-width:1279.99px)').matches

It returns true on Safari but false on Chrome and Firefox

Expected Behavior

Drawer should not disappear on screen with 1280px wide.

Current Behavior

If you go to v1 docs on Safari, you'll see that the drawer is missing.

Steps to Reproduce (for bugs)

Open Safari

Go to https://material-ui-1dab0.firebaseapp.com/getting-started/installation/

Change browser to 1280px width

Sidebar disappear

Your Environment

Tech
Version

Material-UI
v1.0.0-beta.18

browser
Safari 11.0.1

OS
macOS 10.13.1 beta

Issue 2:
Can not format textField of type date in the form 'DD/MM/YYYY'. The options for type are limited. Why not have a format field

I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

TextField should have a format prop that will help format date in any format. eg.

<TextField
onChange={onDateChange}
id="date"
label="Date Received"
type="date"
format={'DD/MM/YYYY'}
value={dateRecieved}
className={classes.textField}
margin="normal"
InputLabelProps={{
shrink: true
}}
/>

Current Behavior

Currently the type options doesn't allow to format in DD/MM/YYYY form.

Your Environment

Tech
Version

Material-UI
1.0.0-beta.32

React
3.7.2

browser
chrome

etc