instruction stringlengths 0 30k β |
|---|
Redirect Users to another website using GAS |
|html|google-apps-script|redirect|url-shortener| |
In my Pine Script strategy function, I set the following parameters:
```pine
strategy("XXX", overlay=true,
initial_capital = 1000,
default_qty_value = 50,
default_qty_type = "percent_of_equity",
pyramiding = 4,
commission_type = "percent",
commission_value = 0.05,
slippage = 0,
process_orders_on_close = false,
margin_long = 25,
margin_short = 0,
calc_on_order_fills = true,
calc_on_every_tick = false,
use_bar_magnifier= true)
```
I set `calc_on_order_fills = true` and `calc_on_every_tick = false`. However, I noticed that TradingView alerts are being executed in real time as if `calc_on_every_tick = true`.
I expect TradingView alerts to be executed in real time as if `calc_on_order_fills = true` to avoid missing the optimal timing to trade. |
TradingView alerts are not being executed by strategy() |
|pine-script|alert|tradingview-api| |
<s>Most likely the `int32_t * SIZE` in the `malloc` call. If you use a bit-shift like `SIZE << 2` instead, your code should be much faster and more efficient.</s>
OK, in all seriousness, `a_ptr`, `b_ptr`, and `c_ptr` are all separate blocks of memory. In your loop you are accessing one, then the other, then the other, then repeating. I hear that is like bad for cache or something, because you are jumping around in memory, instead of accessing them sequentially. |
I wish to merge `df1` and `df2` to `df3` and keep order. my demo code add `sort=False` but it not work as expected.
```
import pandas as pd
data1 = [
['4A', 1],
['3B', 2],
['2C', 3],
['1D', 4],
]
data2 = [
['2C', 9],
['4A', 3],
['6F', 2],
['5G', 1],
]
df1 = pd.DataFrame(data1, columns=['name', 'value'])
df2 = pd.DataFrame(data2, columns=['name', 'value'])
df3 = pd.merge(df1, df2, how='outer', on='name', sort=False)
df3 = df3.rename({'value_x': 'v1', 'value_y': 'y2'}, axis=1)
print(df1)
print(df2)
print(df3)
```
Output:
```
name value
0 4A 1
1 3B 2
2 2C 3
3 1D 4
name value
0 2C 9
1 4A 3
2 6F 2
3 5G 1
name v1 y2
0 1D 4.0 NaN
1 2C 3.0 9.0
2 3B 2.0 NaN
3 4A 1.0 3.0
4 5G NaN 1.0
5 6F NaN 2.0
```
Expected output:
```
name v1 y2
0 4A 1.0 3.0
1 3B 2.0 NaN
2 2C 3.0 9.0
3 1D 4.0 NaN
4 6F NaN 2.0
5 5G NaN 1.0
``` |
I am trying to study the dynamics of a charged particle inside potential fields. I tried defining a dummy potential like this:
```
x = np.linspace(-20, 20, 10)
y = np.linspace(-20, 20, 10)
z = np.linspace(0, 10, 10)
X, Y, Z = np.meshgrid(x, y, z)
V = X**2 + Y**2 + Z**2
```
and I used gradient function to get Electric field at each point.
```
Ex, Ey, Ez = np.gradient(V)
```
This gives me a (10,10,10) 3d array. Now the problem arises when I am studying the motion of a particle with some mass in this vector field.
For example, my force is defined like this:
```
f_e[i][0] = -Q * Ex_at_r # Ex but at that r_x value particle is currently
f_e[i][1] = -Q * Ey_at_r
f_e[i][2] = -Q * Ez_at_r
```
When it comes to forces like gravity you don't need to worry about all this I can just have a 1-D array like this `f_g = np.array([0,0,-g])` and call it day, but my f_e is changing as the particle moves. I already tried defining f_e like this, `f_e_x = -Q*r[i][0] # X_component of position vector for ith iteration`, and this sort of works but this still isn't same as having a vector field and a charge thrown in it.
Is there a standard way to go about this? |
How to throw a charged particle in a electric vector field? |
You could use [`top_k`](https://docs.pola.rs/py-polars/html/reference/dataframe/api/polars.DataFrame.top_k.html) and slice the last row:
```
import polars as pl
np.random.seed(0)
df = pl.DataFrame({'col': np.random.choice(5, size=5, replace=False)})
out = df.top_k(2, by='col')[-1]
```
You could also [`filter`](https://docs.pola.rs/py-polars/html/reference/dataframe/api/polars.DataFrame.filter.html) with [`rank`](https://docs.pola.rs/py-polars/html/reference/expressions/api/polars.Expr.rank.html), but this will perform a full sort, so it could be algorithmically less efficient:
```
out = df.filter(pl.col('col').rank(descending=True)==2)
```
Output:
```
shape: (1, 1)
βββββββ
β col β
β --- β
β i64 β
βββββββ‘
β 3 β
βββββββ
```
Input:
```
shape: (5, 1)
βββββββ
β col β
β --- β
β i64 β
βββββββ‘
β 2 β
β 0 β
β 1 β
β 3 β
β 4 β
βββββββ
```
##### timings:
1M rows
```
# top_k
39.3 ms Β± 7.23 ms per loop (mean Β± std. dev. of 7 runs, 10 loops each)
# filter+rank
54.6 ms Β± 8.58 ms per loop (mean Β± std. dev. of 7 runs, 10 loops each)
```
10M rows:
```
# top_k
427 ms Β± 84.8 ms per loop (mean Β± std. dev. of 7 runs, 1 loop each)
# filter+rank
639 ms Β± 102 ms per loop (mean Β± std. dev. of 7 runs, 1 loop each)
``` |
I have been asked in one of the Top company below question and I was not able to answer.
Just replied : I need to update myself on this topic
**Question :**
**If you create a composite indexing on 3 columns (eid , ename , esal ) ?**
- If i mention only eid=10 after where clause will the indexing be called ?
`select * from emp where eid=10`;
- If I mention only eid=10 and ename='Raj' will the indexing be called ?
`select * from emp where eid=10 and ename='Raj';`
- If I mention in different order like esal=1000 and eid=10 will the indexing be called ?
`select * from emp where esal=1000 and eid=10;`
- If I mention in reverse order like esal = 1000 and ename = 'Raj' and eid = 10 will the indexing be called ?
`select * from emp where esal=1000 and enam='Raj' and eid=10;`
Need a solution for this with detail table representation with data how it does?
|
`make menuconfig` allows to tweak the Buildroot configuration, no the Linux kernel configuration. To tweak the Linux kernel configuration, run `make linux-menuconfig`, which will fire up the menuconfig of the Linux kernel.
See https://bootlin.com/doc/training/buildroot/buildroot-slides.pdf starting slide 76 for more details on the Linux kernel configuratiojn |
I have been asked in one of the Top company below question and I was not able to answer.
Just replied : I need to update myself on this topic
**Question :**
**If you create a composite indexing on 3 columns (eid , ename , esal ) ?**
- If i mention only eid=10 after where clause will the indexing be called ?
`select * from emp where eid=10`;
- If I mention only eid=10 and ename='Raj' will the indexing be called ?
`select * from emp where eid=10 and ename='Raj';`
- If I mention in different order like esal=1000 and eid=10 will the indexing be called ?
`select * from emp where esal=1000 and eid=10;`
- If I mention in reverse order like esal = 1000 and ename = 'Raj' and eid = 10 will the indexing be called ?
`select * from emp where esal=1000 and enam='Raj' and eid=10;`
Need a solution for this with detail table representation with data how it does?
Will upvote the great solution you provide |
{"Voters":[{"Id":14732669,"DisplayName":"ray"},{"Id":17562044,"DisplayName":"Sunderam Dubey"},{"Id":839601,"DisplayName":"gnat"}]} |
Currently my project uses OpenCV to process pictures, draw some information and then push the video frames out through ffmpeg, because it is a live streaming form of pushing, the processing speed of a single frame is very high, the processing speed is slow, it will lead to push out the video stream dropped frames. After troubleshooting, the more time-consuming process is the process of drawing Chinese characters. Because OpenCV does not support drawing Chinese characters, I use Pillow to convert the image format every time I draw, and then convert the Pillow image back to numpy format after drawing. The following are the key code steps to draw Chinese characters:
```python
cv2_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
pil_img = Image.fromarray(cv2_img)
draw = ImageDraw.Draw(pil_img)
font = ImageFont.truetype("simhei.ttf", 15, encoding="utf-8")
delta_y = 20
draw.text((x, y + delta_y), f"δΈζxxxxx", (255, 255, 255), font=font)
img = cv2.cvtColor(np.array(pil_img), cv2.COLOR_RGB2BGR)
```
The following solutions are known to work:
1. All drawing is done using Pillow (including drawing rectangular boxes, line segments, etc.)
2. Compile the OpenCV package that includes the freetype module. Compile OpenCV packages that include the freetype module.
For the two solutions I proposed, it may not be very easy to deal with them due to some complicated reasons:
1. The drawing in the code is cross-drawing, OpenCV -> Pillow -> Opencv ...... The amount of changes would be larger if Pillow was used exclusively for drawing.
2. I am compiling OpenCV-python with freetype module, but even if it is compiled successfully, it will encounter some cross-platform porting, cross-version use and a series of problems, which can only be solved by recompiling, and the program is only used as a back-up program to The program is currently only used as an alternate solution.
Of course there are other solutions, if there is a program that meets my high processing speed requirements, welcome to the big brother to give reference. |
null |
I'm not sure what the nday() stands for, but I guess you are doing a count down for button to be enable, if that case, try the code below:
```
setTimeout(() => {
localStorage.removeItem("color");
localStorage.removeItem("name");
done11.style.backgroundColor = "white";
done11.innerText = "Claim";
}, Date.now() - see);
// You have already initialised a variable see with nday() value, might as well reuse it here
``` |
I am trying to learn the dataverse API using C#. I am following the code in this github: https://github.com/microsoft/PowerApps-Samples/blob/master/dataverse/orgsvc/C%23-NETCore/GetStarted/ConsoleApp%20(public)/Program.cs
I changed the login information and the appID to my app registration's client id and added a redirect URL of http://localhost.
The app registration does have API permissions to Dynamics CRM.
However, I still get an error of: `Original exception: AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'`.
This is my connection string:
```
static string connectionString = $@"
AuthType = OAuth;
Url = {url};
UserName = {userName};
Password = {password};
AppId = {appId};
RedirectUri = http://localhost;
LoginPrompt=Auto;
RequireNewInstance = True";
```
I cannot figure out what the issue is. Any help would be greatly appreciated. |
Connecting to Dataverse api in C# |
|c#|dataverse| |
Is there a way in vscode to after I type Ctrl + . and accept a correction with quick fix, to automatically run the key combo Alt+F8 to move to the next problem without having to?
I use a spelling extension and it to correct a word by selecting Ctrl+ . then selecting the correct suggestion. However after this selection I want it to automatically move to the next item in the problem list. Currently it doesn't do this but I have to Press Alt+F8 which is the default to open the next problem. Then I click Ctrl + . again to select which correction applies.
I am not sure why vscode doesn't have option to move automatically to the next problem after fixing the first. I looked at the settings and there isn't such an option.
Visual:
1. Have file with problems and Press Alt+F8 to navigate to first problem
[![enter image description here][1]][1]
Press Ctrl+ . and select a suggested correction from the list with mouse click or enter.
[![enter image description here][2]][2]
After correction with Ctrl+. the cursor stays on the corrected word and one has to manually click Alt+F8 again to to go to the next problem.
[![enter image description here][3]][3]
[1]: https://i.stack.imgur.com/I2tWE.png
[2]: https://i.stack.imgur.com/OdCXY.png
[3]: https://i.stack.imgur.com/tV13w.png |
In my research work, I want to do the vehicle survival fraction; survival rates were calculated using the log-logistic survival function. In equation two unknown parameters a, and b are obtained by minimising the sum of squared errors between the experimental and modelled. The equation of the model is:
S = [1 + (t/a)^b]^(-1)
age of the vehicle t = [0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20];
registered vehicles of respective age t, N = [6801342;6364669;6104616;5849372;5426898;4969076;4549439;4117610;3714272;3324896;2980512;2652830;2320935;2041282;1818527;1594733;1335572;1053197;800212;566590;376620];
experimental value u_exp = [406183941.2;270789294.1;812367882.4;541578588.2;406183941.2;1353946471;406183941.2;135394647.1;135394647.1;135394647.1;676973235.3;270789294.1;406183941.2;0;270789294.1;406183941.2;0;135394647.1;0;0;135394647.1];
u_mod = ((1+(t./a).^a).^(-1))*N; (modeled value = S*N)
and I want to calculate the parameters βaβ and βbβ by minimizing the sum of squared errors between βn expβ and βn modelβ.
Someone here can help me by writing the Matlab code, please?
Thank you already for your help! |
I have enabled Http2 in Azure portal in Application gateway configuration.
Also, I am accessing it using https and have min version set to TLS 1.2
Still, when accessing it from browser, Chrome dev tools report protocol http 1.1 is being used.
Am I missing something? |
Azure Application Gateway http/2 not working |
|azure|azure-application-gateway| |
|excel|vba|macos|excel-tables|listobject| |
You can also use 'non-null assertion operator' which is used if the typescript compiler complains about a value being null or undefined , you can use the ! operator to assert that the said value is not null or undefined .
*ngIf="cardForm.controls.name.errors!['required']" |
I dont really know how to code lua, i made a script, when "Numlock" is on the script clicks "a" for a random time duration, then releases "a" and it presses "s" for random time. repeats the script until numlock is turned off. it doesnt work tho..
> function OnEvent(event, arg)
OutputLogMessage("wawa")
if event == sKeyLockOn("Numlock") then
repeat
PressKey("a")
Sleep(math.random(8700, 8900))
ReleaseKey("a")
Sleep(2)
PressKey("s")
Sleep(math.random(8700, 8900))
ReleaseKey("s")
Sleep(2)
until not IsKeyLockOn("Numlock")
end
end
i tried putting the mouse button instead of the numlock but nothing works.. |
LGHUB LUA script |
|lua|logitech|logitech-gaming-software| |
null |
I don't know if this helps, but I encountered something similar to this issue earlier this week. I couldn't figure out why my receipts weren't being cut by a USB POS printer consistently. Sometimes they would, sometimes they wouldn't. It dawned on me that my Golang program might be executing too quickly, clearing the buffers and terminating before the printer had received all the necessary commands. So, I decided to introduce a short delay (because sync does not work like the OP said) for testing purposes, and it worked.
So, I'm leaving this comment here in case someone else encounters the same issue. |
|excel|vba|autofilter|excel-tables|listobject| |
Maybe it would be useful for you to import the images and not use the path.
<script setup>
import image1 from '../../assets/images/image1.png'
import image2 from '../../assets/images/image2.png'
const imageSource = computed(() => {
return isBlue.value ? image1 : image2
})
</script>
|
I'm using this solution by wOxxOm [here][1] to keep the service worker alive in my chrome extension (manifest v3).
I used the offscreen solution because I use win7 so I can only use chrome v109. it works very well, but when the PC hibernate then wake up, the service worker will restart with a probability of 50%. for example if I hibernate after 10s and wake up after 10s then the SW will restart always...
This problem does not happen in my tests when I use background scripts using manifest v2 with `"persistent" : true`
Is there something I can do to make the SW persistent (not restart after hibernation) as in MV2?
I tested other solutions but none worked, for example I discovered that I can make the SW persistent using alarms too:
```javascript
// keep SW alive for 30s
// self.serviceWorker.postMessage('test')
// this will keep SW alive for 5min then chrome will kill it, to prevent this kill we will run alarm every 4min
// we run setInterval every 20s to prevent SW sleep in the first minute
setInterval(()=>{self.serviceWorker.postMessage('test');console.log("___________postMessage every 20 seconds");},20000);
chrome.runtime.onInstalled.addListener(() => {
chrome.alarms.create('keepAlive', { periodInMinutes: 4 });
});
chrome.alarms.onAlarm.addListener((info) => {
if (info.name === 'keepAlive') {
self.serviceWorker.postMessage('test');
console.log("++++++++++++alarm every 4 min");
}
});
```
But it did not solve the hibernation problem too. I'm out of ideas, any idea please?
is this problem solved in newer chrome versions? i have only win7 i cannot test the newer chrome versions unfortunately.
[1]: https://stackoverflow.com/questions/66618136/persistent-service-worker-in-chrome-extension/ |
I am new to Flask and JavaScript, so help would be appreciated. I am making a mock draft simulator, and I have a function that contains a for loop, that simulates a selection for each team, adds the pick to a dictionary, and after the loop breaks, the dictionary is sent to JavaScript.
```
@app.route('/simulate-draft' , methods=['POST'])
def simulate_draft():
# Get info from user and send to JavaScript
if team == user_team:
#get pick from user
#append to draft_results
else:
#simulate pick
#append to draft_results
return jsonify(draft_results)
```
However, I want the selections to be sent to JavaScript one by one, so the team the user chose to select for can make their selection, instead of the whole dictionary being sent at the end of the function I have read that yield could be a potential solution for this, but I keep getting errors when implementing this. |
How can I update my Python app so my Flask function sends information to JavaScript without breaking the loop? |
|javascript|flask| |
null |
I am receiving the following error codes in my output. I am using Icarus Verilog, with VSCode as my IDE. Would anyone know how to resolve this?
**No top level modules, and no -s option.**
This issue has occurred in one other instance before and I was not sure how to proceed.
```
`timescale 1ns / 1ps
// Definition of the 8-bit combinational shifter module
module combinational_shifter(
input [7:0] A,
input [3:0] n,
input dir,
output reg [7:0] Y
);
always @(*) begin
if (dir == 1'b0) // If dir is 0, shift to the right
Y = A >> n;
else // Otherwise, shift to the left
Y = A << n;
end
endmodule
// Testbench module for the combinational shifter
module combinational_shifter_tb;
// Inputs to the shifter
reg [7:0] A;
reg [3:0] n;
reg dir;
// Output from the shifter
wire [7:0] Y;
// Instantiate the Unit Under Test (UUT)
combinational_shifter uut (
.A(A),
.n(n),
.dir(dir),
.Y(Y)
);
initial begin
// Initialize Inputs
A = 8'b10101010; // Example input to test
dir = 0; // Start with right shift
n = 0;
// Test all possible shifts
for (n = 0; n < 16; n = n + 1) begin
#10; // Delay to observe changes
$display("Right Shift: A = %b, n = %d, Result = %b", A, n, Y);
end
dir = 1; // Change to left shift
for (n = 0; n < 16; n = n + 1) begin
#10; // Delay to observe changes
$display("Left Shift: A = %b, n = %d, Result = %b", A, n, Y);
end
end
endmodule
```
|
I'm encountering an issue with Hibernate where I'm getting the following SQL error:
Please help me to resolve error
SQL Error: 0, SQLState: 42P01
ERROR: missing FROM-clause entry for table "th1_1"
Position: 14
I'm working on a Spring Boot application where I'm using Hibernate for ORM mapping. I have entities defined for dx_entity and dx_temporary_hazard, and I'm using a join strategy inheritance between them.
I'm attempting to retrieve data using Hibernate's findAll method.
@Getter
@Setter
@Entity
@Table(name = "dx_entity")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "table_name", discriminatorType = DiscriminatorType.STRING)
@Where(clause = "deleted_at is null")
@NoArgsConstructor
public class DxEntity extends MultiTenantEntity implements Serializable {
// Entity fields...
}
@Entity
@Table(name = "dx_temporary_hazard")
@Setter
@Getter
@DiscriminatorValue("dx_temporary_hazard")
public class TemporaryHazard extends DxEntity {
// Entity fields...
}
**test controller:
**
@RestController
public class TController {
private final TemporaryHazardRepository temporaryHazardRepository;
public TController(TemporaryHazardRepository temporaryHazardRepository) {
this.temporaryHazardRepository = temporaryHazardRepository;
}
@GetMapping("/test")
public Page<TemporaryHazard> test() {
return temporaryHazardRepository.findAll(PageRequest.of(0,20));
}
}
When we trigger /test controller, Quires performed in console:
SELECT th1_1.pk_id,
th1_0.changed_at,
th1_0.changed_by,
th1_0.created_at,
th1_0.created_by,
th1_0.created_layout,
th1_0.deleted_at,
th1_0.module_name,
th1_0.status,
th1_0.tag,
th1_0.tenant_id,
th1_0.updated_layout,
th1_1.abc,
th1_1.xyz,
th1_1.abc1,
th1_1.control_measures_required,
th1_1.xyz1,
th1_1.type
FROM PUBLIC.dx_entity th1_0
JOIN PUBLIC.dx_temporary_hazard th1_1
ON th1_0.pk_id=th1_1.pk_id
WHERE th1_0.tenant_id = ?
AND (
th1_0.deleted_at IS NULL)
AND th1_0.table_name='dx_temporary_hazard' offset ? rowsFETCH first ? rows only`
SELECT count(th1_1.pk_id)
FROM PUBLIC.dx_entity th1_0
WHERE th1_0.tenant_id = ?
AND (
th1_0.deleted_at IS NULL)
AND th1_0.table_name='dx_temporary_hazard'
**Error:**
SQL Error: 0, SQLState: 42P01
ERROR: missing FROM-clause entry for table
We can see that "th1_1.pk_id" is wrong alias name in count query. Hence query failing to return result.
I tried with hibernate 6.2.x and 6.4.x version, No luck |
How to Draw Chinese Characters on a Picture with OpenCV |
|python|opencv|python-imaging-library| |
null |
Suppose if we have two micro services communicating using spring Rest Template call and they are exchanging the request and response respectively.Now if I want to use the Kafka in between them to increase throughput. Is it possible to achieve this scenario?
I am able to publish the object as string and produce in Kafka and that is getting listened by the consumer. Now the consumed data is getting processed and sent to the different topic. Now the response should get return in the same function by which the message was produced and published. Is it possible to achieve this using spring Kafka.
How to achieve using request-response pattern. |
I have written a Fortran subroutine to compute the size of an array and I want to get the result directly in R. However, I do not get the expected result...
First I build the `size95.f95 file`
```
subroutine fsize(x, n)
double precision, intent(in):: x(:)
integer, intent(out) :: n
n = size(x)
end subroutine fsize
```
Then I compile it at CMD of Windows with
```
R CMD SHLIB size95.f95
```
Although, after I load and test it in R for a 10-element vector, I get length of 1 instead of 10. What just happened??
```
x <- 1:10
dyn.load("size95.dll")
dotCall64::.C64("fsize",
SIGNATURE = c("double", "integer"),
INTENT = c("r", "w"),
x=x, n=dotCall64::integer_dc(1))
# $x
# NULL
#
# $n
# [1] 1
```
The desired output should be
```
# $x
# NULL
#
# $n
# [1] 10
```
Thanks a lot! |
How to get size of array directly from Fortran to R? |
|r|fortran| |
null |
[![enter image description here][1]][1]I want to implement a feature where when I click on a specific sentence within this paragraph, the background color of that sentence changes.
I've tried looking into gesture detection and text selection features within Jetpack Compose, but couldn't find a straightforward way to achieve this effect. Can someone please guide me on how to implement this functionality?
[1]: https://i.stack.imgur.com/aSM44.png |
Hmm this is not really a NextJS issue, but a [CORS issue][1]. Client side request get's blocked directly by the browser since https://api.example.com does not allow cross-origin requests. Your localhost being not the same origin as example.com.
One way to fix it, usually 3rd party API's have a CORS management section where you can whitelist your localhost or your domain name for specific requests.
[1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS |
To achieve the menu popup functionality, you should prefer using the `checkbox input` of HTML alongside the `:checked` CSS property.
This would also help you to further add more functions w.r.t. the state of the input box, hence you will able to get an effect of `menu is open` or `menu is closed` as a property
Try following the given example:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
body {
user-select: none;
}
#content {
display: none;
width: 40%;
margin-top: 4px;
padding: 8px;
background: skyblue;
border-radius: 6px;
cursor: pointer;
}
label {
color: #292929;
cursor: pointer;
}
label:hover {
text-decoration: underline;
}
label:active {
color: black;
}
#toggle:checked+#content {
display: block;
}
#toggle {
/** display: none; (to hide the checkbox icon) **/
}
<!-- language: lang-html -->
<label for="toggle">Press here to show content</label>
<input type="checkbox" id="toggle">
<div id="content">
If pressed content is shown
</div>
<!-- end snippet -->
|
Minimize the sum of squared errors between the experimental and predicted data in order to estimate two optimum parameters by using matlab |
|matlab| |
null |
When using **kubectl get nodes**, the connection refused error you are experiencing is probably caused by the way your Ansible playbook handles the kubeconfig file.
**See how to resolve the problem and make calico deployment possible here.**
- Make sure the master node's Kubernetes API server is up and working by checking its port 6443 This can be accomplished by confirming that no firewall rules are preventing the connection and monitoring the kube-apiserver service's status.
- Due to security considerations, it is generally discouraged to run Ansible jobs with root capabilities. Instead, create a special user for Kubernetes management and configure Ansible to utilize that user.
- Inside the playbook once the kubeconfig has been copied to a non-root user's home directory.Ensure that the user has the necessary permissions, and utilize the file module's owner and group options to properly specify ownership and group.
- Change the playbook's kubectl get nodes task to point to the non-root user's kubeconfig directory.
- Using the official calico for Kubernetes CNI provider on Ansible Galaxy, you can deploy calico once you have a functional kubeconfig established for your non-root user.
Instead of pasting the kubeconfig directly into the playbook of enhanced security advantage, think about storing it as a Kubernetes secret. Using [Ansible Vault][1] to safely handle private data, such as Kubeadm tokens
[1]: https://docs.ansible.com/ansible/latest/cli/ansible-vault.html |
Method threw 'org.hibernate.LazyInitializationException' exception. Cannot evaluate com.esewa.admin.domain.Departments$HibernateProxy$ekCkdrrd.toString()
While i was fetching the entity its data is coming perfectly fine but the related mapping data could not able to fetch though my mapping in manytoone and its default fetch type is eager and also to ensure more in service level transactional annotation is used but the api is fetching this error.
Method threw 'org.hibernate.LazyInitializationException' exception. Cannot evaluate com.esewa.admin.domain.Departments$HibernateProxy$ekCkdrrd.toString() |
Problem While Fetching the Entity data and its related Entity data with JPA(Lazy Initialization Exception) |
|java|spring-boot|hibernate|jpa|jpql| |
null |
I have a numpy array and corresponding row and column indices:
```
mat = np.array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
row_idx = np.array([0, 0, 0,
0, 0, 0,
1, 1, 1])
col_idx = np.array([0, 1, 2,
0, 1, 2,
0, 1, 2])
```
I would like to unravel the matrix by the groups specified in row_idx and col_idx:
```
result = np.array([0, 3, 1, 4, 2, 5, 6, 7, 8])
```
**Why numpy_groupies.aggregate() doesn't work**
```
import numpy as np
import numpy_groupies as npg
mat = np.array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
row_idx = np.array([0, 0, 0,
0, 0, 0,
1, 1, 1])
col_idx = np.array([0, 1, 2,
0, 1, 2,
0, 1, 2])
result = npg.aggregate(group_idx=np.vstack([row_idx, col_idx]), a=mat.reshape(-1), func='array')
Produces:
[[array([0, 3]) array([1, 4]) array([2, 5])]
[array([6]) array([7]) array([8])]]
```
I have tried aggregate() from the numpy_groupies package, but it is both slow and returns an array combining np.arrays and can also include ints rather than arrays in certain cirumstances (which makes further manipulation difficult and slow).
**Why ravel doesn't work**
The problem with ravel is that it does not generalise to where the matrix has areas that are grouped by rows and other areas by columns based on the row_idx and col_idx. There can be a combination of both row and column grouping. |
|php|html|forms|file|mysqli| |
164b: f3 0f 1e fa endbr64
164f: 55 push %rbp
1650: 53 push %rbx
1651: 48 83 ec 28 sub $0x28,%rsp
1655: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
165c: 00 00
165e: 48 89 44 24 18 mov %rax,0x18(%rsp)
1663: 31 c0 xor %eax,%eax
1665: 48 89 e6 mov %rsp,%rsi
1668: e8 18 08 00 00 call 1e85 <read_six_numbers>
166d: 83 3c 24 01 cmpl $0x1,(%rsp)
1671: 75 0a jne 167d <phase_2+0x32>
1673: 48 89 e5 mov %rsp,%rbp
1676: bb 02 00 00 00 mov $0x2,%ebx
167b: eb 13 jmp 1690 <phase_2+0x45>
167d: e8 c1 07 00 00 call 1e43 <explode_bomb>
1682: eb ef jmp 1673 <phase_2+0x28>
1684: 83 c3 01 add $0x1,%ebx
1687: 48 83 c5 04 add $0x4,%rbp
168b: 83 fb 07 cmp $0x7,%ebx
168e: 74 12 je 16a2 <phase_2+0x57>
1690: 89 d8 mov %ebx,%eax
1692: 0f af 45 00 imul 0x0(%rbp),%eax
1696: 39 45 04 cmp %eax,0x4(%rbp)
1699: 74 e9 je 1684 <phase_2+0x39>
169b: e8 a3 07 00 00 call 1e43 <explode_bomb>
16a0: eb e2 jmp 1684 <phase_2+0x39>
16a2: 48 8b 44 24 18 mov 0x18(%rsp),%rax
16a7: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
16ae: 00 00
16b0: 75 07 jne 16b9 <phase_2+0x6e>
16b2: 48 83 c4 28 add $0x28,%rsp
16b6: 5b pop %rbx
16b7: 5d pop %rbp
16b8: c3 ret
16b9: e8 c2 fb ff ff call 1280 <__stack_chk_fail@plt>
Given the code above I speculated that %rbp would be equal to a decimal value of -40 but I know this is incorrect and I dont know enough about assembly to figure out where my logic went wrong.
Im not entirely sure what the output is supposed to be but I am not sure if the answer I came up with makes sense because line 1690 compares if %eax is equal to %rbp + 4 but if %rbp is -40 this statement will never execute resulting in an infinite loop |
Chrome mobile phone.
There has to be a way to remove it?
It happens in the code example I provided also.
I can see it when the buttons are clicked via mobile.
Does anyone on here know what I am referring to?
When I tap one of the buttons via mobile, there is a white flash, how do I disable or remove that?
That is all I am trying to do in the code.
https://jsfiddle.net/xmdq14a2/1/
I am not able to take a screenshot of it because it happens too quickly.
To reproduce, tap one of the buttons via a mobile device.
Only occurs via mobile not desktop.
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
I am not sure what is causing it to occur.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
(function manageLinks() {
const linksButton = [{
buttonClass: "linkButton btn-primary btn",
title: "Links"
}
];
const buttonContainer = document.querySelector(".buttonContainerB");
linksButton.forEach(function (links) {
const button = document.createElement("button");
button.className = links.buttonClass;
button.textContent = links.title;
button.classList.add("linkButton", "btnC", "btn-primaryC");
button.setAttribute("data-destination", "#lb"); // Added this line
buttonContainer.appendChild(button);
});
})();
(function manageLinkButtonOpen() {
function openModal(target) {
const modal = document.querySelector(target);
modal.classList.add("active");
}
function addLinkToButton() {
const modalButton = document.querySelector(".linkButton");
modalButton.addEventListener("click", function (event) {
//const target = event.currentTarget.dataset.destination;
//openModal(target);
openModal(event.currentTarget.dataset.destination);
});
}
addLinkToButton();
}());
(function manageLinkButtonClose() {
function closeModal(modal) {
modal.classList.remove("active");
}
function addCloseEventToModal() {
const closeModals = document.querySelectorAll(".modalB");
closeModals.forEach(function (modal) {
modal.addEventListener("click", function (event) {
//closeModal(event.target.closest(".modalB"));
closeModal(document.querySelector(".modalB"));
});
});
}
addCloseEventToModal();
}());
<!-- language: lang-css -->
body {
margin: 0;
padding: 0;
}
body {
background: #121212;
padding: 0 8px 0;
}
/*body:has(.outer-container:not(.hide)) {
padding-top: 0;
}*/
body:has(.modal.active) {
overflow: hidden;
}
body:has(.modalB.active) {
overflow: hidden;
}
.outer-container {
display: flex;
min-height: 100vh;
/*justify-content: center;
flex-direction: column;*/
}
.buttonContainerB {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
max-width: 569px;
gap: 10px;
}
/*.buttonContainerC {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
max-width: 569px;
gap: 10px;
}
*/
.buttonContainerC {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: space-around;
max-width: 569px;
gap: 10px;
}
.buttonContainerC:after{
content:"";
flex-basis:183px;
}
.btn-primaryC {
color: #2fdcfe;
background-color: #000000;
border-color: #2fdcfe;
}
.btnC {
display: inline-block;
line-height: 1.5;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
background-color: #000000;
border: 1px solid red;
box-sizing: border-box;
padding: 6px 12px;
font-size: 16px;
border-radius: 4px;
font-family: "Poppins", sans-serif;
font-weight: 500;
font-style: normal;
}
.btn-primaryD {
color: #2fdcfe;
background-color: #000000;
border-color: #2fdcfe;
}
.btnD {
display: inline-block;
line-height: 1.5;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
background-color: #000000;
border: 1px solid #2fdcfe;
box-sizing: border-box;
padding: 6px 12px;
font-size: 16px;
border-radius: 4px;
font-family: "Poppins", sans-serif;
font-weight: 500;
font-style: normal;
}
.linkButtonB {
flex-basis: 183px;
/* width of each button */
margin: 0;
/* spacing between buttons */
cursor: pointer;
}
.linkButton {
flex-basis: 183px;
/* width of each button */
margin: 0;
/* spacing between buttons */
cursor: pointer;
}
.containerD.hide {
display: none;
}
.modalB {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
display: flex;
/*background: rgba(0, 0, 0, 0.4);*/
transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;
transform: translate(0, -25%);
opacity: 0;
pointer-events: none;
z-index: -99;
overflow: auto;
border-radius: 50%;
}
.modalB.active {
/* display: flex;*/
opacity: 1;
transform: scale(1);
z-index: 1000;
pointer-events: initial;
border-radius: 0;
overflow: auto;
padding: 8px 8px;
}
.inner-modalB {
position: relative;
margin: auto;
}
.containerC {
/*display: flex;
flex-wrap: wrap;
flex-direction: column;*/
/* added*/
/* min-height: 100%;*/
margin: auto;
/* justify-content: center;
align-content: center;*/
}
.containerC.hide {
display: none;
}
.modal-footer {
display: flex;
align-items: center;
box-sizing: border-box;
padding: calc(16px - (8px * 0.5));
background-color: transparent;
border-top: 1px solid transparent;
border-bottom-right-radius: calc(8px - 1px);
border-bottom-left-radius: calc(8px - 1px);
}
.exitC {
transform: translatey(100%);
margin: -65px auto 0;
inset: 0 0 0 0;
width: 47px;
height: 47px;
background: black;
border-radius: 50%;
border: 5px solid red;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.exitC::before,
.exitC::after {
content: "";
position: absolute;
width: 100%;
height: 5px;
background: red;
transform: rotate(45deg);
}
.exitC::after {
transform: rotate(-45deg);
}
.closeB {
transform: translatey(100%);
margin: -65px auto 0;
inset: 0 0 0 0;
/*margin: auto auto 0;*/
/*margin: 10px auto 0;*/
width: 47px;
height: 47px;
background: black;
border-radius: 50%;
border: 5px solid red;
display: flex;
align-items: center;
justify-content: center;
/*margin: auto;*/
cursor: pointer;
}
.closeB::before,
.closeB::after {
content: "";
position: absolute;
width: 100%;
height: 5px;
background: red;
transform: rotate(45deg);
}
.closeB::after {
transform: rotate(-45deg);
}
<!-- language: lang-html -->
<div class="outer-container ">
<div class="containerC ">
<div class="modal-contentA">
<div class="buttonContainerB">
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
</div>
<div class="modal-footer">
<button class="exitC exit" type="button" title="Exit" aria-label="Close"></button>
</div>
</div>
<div id="lb" class="modalB">
<div class="inner-modalB">
<div class="buttonContainerC">
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
</div>
<div class="linkButton"></div>
<div class="modal-footer">
<button class="closeB exit">×</button>
</div>
</div>
</div>
</div>
</div>
<!-- end snippet -->
|
Is there any library available to encode these if present as values eg. can be html attributes, js events, scripts, expressions evaluating to true? Though it should escape values like ">50000" or "<232" i.e any "</>" used with numeric values. Or how to encode these based on whitelisting etc?
<script>alert(1709881302027)</scipt>;
<script /**/>/**/alert(1709881242160)/**/</script /**/
<IMG onmouseover="alert('xxs')">
><script>alert(1709881242161)</script>
%3Cscript%3Ealert%281%29%3C%2Fscript%3E1709881242161
javascript:alert(1709881302029)
1 OR 1=1 ; -- OR 1 OR 1=1 ;
' OR '1'='1
1 OR 1=1;
In case of owasp library it also encodes all the presence of <,' etc even if they are not html attributes or js events. |
i've been through the same problem but in my case with **typeorm**
but i think my solution will works for you.
what i did is implement simple parser that take `stingifiedJsonObjectQuery` which is JSON string that represent **where** from client
and parse it's to **typeorm object**.
that's snippet from my production code that does the jobs:
(and please note that this is not for copy paste it just to looks at and to learn from)
import { BadRequestException, Inject } from '@nestjs/common';
import { Between, Equal, FindOneOptions, ILike, In, IsNull, LessThan, MoreThan } from 'typeorm';
import { ILogger } from '../../core/logger/logger.interface';
import { LOGGER_PROVIDER_NAME } from '../../core/providers.constants';
import { IQueryParser, ITypeOrmQueryParser } from './queryParser.interface';
export enum FindOperators {
NOT = '$not',
ILIKE = '$ilike',
IN = '$in',
MORE_THATN = '$MoreThan',
LESS_THAN = '$LessThan',
EQUAL = '$Equal',
ISNULL = '$ISNULL',
ARE = '$are',
CONTAINS = '$contains',
BETWEEN = '$between',
Assigned = '$Assigned',
}
export interface ICondition {
operation?: FindOperators;
value?: any;
}
function parseOperator(condition: ICondition) {
if (typeof condition !== 'object') return condition;
if (condition === null || condition === undefined || condition.value == null) return IsNull();
if (!condition.operation) return condition.value;
switch (condition.operation) {
case FindOperators.EQUAL:
return Equal(condition.value);
case FindOperators.LESS_THAN:
return LessThan(condition.value);
case FindOperators.MORE_THATN:
return MoreThan(condition.value);
case FindOperators.IN:
return In(condition.value);
case FindOperators.ILIKE:
condition.value = condition.value.replace('%20', ' ');
return ILike(condition.value);
case FindOperators.ARE:
return {
id: In(condition.value),
};
case FindOperators.CONTAINS:
condition.value = condition.value.replace('%20', ' ');
return ILike('%' + condition.value + '%');
case FindOperators.BETWEEN:
return Between(new Date(condition.value[0]), new Date(condition.value[1]));
default:
throw new BadRequestException(`Operator ${condition.operation} not found`);
}
}
function parseAndOptions(where) {
for (const [key, value] of Object.entries(where)) {
if (typeof value === 'object' && value !== null) {
if (value['operation']) {
where[key] = parseOperator(value);
continue;
}
where[key] = parseAndOptions(value);
}
}
return where;
}
function parseOrOptions(where) {
if (Array.isArray(where)) {
for (let i = 0; i < where.length; i++) where[i] = parseOrOptions(where[i]);
return where;
}
return parseAndOptions(where);
}
function parseTypeOrmOptions(options: FindOneOptions) {
if (options.where) options.where = parseOrOptions(options.where);
return options;
}
export class TypeOrmQueryParser implements ITypeOrmQueryParser {
constructor(@Inject(LOGGER_PROVIDER_NAME) private _logger: ILogger) {}
parseQuery(str: any) {
const result: any = str;
try {
result.parsedOptions = JSON.parse({ ...result }.options);
result.options = parseTypeOrmOptions(JSON.parse(JSON.stringify(result)).parsedOptions);
} catch (err) {
this._logger.error('[TYPEORM_PARSER]', 'ERROR WHILE PARSING ' + err);
result.options = {
where: {},
};
}
result.skip = parseInt(result.skip);
if (!result.skip) {
result.skip = 0;
}
result.limit = parseInt(result.limit);
if (!result.limit) {
result.limit = 100;
}
return result;
}
}
export class SqlQueryParser implements IQueryParser {
parseQuery(str: any) {
const result: any = str;
result.skip = parseInt(result.skip);
if (!result.skip) {
result.skip = 0;
}
result.limit = parseInt(result.limit);
if (!result.limit) {
result.limit = 100;
}
if (result.options) {
try {
result.options = JSON.parse(result.options);
result.options = parseTypeOrmOptions(result.options);
} catch (err) {
result.options = {};
}
}
return result;
}
}
|
I'm wondering if the SamuelSackey code has an error, in
lib/supabase/server-client the code is not spreading the options.
See lines 18 and 22 from the repo (https://github.com/SamuelSackey/nextjs-supabase-example/blob/main/src/lib/supabase/server-client.ts)
set(name: string, value: string, options: CookieOptions) {
if (component) return;
cookies().set(name, value, options);
},
remove(name: string, options: CookieOptions) {
if (component) return;
cookies().set(name, "", options);
},
The Supabase SSR docs has the following
get(name: string) {
return cookieStore.get(name)?.value
},
set(name: string, value: string, options: CookieOptions) {
cookieStore.set({ name, value, ...options })
},
remove(name: string, options: CookieOptions) {
cookieStore.set({ name, value: '', ...options })
},
For example (on the Supabase SSR docs) https://supabase.com/docs/guides/auth/server-side/creating-a-client?environment=route-handler
His middleware code also looks abbreviated, here are the supabase docs for middleware
https://supabase.com/docs/guides/auth/server-side/creating-a-client?environment=middleware, note the get, set, and remove code is missing from his middleware.ts. When calling the ssr CreateServerClient, the third argument is the cooking handling (cookies and cookieOptions),
declare function createServerClient<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options: SupabaseClientOptions<SchemaName> & {
cookies: CookieMethods;
cookieOptions?: CookieOptionsWithName;
}): _supabase_supabase_js.SupabaseClient<Database, SchemaName, Schema>;
Edit: also found this on the Supabase Social Login documents (
https://supabase.com/docs/guides/auth/social-login/auth-google)
>Google does not send out a refresh token by default, so you will need to pass parameters like these to signInWithOAuth() in order to extract the provider_refresh_token:
|
I am using a Huawei E3372 4G USB dongle on Win8.1. This dongle's settings can be accessed via browser by typing 192.168.8.1 and the user can enable a 4G connection by manually clicking the "Enable mobile data" button.
This is the script I am trying to use to "Enable mobile data" connection, knowing I'm doing something wrong only on line 4:
```
#!/bin/bash
curl -s -X GET "http://192.168.8.1/api/webserver/token" > token.xml
TOKEN=$(grep -v '<?xml version="1.0" encoding="UTF-8"?><response><token>' -v '</token></response>' token.xml)
curl "http://192.168.8.1/api/dialup/mobile-dataswitch" -H "Host: 192.168.8.1" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:68.0) Gecko/20100101 Goanna/4.8 Firefox/68.0 PaleMoon/29.0.1" -H "Accept: */*" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8;" -H "_ResponseSource: Broswer" -H "__RequestVerificationToken: $TOKEN" -H "X-Requested-With: XMLHttpRequest" -H "Referer: http://192.168.8.1/html/content.html" -H "Cookie: SessionID=AgVjkIjBxOC0xPbys3nne7rA4I8GXNzUkZCcSOGPR8P3xss8XOuqRbdb0EgHidXhQXZ903xf0nk0F8J81ISqHpZ7kYvZaSW5wHWDqJ9w90pXj90cPwCm7F01fFcmp0gv" -H "Connection: keep-alive" --data-raw "<?xml version=""1.0"" encoding=""UTF-8""?><request><dataswitch>1</dataswitch></request>"
date
exec $SHELL
```
Upon executing the first curl command, the xml file's content would look like this:
```
<?xml version="1.0" encoding="UTF-8"?><response><token>ZsxY7Q9G90jh4FqUiAjxD9XmqLWf0rYg4RUNf6FoVzeTIlPPms0Ov1RERFFRY77o</token></response>
```
Just for test purposes, if I manually insert the token in the bash script, it works like a charm:
```
#!/bin/bash
curl "http://192.168.8.1/api/dialup/mobile-dataswitch" -H "Host: 192.168.8.1" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:68.0) Gecko/20100101 Goanna/4.8 Firefox/68.0 PaleMoon/29.0.1" -H "Accept: */*" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8;" -H "_ResponseSource: Broswer" -H "__RequestVerificationToken: ZsxY7Q9G90jh4FqUiAjxD9XmqLWf0rYg4RUNf6FoVzeTIlPPms0Ov1RERFFRY77o" -H "X-Requested-With: XMLHttpRequest" -H "Referer: http://192.168.8.1/html/content.html" -H "Cookie: SessionID=AgVjkIjBxOC0xPbys3nne7rA4I8GXNzUkZCcSOGPR8P3xss8XOuqRbdb0EgHidXhQXZ903xf0nk0F8J81ISqHpZ7kYvZaSW5wHWDqJ9w90pXj90cPwCm7F01fFcmp0gv" -H "Connection: keep-alive" --data-raw "<?xml version=""1.0"" encoding=""UTF-8""?><request><dataswitch>1</dataswitch></request>"
date
exec $SHELL
```
I've found several suggestions for the same or similar dongles, none of them worked for me, it must be due to my insufficient knowledge. My cry for help is about line 4 of the top-most script. I am making a mistake somewhere obviously.
Thank you in advance for your help. |
How to sanitise request body in spring boot if some attributes contain these values |
|java|spring-boot|xss|encode|sanitization| |
Chrome mobile phone. android.
There has to be a way to remove it?
It happens in the code example I provided also.
I can see it when the buttons are clicked via mobile.
Does anyone on here know what I am referring to?
When I tap one of the buttons via mobile, there is a white flash, how do I disable or remove that?
That is all I am trying to do in the code.
https://jsfiddle.net/xmdq14a2/1/
I am not able to take a screenshot of it because it happens too quickly.
To reproduce, tap one of the buttons via a mobile device.
Only occurs via mobile not desktop.
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
I am not sure what is causing it to occur.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
(function manageLinks() {
const linksButton = [{
buttonClass: "linkButton btn-primary btn",
title: "Links"
}
];
const buttonContainer = document.querySelector(".buttonContainerB");
linksButton.forEach(function (links) {
const button = document.createElement("button");
button.className = links.buttonClass;
button.textContent = links.title;
button.classList.add("linkButton", "btnC", "btn-primaryC");
button.setAttribute("data-destination", "#lb"); // Added this line
buttonContainer.appendChild(button);
});
})();
(function manageLinkButtonOpen() {
function openModal(target) {
const modal = document.querySelector(target);
modal.classList.add("active");
}
function addLinkToButton() {
const modalButton = document.querySelector(".linkButton");
modalButton.addEventListener("click", function (event) {
//const target = event.currentTarget.dataset.destination;
//openModal(target);
openModal(event.currentTarget.dataset.destination);
});
}
addLinkToButton();
}());
(function manageLinkButtonClose() {
function closeModal(modal) {
modal.classList.remove("active");
}
function addCloseEventToModal() {
const closeModals = document.querySelectorAll(".modalB");
closeModals.forEach(function (modal) {
modal.addEventListener("click", function (event) {
//closeModal(event.target.closest(".modalB"));
closeModal(document.querySelector(".modalB"));
});
});
}
addCloseEventToModal();
}());
<!-- language: lang-css -->
body {
margin: 0;
padding: 0;
}
body {
background: #121212;
padding: 0 8px 0;
}
/*body:has(.outer-container:not(.hide)) {
padding-top: 0;
}*/
body:has(.modal.active) {
overflow: hidden;
}
body:has(.modalB.active) {
overflow: hidden;
}
.outer-container {
display: flex;
min-height: 100vh;
/*justify-content: center;
flex-direction: column;*/
}
.buttonContainerB {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
max-width: 569px;
gap: 10px;
}
/*.buttonContainerC {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
max-width: 569px;
gap: 10px;
}
*/
.buttonContainerC {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: space-around;
max-width: 569px;
gap: 10px;
}
.buttonContainerC:after{
content:"";
flex-basis:183px;
}
.btn-primaryC {
color: #2fdcfe;
background-color: #000000;
border-color: #2fdcfe;
}
.btnC {
display: inline-block;
line-height: 1.5;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
background-color: #000000;
border: 1px solid red;
box-sizing: border-box;
padding: 6px 12px;
font-size: 16px;
border-radius: 4px;
font-family: "Poppins", sans-serif;
font-weight: 500;
font-style: normal;
}
.btn-primaryD {
color: #2fdcfe;
background-color: #000000;
border-color: #2fdcfe;
}
.btnD {
display: inline-block;
line-height: 1.5;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
background-color: #000000;
border: 1px solid #2fdcfe;
box-sizing: border-box;
padding: 6px 12px;
font-size: 16px;
border-radius: 4px;
font-family: "Poppins", sans-serif;
font-weight: 500;
font-style: normal;
}
.linkButtonB {
flex-basis: 183px;
/* width of each button */
margin: 0;
/* spacing between buttons */
cursor: pointer;
}
.linkButton {
flex-basis: 183px;
/* width of each button */
margin: 0;
/* spacing between buttons */
cursor: pointer;
}
.containerD.hide {
display: none;
}
.modalB {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
display: flex;
/*background: rgba(0, 0, 0, 0.4);*/
transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;
transform: translate(0, -25%);
opacity: 0;
pointer-events: none;
z-index: -99;
overflow: auto;
border-radius: 50%;
}
.modalB.active {
/* display: flex;*/
opacity: 1;
transform: scale(1);
z-index: 1000;
pointer-events: initial;
border-radius: 0;
overflow: auto;
padding: 8px 8px;
}
.inner-modalB {
position: relative;
margin: auto;
}
.containerC {
/*display: flex;
flex-wrap: wrap;
flex-direction: column;*/
/* added*/
/* min-height: 100%;*/
margin: auto;
/* justify-content: center;
align-content: center;*/
}
.containerC.hide {
display: none;
}
.modal-footer {
display: flex;
align-items: center;
box-sizing: border-box;
padding: calc(16px - (8px * 0.5));
background-color: transparent;
border-top: 1px solid transparent;
border-bottom-right-radius: calc(8px - 1px);
border-bottom-left-radius: calc(8px - 1px);
}
.exitC {
transform: translatey(100%);
margin: -65px auto 0;
inset: 0 0 0 0;
width: 47px;
height: 47px;
background: black;
border-radius: 50%;
border: 5px solid red;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.exitC::before,
.exitC::after {
content: "";
position: absolute;
width: 100%;
height: 5px;
background: red;
transform: rotate(45deg);
}
.exitC::after {
transform: rotate(-45deg);
}
.closeB {
transform: translatey(100%);
margin: -65px auto 0;
inset: 0 0 0 0;
/*margin: auto auto 0;*/
/*margin: 10px auto 0;*/
width: 47px;
height: 47px;
background: black;
border-radius: 50%;
border: 5px solid red;
display: flex;
align-items: center;
justify-content: center;
/*margin: auto;*/
cursor: pointer;
}
.closeB::before,
.closeB::after {
content: "";
position: absolute;
width: 100%;
height: 5px;
background: red;
transform: rotate(45deg);
}
.closeB::after {
transform: rotate(-45deg);
}
<!-- language: lang-html -->
<div class="outer-container ">
<div class="containerC ">
<div class="modal-contentA">
<div class="buttonContainerB">
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
<button class="linkButtonB btn-primaryC btnC">linkButton</button>
</div>
<div class="modal-footer">
<button class="exitC exit" type="button" title="Exit" aria-label="Close"></button>
</div>
</div>
<div id="lb" class="modalB">
<div class="inner-modalB">
<div class="buttonContainerC">
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
<a href="#" class="linkButton btn-primaryD btnD" target="_blank">some text </a>
</div>
<div class="linkButton"></div>
<div class="modal-footer">
<button class="closeB exit">×</button>
</div>
</div>
</div>
</div>
</div>
<!-- end snippet -->
|
What is the point of this part of an auto-generated JSP page in IntelliJ IDEA?
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
Because I don't see any loss of functionality if I remove this line. What's its purpose? |
What is page contentType in JSP? |
I understand your question. You want the image to "refresh" while the application is being used, so if the source file changes, the image displayed by the widget will also change. There's no 'miracle formula' for this, the two files need to have the same name. Let me explain: we change the name of the image "dog.png" to animal.png and we also change the name of "cat.png" to animal.png. When you replace one file with the other you keep the same name but you change the data and so Kivy realises on its own that the content of the file has changed and refreshes the image but to do this the 2 files must have the same name. Tell me if I'm not clear, I can explain again.
Translated with DeepL.com (free version) |
I wait until the page is loaded and use the "DOMContentLoaded" method to add eventhandlers on some p tags. This works until I open and close the modal. Can someone please tell me why the page fully freezes?
```
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="div_1">
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>
<p id="open_modal">open the modal</p>
<script>
document.addEventListener("DOMContentLoaded", () => {
let test = document.querySelector("#div_1")
for (let i = 0; i < test.children.length; i++) {
test.children[i].addEventListener("click", () => {
console.log(test.children[i].innerHTML)
});
};
});
document.querySelector("#open_modal").addEventListener("click", () => {
if (!document.querySelector("#modal")) {
document.body.innerHTML += `
<div id="modal" style="display: block; position: fixed; z-index: 1; padding-top: 100px; left: 0; top: 0; width: 100%; height: 100%; overflow: auto;
background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4)">
<div id="modal_content">
<span id="modal_close">×</span>
<p style="color: green;">Some text in the Modal..</p>
</div>
</div>
`;
} else {
document.querySelector("#modal").style.display = "block";
};
document.querySelector("#modal_close").addEventListener("click", () => {
document.querySelector("#modal").style.display = "none";
});
});
</script>
</body>
</html>
``` |
I am writing code for Roman Numeral Converter in browser, currently learning Javascript. Problem is right on checking return statements in console.log. I am getting right answers, but somehow all tests are failing.
CODE:
let resstr="";
``your text`` let resarr=[];
function convertToRoman(num) {
let robj={
M: 1000, CM: 900,
D: 500, CD: 400, C: 100, XC: 90,
L: 50, XL: 40, X: 10,
IX: 9, V: 5, IV: 4, I: 1
};
let okeys=Object.keys(robj); //getting keys for iteration
//loop to check numbers and adding roman numerals in array
okeys.some((key)=>{
if (num>=robj[key]){
//console.log(robj[key]);
resarr.push(key);
num=num-robj[key];
//console.log("number after subtraction is: " + num);
return true;
}
});
//end cases
if (num===0){
resstr=resarr.join('').toString();
console.log("operation done", resstr);
return resstr;
}
else if (num!==0){
console.log("no 0", num);
return convertToRoman(num);
}
else {
console.log("ended");
return true;
}
// console.log(resstr);
// return resstr;
}
For convertToRoman(3999), convertToRoman(1), convertToRoman(2) etc I am getting right answers on console.log, but browser tests are all failing, like it is getting something else than the right answer. |
Chrome extension MV3: persistent service worker die after wake up from hibernation |
|google-chrome|google-chrome-extension|service-worker|hibernation| |
When i run ./gradlew genEclipseRuns it fails to build and i get the error
```
PS C:\Users\camer\Desktop\MinecraftCoding\MinecraftJava> ./gradlew genEclipseRuns
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.4/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\camer\Desktop\MinecraftCoding\MinecraftJava\build.gradle' line: 5
* What went wrong:
Plugin [id: 'net.minecraftforge.gradle', version: '[6.0.16,6.2)'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'net.minecraftforge.gradle:net.minecraftforge.gradle.gradle.plugin:[6.0.16,6.2)')
Searched in the following repositories:
Gradle Central Plugin Repository
MinecraftForge(https://maven.minecraftforge.net/)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 5s
```
how do i fix this i have the latest java installed also and am on windows
I tried to build the mdk gradle and instead of succeeding it failed with an exception |
|python|factorial| |
|excel|vba|loops|excel-tables|listobject| |
I am using yarn workspaces in which I have 3 projects.
My-project
folder-1
folder-2
folder-3
Some devs work on folder-1, others on folder-2 and the rest on folder-3. The flow of the release is the following:
- PRs are created on feature branches and merged to develop.
- The process of PRs continue and they all get merged to develop. At some point, we decide whether release is due, so develop is merged into main branch.
- From main, we create a release candidate and deploy scripts on productions are run.
The problem that happens for us is that folder-3 project needs to be released much quicker(every day), whereas folder-1's release happens very rarely(every month) even though folder-1 changes every day(it's just release must happen every month).
**The problem:** When the team works on feature branches and merges things to develop, it happens that develop branch ends up containing folder-1 and folder-3's changed files. If we want to release folder-1 every day, we got no choice but to merge develop into main in which case changed folder-3's code also moves into main which is not ideal, because folder-3's release must happen every month, not every day.
One thing that I looked into is using `git checkout /paths` which only moves the specific folder from one branch to another - i.e I could use this to only move folder-1 from develop to main, but I am not sure if this is the right and best practice.
|
Handle workspace/monorepo's deployment with different deployments |
{"Voters":[{"Id":2001654,"DisplayName":"musicamante"},{"Id":354577,"DisplayName":"Chris"},{"Id":9484913,"DisplayName":"Parisa.H.R"}]} |
I wrote a code to call a function from PostgreSQL. In the pgAdmin, I call the function and it works right. This is my code in C#:
_db.Database.SqlQuery<CreateOrderInfo>($"select * from Asset_CreateOrderInfo('{request.Data!.UserId}',{request.Data!.SymbolId})")
The generated command is like this:
select * from Asset_CreateOrderInfo('00000001-0000-0000-0000-000000000000',2)
When I run the above code in the pgAdmin, it works right. But when I send through the EF Core and C#, It doesn't work and raises this error:
{Npgsql.PostgresException (0x80004005): 22P02: invalid input syntax for type uuid: "@p0"
Could you help me what the problem is? |
Passing GUID value through SqlQuery will raise the error: invalid input syntax for type uuid |
|c#|postgresql|entity-framework|entity-framework-core| |
I had to do two things,
First was to remove the separation of client and server and put them both in just one variable.
Second, I followed Mark Rotteveel's suggestion, but I didn't set `AuthClient = Srp256, Srp` as he said, I had to set `AuthClient = Legacy_Auth, Srp, Win_Sspi`.
Anyway, he helped me. |
The main question here for a quick diagnose:<br> **Does the AWS IAM role is eventually being used?**
You can see it when you enter the aws console UI inside the role details you should see **when it was last used** (don't trust on the column in the external view where you can see all roles with a search bar, I saw some delays in the update there).
**If role is never used:**
1. Check the arn that was passed to the service account annotation.
2. Check the namespace and service account name passed to the trust relationship - put wildcard on both for a quick debug.
3. Check the OIDC related values that you passed to the trust relationship, I would just quickly change it to trust all clusters in this account for a quick debug.
4. Try to assume other role with that pod via the IRSA mechanism (like you did).
**If role is used:**
Then the error should specify which action is missing in your policy, try to see if the required policy was changed in the latest versions of your tool.
In the case of aws-load-balancer controller it was really changed between [v2.4.1][1] <-> [v2.6.0][2].
--------------------
(*) You haven't specified the full error, but usually it is easy to see according to the error if the role that was passed via the service account was used - you should see something like this:
AccessDenied: User: arn:aws:sts::<accountId>:assumed-role/eks-alb-controller-hhfz6/1695108220719227138)
And not the Node's role Id.
[1]: https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.1/docs/install/iam_policy.json
[2]: https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.6.0/docs/install/iam_policy.json |
Use single `&` :
set "var1=a" & set "var2=b"
echo My two variables: %var1% %var2%
Output:
C:\>set "var1=a" & set "var2=b"
C:\>echo My two variables: %var1% %var2%
My two variables: a b
C:\> |
upgrade your nodejs to LTS version this is more suitable version even I have also same issue but after upgrading to LTS version I got the Answer
|
I'm trying to develop a school schedule generator in JavaScript for a high school with various subjects, teachers, and classes. The goal is to create a balanced and c schedule that minimizes conflicts while considering teacher preferences and availability.
**Specific Challenge:**
I'm struggling with the algorithm for subject distribution. Ideally, I'd like an efficient algorithm that can handle these constraints:
1. Balanced subject distribution across classes throughout the week.
2. Respecting teacher preferences and unavailable days.
3. Distributing teachersβ lectures to classes in an organized and fair manner for all.
**Additional Information:**
I'm familiar with basic object-oriented programming concepts in JavaScript and have looked at some online resources on scheduling algorithms. However, they seem too complex for my needs.
Are there any efficient algorithms suitable for this scenario, or can you suggest an approach for distributing subjects effectively while considering the mentioned constraints?
**Example Data:**
```
const teachers = [
{
name: "Math-Teacher",
id: "T1",
workDays: 6,
subjects: ["M1", "M2", "M3"],
},
{
name: "Quilting-Teacher",
id: "T2",
workDays: 2,
subjects: ["Q1", "Q2", "Q3"],
},
{
name: "Italian-Teacher",
id: "T3",
workDays: 6,
subjects: ["I1", "I2", "I3"],
},
{
name: "Biology-Teacher",
id: "T4",
workDays: 4,
subjects: ["B1", "B2", "B3"],
},
{
name: "history-Teacher",
id: "T5",
workDays: 2,
subjects: ["H1"],
},
{
name: "Phasics-Teacher",
id: "T6",
workDays: 5,
subjects: ["P1", "P2", "P3"],
},
{
name: "Italian-Teacher",
id: "T7",
workDays: 3,
subjects: ["I1", "I2", "I3"],
},
{
name: "Chemistry-Teacher",
id: "T8",
workDays: 3,
subjects: ["C1", "C2", "C3"],
},
{
name: "English-Teacher",
id: "T9",
workDays: 4,
subjects: ["M1"],
},
{
name: "Arabic-Teacher",
id: "T10",
workDays: 6,
subjects: ["A1", "A2"],
},
];
const subjects = [
//1-sec subjects
{
name: "Math",
class: "1-sec",
id: "M1",
weeklyLectures: 7,
},
{
name: "Biology",
class: "1-sec",
id: "B1",
weeklyLectures: 4,
},
{
name: " Quilting",
class: "1-sec",
id: "Q1",
weeklyLectures: 3,
},
{
name: "Isramic Culture",
class: "1-sec",
id: "I1",
weeklyLectures: 3,
},
{
name: "Phasics",
class: "1-sec",
id: "P1",
weeklyLectures: 5,
},
{
name: "History",
class: "1-sec",
id: "H1",
weeklyLectures: 3,
},
{
name: "English",
class: "1-sec",
id: "E1",
weeklyLectures: 5,
},
{
name: "Arabic",
class: "1-sec",
id: "A1",
weeklyLectures: 6,
},
{
name: "Chemistry",
class: "1-sec",
id: "C1",
weeklyLectures: 3,
},
//2-sec subjects
{
name: "Math",
class: "2-sec",
id: "M2",
weeklyLectures: 7,
},
{
name: "Biology",
class: "2-sec",
id: "B2",
weeklyLectures: 4,
},
{
name: " Quilting",
class: "2-sec",
id: "Q2",
weeklyLectures: 3,
},
{
name: "Isramic Culture",
class: "2-sec",
id: "I2",
weeklyLectures: 3,
},
{
name: "Phasics",
class: "2-sec",
id: "P2",
weeklyLectures: 5,
},
{
name: "English",
class: "2-sec",
id: "E2",
weeklyLectures: 5,
},
{
name: "Arabic",
class: "2-sec",
id: "A2",
weeklyLectures: 6,
},
{
name: "Chemistry",
class: "2-sec",
id: "C2",
weeklyLectures: 3,
},
//3-sec subjects
{
name: "Math",
class: "3-sec",
id: "M3",
weeklyLectures: 7,
},
{
name: "Biology",
class: "3-sec",
id: "B3",
weeklyLectures: 4,
},
{
name: " Quilting",
class: "3-sec",
id: "Q3",
weeklyLectures: 3,
},
{
name: "Isramic Culture",
class: "3-sec",
id: "I3",
weeklyLectures: 3,
},
{
name: "Phasics",
class: "3-sec",
id: "P3",
weeklyLectures: 5,
},
{
name: "English",
class: "3-sec",
id: "E3",
weeklyLectures: 5,
},
{
name: "Arabic",
class: "3-sec",
id: "A3",
weeklyLectures: 6,
},
{
name: "Chemistry",
class: "3-sec",
id: "C3",
weeklyLectures: 3,
},
];
const classes = [
{
name: "1-secondary",
id: "1-sec",
DailyLectures: 7,
subjects: ["M1", "Q1", "I1", "A1", "E1", "H1", "C1", "B1", "P1"],
},
{
name: "2-secondary",
id: "2-sec",
DailyLectures: 7,
subjects: ["M2", "Q2", "I2", "A2", "E2", "C2", "B2", "P2"],
},
{
name: "3-secondary",
id: "3-sec",
DailyLectures: 7,
subjects: ["M3", "Q3", "I3", "A3", "E3", "C3", "B3", "P3"],
},
];
const daysOfWeek = ["Sat", "Sun", "Mon", "Tue", "Wed", "Thr"];
```
**Expected Output**:
I expect the output to be a weekly schedule for each class, with lectures of teachers evenly distributed across the working days.
For example(like this but in a efficient way):
```
1-sec: {
Sat: [
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: ' Quilting', class: '1-sec', id: 'Q1', weeklyLectures: 3 },
{ name: ' Quilting', class: '1-sec', id: 'Q1', weeklyLectures: 3 },
{
name: 'Isramic Culture',
class: '1-sec',
id: 'I1',
weeklyLectures: 3
},
{ name: 'Biology', class: '1-sec', id: 'B1', weeklyLectures: 4 },
{ name: 'History', class: '1-sec', id: 'H1', weeklyLectures: 3 },
{ name: 'History', class: '1-sec', id: 'H1', weeklyLectures: 3 }
],
Sun: [
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: ' Quilting', class: '1-sec', id: 'Q1', weeklyLectures: 3 },
{
name: 'Isramic Culture',
class: '1-sec',
id: 'I1',
weeklyLectures: 3
},
{ name: 'Biology', class: '1-sec', id: 'B1', weeklyLectures: 4 },
{ name: 'History', class: '1-sec', id: 'H1', weeklyLectures: 3 },
{ name: 'Phasics', class: '1-sec', id: 'P1', weeklyLectures: 5 },
{ name: 'Chemistry', class: '1-sec', id: 'C1', weeklyLectures: 3 }
],
Mon: [
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{
name: 'Isramic Culture',
class: '1-sec',
id: 'I1',
weeklyLectures: 3
},
{ name: 'Biology', class: '1-sec', id: 'B1', weeklyLectures: 4 },
{ name: 'Phasics', class: '1-sec', id: 'P1', weeklyLectures: 5 },
{ name: 'Chemistry', class: '1-sec', id: 'C1', weeklyLectures: 3 },
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 }
],
Tue: [
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: 'Biology', class: '1-sec', id: 'B1', weeklyLectures: 4 },
{ name: 'Phasics', class: '1-sec', id: 'P1', weeklyLectures: 5 },
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: 'Arabic', class: '1-sec', id: 'A1', weeklyLectures: 6 }
],
Wed: [
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: 'Phasics', class: '1-sec', id: 'P1', weeklyLectures: 5 },
{ name: 'Arabic', class: '1-sec', id: 'A1', weeklyLectures: 6 }
],
Thr: [
{ name: 'Math', class: '1-sec', id: 'M1', weeklyLectures: 7 },
{ name: 'Arabic', class: '1-sec', id: 'A1', weeklyLectures: 6 }
]
}
``` |
Building a School Schedule Generator |
|javascript|algorithm|scheduling|schedule| |
null |
I have a numpy array and corresponding row and column indices:
```
mat = np.array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
row_idx = np.array([0, 0, 0,
0, 0, 0,
1, 1, 1])
col_idx = np.array([0, 1, 2,
0, 1, 2,
0, 1, 2])
```
I would like to unravel the matrix by the groups specified in row_idx and col_idx:
```
result = np.array([0, 3, 1, 4, 2, 5, 6, 7, 8])
```
**I can do this with numpy_groupies.aggregate(), but can have weird return values:**
```
import numpy as np
import numpy_groupies as npg
mat = np.array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
row_idx = np.array([0, 0, 0,
0, 0, 0,
1, 1, 1])
col_idx = np.array([0, 1, 2,
0, 1, 2,
0, 1, 2])
result = npg.aggregate(group_idx=np.vstack([row_idx, col_idx]), a=mat.reshape(-1), func='array')
Produces:
[[array([0, 3]) array([1, 4]) array([2, 5])]
[array([6]) array([7]) array([8])]]
```
I have tried aggregate() from the numpy_groupies package, but it is both slow and returns an array combining np.arrays and can also include ints rather than arrays in certain cirumstances (which makes further manipulation difficult and slow).
**Why ravel doesn't work**
The problem with ravel is that it does not generalise to where the matrix has areas that are grouped by rows and other areas by columns based on the row_idx and col_idx. There can be a combination of both row and column grouping. |
Turns out, the inverse relationship was causing the issue.
Previously, I had the relationship between Order and Item defined as
@Model
class Order: Decodable {
@Attribute(.unique) var orderId: String
var items: [Item]
}
@Model
class Item: Decodable {
@Attribute(.unique) var orderItemId: String
@Relationship(inverse: \Order.items) var order: Order?
}
Changed that to
@Model
class Order: Decodable {
@Attribute(.unique) var orderId: String
@Relationship(inverse: \Item.order) var items = [Item]()
}
@Model
class Item: Decodable {
@Attribute(.unique) var orderItemId: String
var order: Order?
}
and it worked. |
I want to make a function where I can pass in a selector name and a property and get back the css rule that matches.
for example, If I had a css class that is called "hedgehog" that applies a background color "blue", I want to call getCssTheme("hedgehog", "backgroundColor") and get back "blue".
I think I got close based on https://stackoverflow.com/questions/324486/how-do-you-read-css-rule-values-with-javascript and http://www.javascriptkit.com/domref/cssrule.shtml
I have :
function getCssTheme(element, property) {
var classes = document.styleSheets[1].cssRules;
for (var x = 0; x < classes.length; x++) {
if (classes[x].selectorText == element) {
var rules = classes[x].cssText || classes[x].style.cssText
for (var y = 0; y < rules.length; y++){
if (/*verify that the y-th property is the specified one*/) {
return rules[y];
}
}
}
}
}
I left out the check on the final if, because I don't know how to reference the property name, and I'm only guessing the return will respond right.
Anybody know the way to reference the property name? (Is this type of code even possible?) |
How to "Enable mobile data" on a Huawei E3372 4G USB dongle using a bash script in Windows |
|bash|curl|usb|4g|dongle| |