Categories
Mastering Development

Sorting an array pulled from database using $obj->select

I have inherited a project from another developer that has a bunch of dropdown menus that pull information from the database. The way this is set up is as follows: $agent_list = $obj->select(TABLEPRIFIX.’agent’, ‘*’, [‘status’ =>1 ]); If I am reading this correctly it is basically saying “select table ‘the_agent’ and grab everything with a […]

Categories
Database Development

Replace a sequential set of numbers with special character

I have a varchar(200) column that contains entries such as, ABC123124_A12312 ABC123_A1212 ABC123124_B12312 AC123124_AD12312 A12312_123 etc.. I want to replace a sequence of numbers with a single * so that I can group the distinct non-numeric patterns in the table. The result for this set would be ABC*_A* ABC*_B* AC*_AD* A*_* I have written the […]

Categories
Cryptocurrency Development Ethereum

Go-ethereum light node does not provide getTransactionReceipt after upgrade

I’m running the following services in docker: go-ethereum 1.9.11-stable-6a62fe39 in light mode python 3.7-alpine app with Web3 v5.5.1. Geth node startup is straightforward: image: ethereum/client-go:stable command: [‘–syncmode’, ‘light’, ‘–rpc’, ‘–rpcaddr’, ‘0.0.0.0’, ‘–rpcvhosts’, ‘*’, ‘–ws’, ‘–wsaddr’, ‘0.0.0.0’] volumes: – ./eth-data:/root/.ethereum web3.eth.getTransaction returns correct tx information web3.eth.getTransactionReceipt raises TransactionNotFound exception Previously node was running in version 1.8 […]

Categories
Development

Regex python – Match newline only if it is followed by number or special character and space

I’ve been trying to figure out this regex in Python but it’s not been producing the expected result. I have a text file which I load that is in the format of: “18 75 19\n!dont split here\n! but split here\n* and split here” I’d like to get the following output: [’18 75 19\n!dont split here’, […]

Categories
Development

How to to add stacked bar plot hatching in pandas? (…or how to get BarContainer vs AxisSubplot in pandas plot vs. matplotlib?)

I have a code example using matplotlib.pyplot.plot() that works and that that I want to replicate to make hatched bar segments on a stacked bar chart. However, I have been making all of my other graphics using pandas.DataFrame.plot() instead of matplotlib.pyplot.plot() and would like to continue this here as well. The example code returns a […]

Categories
Development

opencv throws errors when building cap_avfoundation_mac

Compiling opencv on MacOS Mojave; everything was going well until make threw an error at cap_avfoundation_mac. Make complained about error: stray ‘@’ in program and then went on to throw a bunch of errors on files included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks. The errors go on for absolutely forever; however, most of them seem to be the same. […]

Categories
Development

In C, how to create a function that, given a string literal as a parameter, returns a char*? (Without allocating new memory on the heap)

Desired outcome: utilityfun(“&xxx”) must return a pointer to “xxx”. utilityfun(“xxx”) must return a pointer to “*xxx”. #include <stdio.h> #include <string.h> char* utilityfun(char *s) { if(*s==’&’) return s+1; // this case works fine else { char r[strlen(s)+2]; memset(r,’*’,1); strcpy(r+1,s); char* p=r; return p; // !!! p is local to this stack frame! } } void main() […]

Categories
Development

Need help fixing “undefined reference to” error [duplicate]

This question already has an answer here: What is an undefined reference/unresolved external symbol error and how do I fix it? 32 answers I have this project where I have to create a Class and use getters and setters to print the information. Here is my code so far: My main: //Main program #include <iostream> […]

Categories
Development Java Javascript

Javascript – Simplification of prefix notation

I am working on a kattis problem, where I am suppose to take the input in prefix notation, simplify it and return it in prefix notation as well. This are the examples of inputs and outputs: Sample Input 1 Sample Output 1 + 3 4 Case 1: 7 – x x Case 2: – x […]