instruction
stringlengths
71
95.1k
I want to make my API unavailable to every client who doesn't have the token to access. This means the Android app will send a client as Android and token as token string in the header with keys client and token. Now in middleware, I am checking it with my table fields to pass through authorization. If both match, then...
This is my first Swift app, so I want to improve everything that I can about my code and know what I can do better. The app requests 10 developers from StackExchange API and displays them in a table with the possibility to click on one of them and see more details about him. I was asked to achieve the following memory ...
The following scenario came out of a discussion I was having with a fellow developer on this project. He likes to execute an Ienumerable as soon as possible, hence why he’s doing it inside of the method. Whereas, I’m thinking that if you wait until the object is actually needed, using differed execution, you’re elimina...
I'm trying to solve the Code Jam Dice Straight problem. My Python solution seems to produce the correct output for the first few test cases but then it becomes too slow. How can I possibly optimize it? from operator import itemgetter from itertools import groupby def get_straight(chunk: list, idx: int, straight: ...
This is a console based Tic Tac Toe Game I programmed to practice my python. It is object oriented with a few standalone functions for getting user input. The game also has a basic AI that is implemented in a recursive function. I would appreciate suggestions as to what to work on or improvements to the way the game fu...
I was coding some tooling stuff when I started to ponder whether the best return type for a Range / MinMax method applied on a IEnumerable method. I am using the value the C# 7 Tuples like below, but tempted to create my own class with readonly fields. public static (TSource Min, TSource Max) MinMax<TSource>(this I...
I made a macro that will fill in data in a workbook that has 65 (24 are user filled) columns and can go as long as 1500 rows. In an ideal scenario, the workbook has a perfect column that could work as a key to fill in the data. The thing is, users can duplicate a row, therefore messing with the column with unique value...
Edit: if there's a better way to make this reproducible, please let me know. I can create some dummy data and put this in a codepen, but that wouldn't really reflect the interaction with React that's required. I am going to need to build several React d3 components for a web application that I am building - I'd like t...
When you jump to a search result in Vim, your cursor can end up near the bottom (or top) of the window, making it difficult to see the surrounding context. Some people like to automatically center the cursor after such a jump, but I find that to be too drastic, since it means even small jumps cause scrolling. There's a...
This is really my first shot at scripting anything. What I have below works, it does exactly what I need it to, but this is only a quarter of the total function. Clearly, I need to cut down the length somehow. This is the spreadsheet that this script is referencing. This script is fairly simple, albeit long. What I'm t...
I am new person regarding LibGDX. I have written the below render method. I have a randomly generations oceans (where there are islands at random positions). Within the below code, focusedMapRectangle refers to the focused part of this map. The task is to draw the tiles of the islands that are within focusedMapRectangl...
We have to print the last word of the given string. How to improve and optimise this code? #include <iostream> std::string get_last_word(const std::string& str) { if (str.length() == 0) { std::cerr << "No string\n"; return 0; } int len = str.length(); int i = len - 1; while (i ...
I am implementing the Dijkstra algorithm for a large graph (40k nodes, 100k arcs). For shorter paths the searchtime is under a second for larger ones (from one end to the other) it takes quite some minutes to do it. I am also drawing the path after the search, so I am using some Qt objects. How could I make it faster? ...
It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one second due to 14ms timer incaccuracy. This of course would have bad implications on the schedules (they wouldn't fire if their second was skipped). I spent some...
I'm trying to speed up the execution of the following problem: I have two functions which are used together. Here are the functions explained: The first function simulates N coin flips and returns an array of strings with the results: def throw_a_coin(N): return np.random.choice(['H','T'], size=N) The second funct...
The following is my attempt at a string class that behaves like std::string. Any feedback would be appreciated. my_string.h #pragma once #include <stdexcept> //class that attempts to emulate the behavior of std::string //uses allocator in order to be able to store uninitialized data class my_string { private: si...
I'm looking to get some advice on whether or not I am building/structuring my application the correct way. The program has a few key components: Calculate the fine based on how fast over the limit a driver was travelling Generate a fine letter address to the driver Update a file with a driver's registration details an...
Sometimes I download a Python script (from a trusted source), and can't run it because of missing dependencies, which I have to install one by one (no requirements.txt is provided). I'm looking for a way to automate this process. It's similar to this question, but I'd like to infer the requirements automatically. I.e. ...
Badugi is a 4 card low hand poker game. i / 13 is suit and i % 13 is rank. Cards from 0 to 51 inclusive. Straights and flushes do not count. The best hand is A234. The worst hand is KKKK. If you match on either a suit or rank you take out a card. Any 4 card hand beats a 3 card hand. Any 3 card hand beats a 2 card h...
While I have been teaching myself a little about linux, it's boot processes and service configuration I have been using arch linux in virtualbox for my experimentation. Eventually after much wiling an gnashing of teeth I managed to get a fully functional minimal arch system to the point where I can build upon it as I w...
So i am working on a project and my question is as follows. In the code below is alot of code duplication going. Is it possible to avoid code duplication in such cases? What would be the best practices to avoid the code duplication below. I hope someone can point me to the right direction. public void rechts() { ...
Here is my code about our final project in uni called 'Mars Lander'. The thing is that my code seems to be all over the place (more specifically in the 'main' function at the end of the code...) therefore I would like to get some help with putting things in place! It's my first time making a game using the 'pygame' lib...
I'm a novice, self taught C# developer who's working on my first major program. The program I'm building is a system startup manager that is supposed to replace the stock startup manager that ships with Windows. GitHub You can find instructions on how to use it from the README.txt file, and to get an idea of how it loo...
I'm looking to port a Python script I have over to Swift, partly for some performance benefits, and partly to dip my toe into a new language. My program computes what is called the downset of a permutation of \$[n] := \{1,2,\cdots,n\}\$. For me, a permutation of \$[n]\$ is a tuple containing each integer precisely once...
Given two objects with some food data, log the name of the recipe and ingredients names separated by conjunction "and". Please run the code I have attached to see the expected output. condition - match RECIPES.rules.id with INGREDIENT.id and use INGREDIENT.name in the final output. I was wondering if my solution can b...
I have <button>s that when pressed expand or collapse the contents of all the <details> within the document. The code works, but as a novice in JavaScript, I am not very confident in its performance and/or efficiency. Could you please review it. expandDetBtn = document.getElementById("showBtn"); collapseDetBtn = docu...
I need to filter database data based on filters available to the end user in the form of search term text box, select boxes etc. I have put together this code and need feedback if this is a good way to do it or if there are any better solutions. using Multi.Model; using System; using System.Linq; using System.Windows.C...
My goal in this project is to make something that can—as, quickly, effectively, and efficiently as Array(repeating: , count: )—initialize an Array of alternating values. Note: I am using Swift 4.1 and Xcode 9.3 My Array Initialization: extension Array { init (repeatingValues arr: Array, count: Int) { preco...
I have decided to write my own min max sum functions. I really don't like the ones provided by the STL so I decided to write my own. #include <type_traits> namespace utils { namespace detail { template<typename T1, typename T2> using BiggerT = typename std::conditional<sizeof(T1) >= sizeof(T2), T1, T2>; tem...
Task: Do DFS traversal from a given given graph and print output. Is this code the correct implementation of DFS traversal in Graph? from collections import defaultdict class Graph(object): def __init__(self): self.graph = defaultdict(list) def add_edge(self, u, v): self.graph[u].append(v) ...
As per K & R exercise 5-13 Write the program tail, which prints the last n lines of its input. By default, n is 10, say, but it can be changed by an optional argument, so that tail -n prints the last n lines. The program should behave rationally no matter how unreasonable the input or the value of n. Write the pr...
Here is my implementation of matrix multiplication using the CUDA C++ API. I tried to separate the source code into multiple files for easier maintenance and readability. matrix.hpp By creating this struct I wanted to keep things tidy and avoid passing a lot of parameters to functions and kernels later. #pragma once ...
I just start learning to code in C#. Is there any other short way to make calculator like this using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Calculator { class Program { static void Main(string[] args) { float result =...
This is an answer to this SO question: Vba comparing 2 columns of data. In that question the OP code is very slow (also not working properly but the problem is fixed) I spent some time to implement a version with decent performance at 1M rows+ Note: I know Activesheet is discouraged (and I avoid it) but the Sub is q...
I have an APC UPS, which comes with the apcaccess utility to get various statistical values from the apcupsd daemon service. I am using the following script to stream my line voltage data to thingspeak.com website which allows us to see the results streaming in real time. The script is set as a cron job, executing ever...
Is it possible to make this faster? Any suggestions are more than welcome I have used JavaScript to write this code PROBLEM You will get an array of numbers. Every preceding number is smaller than the one following it. Some numbers will be missing, for instance: [-3,-2,1,5] // missing numbers are: -1,0,2,3,4 Y...
We have conception as "fiscal year" and have calculations based on start/end date (April 1, March 31). My question is: what is better, store end date time as April 1 or March 31? Now I have next code: public DateTime GetFiscalYearStart(int fiscalYear) { return new DateTime(fiscalYear, 4, 1); } public DateTime GetF...
With great inspiration from t3chb0ts ongoing work about scheduling, cron jobs etc. (last post here), I decided to make my own version of the Scheduler - using the observer pattern - as a learning project. The scheduler public class HScheduler { public const int UnlimitedJobParallelism = -1; HSecondCounter ...
How secure is my script? #!/usr/bin/env bash echo "Input database name" read databaseName echo "The database name is set to $databaseName" echo "Input database host" read databaseHost echo "The database host is set to $databaseHost" echo "Input database user" read user echo "The database user is set to $user" stty ...
Assume filteredEvents from below to be a List<Filter>. Basically a list of objects, each of these holding a list of days in the year, among other not-important-at-the-moment data and a specific colour to draw on the calendar, to represent that there are events for that particular colour distinguishable department. It's...
I have implemented repository in Ado.Net which insert data to many tables. I insert all in one transaction and use async/await to improve performances. If you have any suggestions have to improve my code I would be grateful. using MonitoringTool.Common.DomainModelsNew; using MonitoringTool.Common.Extensions; using Syst...
I have implemented a custom iterator to iterate over an array that is held by a pointer. The iterator accepts a unit which specifies by which amount the underlying pointer is increased (or decreased) at each increment (or decrement). I.e. when auto data = new int[100]; ArrayIterator<int, false> it(data, 2); // 2nd ar...
I am pasting here my working code which generate report in worksheet then save it in pdf format then open it in pdf after selecting a name from a combobox in userform then press commandbutton1 to execute it. Source worksheet2 (RpT) Target worksheet5 (Ptr) all do well but it is a long code which takes time to perform so...
Challenge: Write code in Python that parses fund holdings pulled from EDGAR, given a ticker or CIK. Example: For this example, we will use this CIK: 0001166559 Start on this page. Enter in the CIK (or ticker), and it will take you here. Find the "13F" report documents from the ones listed. Here is a "13F-HR". Parse an...
Introduction I drive a white 2CV from home to work, and intend to keep that way until retirement. Once retired, I will sell the 2CV to buy a yacht and sail away. My home is far, far away from my work, so I put a lot of kms on the 2CV everyday. The 2CV is beautiful and nice but also an old car, so a lot of main...
I have this function in R: Minimum <- function(data) { answer <- numeric(length(data)) diference <- c(0, diff(data, lag = 1, differences = 1)) #Padded initially =0 answer[1]=data[1] for (i in 2:length(diference)) { if (diference[i]==0) { answer[i]=answer[i-1] } else { ...
I've integrated the feedback from my previous question "Yet another doubly linked list". In addition to that the list now uses the copy and swap idiom. It also has a very simple iterator to enable it to work with a ranged for loop. So far everything works but I'm not very confident about this code. I would like some fe...
I'm trying to implement a cache available in a data provider (repository). The data provider is a normal class, instanciated at every request made to the application. The reason I have a static class is that I want all requests to share the same _lock object. The data being cached doesn't change very often and is quite...
Description: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. coins = [1, 2, 5], amount = 11, return 3 (11...
I have a large file that I need to parse - and since it will be regenerated from external queries every time script runs so there is no way to parse it once and cache the results. I want to save memory footprint and read and parse only logical "chunks" of that file everything between open 'product' and closing curly br...
I'm calling Connect() for the first time I connect, I am then checking if the connection is still connected every 10 seconds if it is not connected it attempts to re-connect. public class ClientHandler : ISocketHandler, IDisposable { private readonly Socket _socket; private readonly byte[] _buffer; private...
I would like to use a YAML file to store parameters used by computational models developed in Python. An example of such a file is below: params.yaml reactor: diameter_inner: 2.89 cm temperature: 773 kelvin gas_mass_flow: 1.89 kg/s biomass: diameter: 2.5 mm # mean Sauter diameter (1) density: ...
I have written a naive max flow with DFS, could anyone review my below code. What can be done to improve the code and what are the worst cases where this won’t work acceptably? #include <stdio.h> #include <stdlib.h> #define SZ 20 int flow[SZ][SZ]; int residue[SZ][SZ]; int N, E, u, v, c; int Source, Sink; int visited...
Following up from my previous question Streaming my UPS metrics for graphical viewing in bash #!/usr/bin/env bash [ -v METRICS_CHECK ] && set -x API_URL="https://api.thingspeak.com/update" UPS_PROPS=("LINEV" "LOADPCT" "TIMELEFT") API_PARAMS=("api_key==XXXXXXXXXXXXXX") for index in "${!UPS_PROPS[@]}" do value=$...
I'm making a currency exchange app, it works as follows: User types in on desired currency input and the rest of the input fields change with state based on the currency value from the input used, I'm providing the main component (container), but this codesandbox has a working demo. I need some help or guidance on how...
As far as I know, I cannot create function to accept anonymous type as parameter and I am reluctant to create new class to store those anonymous type because their difference is calculatedPrice. How else can I remove\minimize repeated code in code below? //.NET Framework 4 protected void btnDownload_Click(object sender...
I have made a simple program that tests if the given element exists in any STL container. The program tests if the container has a find member function. It will use it if it does. Otherwise, it will call the STL find function instead. I would like to know how I can improve it further? #include <iostream> #include <algo...
I am working on cleaning up and making open source a C++ reflection library that has served me well over the last few years. One of the most important classes of the library is Object, which is used to contain and work with1 any type derived from the object's template parameter T (or any type at all if T is void). I am...
I'm writing this as a follow-up for my previous question posted here: I've successfully decoded a large histogram into a byte array, which is written to a file. I'm now focusing on returning the byte array back to the token-based String. Details on how the tokens work are in the previous example. I've created a method,...
I wrote a small program which downloads song or video from the given youtube link. I used pytube library https://github.com/nficano/pytube and for GUI (Tkinter). from pytube import YouTube import tkinter as tk from tkinter import ttk from tkinter import filedialog import re import threading """Program downloads song o...
I created this method that adds a new situation to the situation list. The situation has a many-to-one relation with project.task. This method seems a little longer than it should be and I don't know how to optimize it: @api.multi def create_situation(self): active_id = self.env.context.get('active_ids', []) or [] ...
The code imports 3 types of files, depending on the button selected. Something I might add is a check that the user has selected the right file - not too sure how I could do this. I've been working on this code for about 2 weeks, and I've got it to a point where I'm happy. It's functional, copies data correctly, and al...
I have written a cpp program which demonstrates the use of the following functionalities in modern cpp. Lambda Functions std::generate std::vector std::erase std::remove_if std::remove std::max_element std::for_each std::shuffle I want to understand the following (1) Have I written the code properly or there are somet...
The task is to implement a solveEquation function, which solves the Quadratic equation. Each equality has exact 2 integer solutions. Return those numbers as an ordered array. Example: const solutions = solveEquation('2 * x^2 - 10 * x + 12'); console.log(solutions); // [2, 3] Solution: function solveEquation(equation) ...
There is a blockchain class with minimal functionality inspired by naivechain. It has template data and hash function parameters: #include "blockchain_block.hpp" #ifndef BLOCKCHAIN_HPP #define BLOCKCHAIN_HPP #include <string> #include <list> #include <type_traits> namespace rzd { template < typename T, typename...
I'm currently learning Haskell and are starting to understand applicatives. I wanted an Either Applicative where the left side is a monoid, so I created this as a learning exercise: module EitherLeftMonoid where data Error = InvalidName | UnderAge deriving (Eq, Show) data Person = Person { name :: String, age :: Int ...
The class defines functions to threshold an image for a given range and Sobel kernel. Each function has similarities, i.e. they share the same following tasks: each function converts an image to grayscale take the gradient rescale to 8 bit apply a threshold, and create a binary image result class GRADIENT_THRESHOLD(o...
I'm learning about Node.js and also Express.js, and attempting to create a forum like website in the process of such, I currently want the user to be able to register an account, and then log into it which is handled via MongoDB using Mongoose async function FindUser(username) { return new Promise((res, rej) =>{ ...
We have project.task model, where each task has many lines and each line has progress field indicating how much work has been done and how much still remaining (from 0 to 100 percent). The task cannot be done until all lines' progress is 100%. @api.onchange('task_line_ids','task_line_rider_ids') def progress_on_change(...
I am trying to port a piece of code from Python to C. What the code does is that it generates a list of precomputed MD5 hash from a plaintext wordlist. The code also has its variations in SHA-1 and SHA-2 families in all 3 programming languages. The structure is the same. I originally wrote the code in Bash, which was s...
I've implemented a simple polymorphic structure, which looks a bit ugly and I'm afraid I am missing an idiomatic way of doing it. To describe briefly what I'm trying to achieve here: I would like to have a structure with a collection of handlers, which all must implement specific trait. use std::fmt; use std::fmt::Form...
I'm writing a multi-layer perceptron from scratch and I think it's way slower than it should be. the culprit seems to be my compute_gradients-function, which according to my investigation answers for most of the execution time. It looks like this: def compute_gradients(X, Y, S1, H, P, W1, W2, lamb): # Y must be one...
So I have a working game of Tic-Tac-Toe with an AI that plays random moves. Is anyway to maybe shorten the endturn() function so it's not so long? Also is this set up well enough to add a mode where the computer plays optimal or sub-optimal moves and a mode impossible to beat? using System.Collections; using System.Col...
(function ($) { "use strict"; $(document).ready(function () { $('.bookinginput').on('change', function(){ var adults = $('#t_adults_qty').val(), child = $('#t_children_qty').val(), pickup = $('#pick_up_list').val(), priceBase =...
In my deployment I need to generate a zip file from a git repo. I have the basic work done with how to pull the latest tag and create the zip file. I ended wanting to update the files that are pulled down to have the last modified of the last commit instead of when I just checked them out. # Set-ExecutionPolicy -Execut...
Can anyone give me some feedback if I'm using std::unordered_multimap optimally? I don't know the ins-and-outs of the std::unordered_multimap implementation. I'm wondering if comparing two maps iterates through each of the elements in the map, making the algorithm \$O(N^2)\$ or if it just compares the hash of the map o...
I have written a program that outputs the hexadecimal representation of an array of bytes. The program works just fine, and I am confident (thanks to valgrind) that I don't have any memory leaks. However, I am not so confident I am doing this the simplest, nor most readable way. It seems to me I have written a lot of c...
One of the answers to Determine if cell contains data validation got me thinking about an edge case I needed to solve. If cell happens to be a multi-cell range what's the best way to answer? The answer below returns False if the range contains both a cell with and without validation. Function HasValidation(cell As Ran...
I have read a lot and spent a lot of hours trying to reach the right way to set a good htaccess in order to redirect an HTTP site to HTTPS. There are a lot of tutorials on the Internet, even on Stack Overflow, but some of them seem to be outdated and don't meet good SEO practices. The scenario is the following one: My...
I am working on a little complicated shell script for the first time and this is what it should do: During startup, it figures out what is my clientid by looking at host-mapping.txt file. If I cannot find clientid for my hostname then I need to exit from the shell script with a non-zero status code and log error messa...
This code is a bidirectional BFS search. Given any two points in a matrix having 0's and 1's, I would like to find if there exists a path between them. Also note that it is forbidden to enter a cell that has a value of 0. One note I would like to make about the code is that I have maintained a duplicate matrix to check...
I solved this problem using a Class, but thought I might try to figure out this memoization thing. Problem There are two printers that print pages at different speeds (X, Y). What is the minimum amount of time it takes to print (N) pages? Input Data First line contains the number of test cases Each test case is on a n...
I am developing an online shopping website. I have a class Item, which contains all the common attributes of all products (I will explain the interfaces at the end) // all products common attribues public class Item: ISearchItem { public int? itemId { get; set; } public int userId { get; set; } ...
As a follow up to this first attempt to create and use my own IObservable<T> implementation, this is version 2.0. The goal has been to correct the code where there were conceptual misunderstandings and to take the issues pointed to by answers into account. The overall concept is the same: A scheduler that can fire off...
I am also pretty new to Python so I want to show my code for a very small currency converter with an Tkinter GUI. The code does what I want, but now I want to optimize it and find new "next level" topics for me to learn. So I would be happy if some of you could take a look on my code and please give me constructive cri...
Skip List Header File #include <random> #include <iostream> #include <algorithm> struct Node { Node(int vv, Node*nn = nullptr) : val{ vv }, next{ nn }{} Node() : val{ 0 }, next{ nullptr } {} //Node(const Node &n); //copy constructor //Node& operator=(Node &n); //copy assignment ~Node() { ...
I've been trying to rewrite the perl transliteration function in javascript. This isn't a complete replication, and I haven't looked at the perl source code... I took inspiration from this question for my source code. some unit tests (not all): describe('without flags', () => { it('should produce a function that tra...
A span provides a view to a contiguous piece of memory. Internally a span wraps a pointer, and a size. I tried an existing implementation: gsl-lite. A function like template <typename T> void f(gsl::span<const T>& s) {} can't accept a gsl::span<T> as an argument. The problem is that no type conversion can occur during...
I'm finishing the book C Primer Plus by Stephen Prata and I wrote as a part of the homework program to convert binary string to decimal number: #include <stdio.h> #include <string.h> typedef unsigned char byte; typedef unsigned int uint; int strbin_to_dec(const char *); int main(void) { char * wbin = "01001001";...
Please also see the new version here So I've been trying to make a blackjack game as my first attempt at an OOP project. The program is working, but not yet finished as it is lacking three major features that I couldn't figure out how to implement. Not being able to deal the same card more than once Automatically chan...
I build a RESTful CRUD API with Node.js and Express. This application allows, for example, to create a table on the client side with the ability to add, update and remove data by ID. I generate an array of random data for the availability of data when you start working on the client side with the table. I will be grate...
The following code animates an item's Y position based on how much of its parent is currently visible. This is the first time I ever animated something on JavaScript based on the window scroll position and the current performance is extremely bad. I am looking for ways to get this running as fast as possible for a smoo...
Let assume a table has more than 100 of columns & I want to display all the rows when all of its columns (Col1, Col2, ..., ColN) are nulls except for the column(s) I mentioned (PK). This is just a sample table I created to explain this question. Sample Table with data +----+------+------+------+------+ | PK | Col1 | C...
I am evaluating if a list of pathways and its genes has pathways included in another pathways. So the way I thought about it is to create a function that does just a single comparison. all_in <- function(x, y) { if (length(x) > length(y)) { 0 } else { ifelse(all(x %in% y), 1, 0) } } And then Vectorize t...
Here is an attempt at implementing the simplest Neural Network, which is an algorithm for learning a binary classifier. In this specific case, it can decide whether an input, of a pair of Cartesian coordinates, belongs to some specific class or not. main.cpp #include <iostream> #include <iomanip> #include <fstream> #in...
I have a comparator function I use with qsort to sort an array of char* (i.e., char**), which compiles with current versions of Clang and GCC without giving errors or warnings: static int comparator(const void* a, const void* b) { #ifdef __cplusplus auto a_recast = const_cast<void *>(a); auto b_recast = const_c...
I am pretty new to Java and I got a requirement of converting Strings to a json structure. My below codes works fine but I have to create multiple objects and my code looks bit ugly. I want to know the better approach. I want the below Json Structure from three Strings SourceApplication, messagType and payload Require...
Basically, I declared a char array to hold a maximum size of 100 char arrays. #include <stdlib.h> #include <memory.h> #include <stdio.h> int add_to_urls(char **urls, char *url) { for (int i = 0; i < 100; i++) { if (urls[i] == NULL) { urls[i] = malloc(sizeof(strlen(url) + 1)); strcpy...
I am new to Python and only just started learning about functions. I stumbled upon a question which recommends using function to print triangles in such a format: Enter height: 5 /\ / \ / \ / \ /________\ /\ /\ / \ / \ / \ / \ / \ / ...
I have such part of function: $token = $this->getToken($user); if ('main' !== session('type') && is_null($token)) { $instagramProfile = $this->findInstagramProfile($user); $token = $instagramProfile->profile->user->api_token ?? null; } else { if (!$instagramProfile = $this->findInstagra...