ActionBarSherlock / IntelliJ (Android Studio) - Newest Versions - actionbarsherlock

I have seen all the posts pointing to various guides purporting to get ABS working with IntelliJ (Android Studio), including here, and here.
For the most recent version of ABS and AS, they don't work.
Generally, the tutorial doesn't match the IDE. Getting past that, and assuming that doing an 'import module' using gradle instead of maven is allowed, I eventually get:
Plugin with id 'android-library' not found
Does anyone have a tutorial for getting the latest version of ABS working with the latest version of AS?
Fwiw, I tried going the Eclipse route with the intention of exporting and then trying to bring it into AS (this is definitely not my preferred path), but I ended-up getting a bunch of "Unable to execute dex: Multiple dex files define..." errors surrounding Jackson.
If it's useful, here is my build.gradle, but my preferred solution would use more "standard" mechanisms than mucking with that and would also, then, more likely be useful to others. Here's the file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
And, my project directory structure:
D:.
└───T-n-T
├───.gradle
│ └───1.6
│ └───taskArtifacts
├───.idea
│ ├───copyright
│ ├───libraries
│ └───scopes
├───assets
├───bin
│ ├───classes
│ │ └───com
│ │ └───pha
│ │ └───t-n-t
│ │ ├───models
│ │ └───services
│ └───res
├───build
│ ├───apk
│ ├───assets
│ │ └───debug
│ ├───classes
│ │ └───debug
│ │ └───com
│ │ └───pha
│ │ └───t-n-t
│ │ ├───models
│ │ └───services
│ ├───dependency-cache
│ │ └───debug
│ ├───incremental
│ │ ├───aidl
│ │ │ └───debug
│ │ ├───dex
│ │ │ └───debug
│ │ ├───mergeAssets
│ │ │ └───debug
│ │ └───mergeResources
│ │ └───debug
│ ├───libs
│ ├───manifests
│ │ └───debug
│ ├───res
│ │ ├───all
│ │ │ └───debug
│ │ │ ├───drawable-hdpi
│ │ │ ├───drawable-mdpi
│ │ │ ├───drawable-xhdpi
│ │ │ ├───drawable-xxhdpi
│ │ │ ├───layout
│ │ │ ├───menu
│ │ │ ├───values
│ │ │ ├───values-sw720dp-land
│ │ │ ├───values-v11
│ │ │ ├───values-v14
│ │ │ └───xml
│ │ └───rs
│ │ └───debug
│ ├───source
│ │ ├───aidl
│ │ │ └───debug
│ │ ├───buildConfig
│ │ │ └───debug
│ │ │ └───com
│ │ │ └───pha
│ │ │ └───t-n-t
│ │ ├───r
│ │ │ └───debug
│ │ │ └───com
│ │ │ └───pha
│ │ │ └───t-n-t
│ │ └───rs
│ │ └───debug
│ └───symbols
│ └───debug
├───gen
│ └───com
│ └───pha
│ └───t-n-t
├───gradle
│ └───wrapper
├───libs
├───res
│ ├───drawable-hdpi
│ ├───drawable-ldpi
│ ├───drawable-mdpi
│ ├───drawable-xhdpi
│ ├───drawable-xxhdpi
│ ├───layout
│ ├───menu
│ ├───values
│ ├───values-sw600dp
│ ├───values-sw720dp-land
│ ├───values-v11
│ ├───values-v14
│ └───xml
└───src
└───com
└───pha
└───t-n-t
├───models
└───services
It should be noted that this represents the project after having rolled it back after a failed attempt to get this working.
UPDATE
I don't know if it's progress, but it's different. I have what I think is the library project from ABS sitting with my main project, and added as a module. I think this is the case because in the IDE, in the main project, SherlockActivity seems to be available. I can extend it (sort of) and can import it's namespace (com.actionbarsherlock.app). I say sort of because everything is fine until I try to build, at which point I get:
Gradle: package com.actionbarsherlock.app does not exist
Gradle: cannot find symbol class SherlockActivity
and the build fails. So something is clearly not quite right.
Any suggestions?
SOLVED
Wow. What a pain. What I ultimately ended-up doing:
As described by others
1) Download and extract ABS
2) Save it in its own folder under your primary project (say ActionBarSherlock)
3) Import it as a Module (new: use Maven / pom.xml - make sure Export is checked)
Pulled from other sources
4) Exclude the ActionBarSherlock/target directory (Open Module Settings)
5) If your primary project uses the support library, change that dependency to Provided (Open Module Settings)
Again, I'm not sure why this was so difficult, or if I've done it correctly, or that there aren't any issues yet to be found (I have an empty Activity which extends SherlockActivity, it does build, and I can deploy it to, and run it on, an emulator), but there you go.

For me the following works fine :
Copy the actionbarsherlock directory to your project root to have
MyAppProject
|-actionbarsherlock
|--build.gradle
|-MyApp
|--build.gradle
|-build.gradle
|-settings.gradle
build.gradle of actionbarsherlock
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion '17.0.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
build.gradle of MyApp
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile project(':actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 17
}
}
settings.gradle
include ':MyApp', ':actionbarsherlock'
and nothing in the MyAppProject build.gradle
Next Right clik on your MyAppProject > Open Module settings
And on the module section import module and select actionbarsherlock directory. Apply
and to verify re open modul settings, go Modules, click on YourApp and verify if on the dependencies you have actionbarsherlocj on scope compile. if yes, you are ready .

From my update to the question, above:
What I ultimately ended-up doing:
As described by others
1) Download and extract ABS
2) Save it in its own folder under your primary project (say, ActionBarSherlock)
3) Import it as a Module (new: use Maven / pom.xml - make sure Export
is checked)
Pulled from other sources
4) Exclude the ActionBarSherlock/target directory (Open Module
Settings)
5) If your primary project uses the support library, change that
dependency to Provided (Open Module Settings)
Again, I'm not sure why this was so difficult, or if I've done it correctly, or that there aren't any issues yet to be found (I have an empty Activity which extends SherlockActivity, it does build, and I can deploy it to, and run it on, an emulator), but there you go.
UPDATE
This configuration ended up not working. How or why it fell apart, I don't know. But after restarting AS, it fell apart. Following the steps here - again - did, this time, get it working.

Related

Trait not implemented for a thing I think implements the trait

I am trying to call a method from a rust crate and getting an error stating that a trait is not implemented for one of the methods I am passing however when I look the method up on docs.rs it does appear to be implementing the required trait.
I am trying to call a method called new_with_count from a crate called wagyu_ethereum.
The code I am using to make the call is here:
use rand::{rngs::StdRng, SeedableRng};
use wagyu_ethereum::*;
use wagyu_model::mnemonic::MnemonicCount;
use wagyu_model::MnemonicError;
pub fn generate_mnemonic() -> Result<String, MnemonicError> {
let mut rng = StdRng::from_entropy();
let mnemonic = EthereumMnemonic::<
wagyu_ethereum::network::Mainnet,
wagyu_ethereum::wordlist::English,
>::new_with_count(&mut rng, 24)?;
Ok(String::from("placeholder"))
}
The code for the method (from the projects GitHub page:
impl<N: EthereumNetwork, W: EthereumWordlist> MnemonicCount for EthereumMnemonic<N, W> {
/// Returns a new mnemonic given the word count.
fn new_with_count<R: Rng>(rng: &mut R, word_count: u8) -> Result<Self, MnemonicError> {
let length: usize = match word_count {
12 => 16,
15 => 20,
18 => 24,
21 => 28,
24 => 32,
wc => return Err(MnemonicError::InvalidWordCount(wc)),
};
let entropy: [u8; 32] = rng.gen();
Ok(Self {
entropy: entropy[0..length].to_vec(),
_network: PhantomData,
_wordlist: PhantomData,
})
}
}
The error:
error[E0277]: the trait bound `StdRng: rand_core::RngCore` is not satisfied
--> src/lib.rs:12:23
|
9 | let mnemonic = EthereumMnemonic::<
| ____________________-
10 | | wagyu_ethereum::network::Mainnet,
11 | | wagyu_ethereum::wordlist::English,
12 | | >::new_with_count(&mut rng, 24)?;
| | - ^^^^^^^^ the trait `rand_core::RngCore` is not implemented for `StdRng`
| |_____________________|
| required by a bound introduced by this call
|
= help: the following other types implement trait `rand_core::RngCore`:
&'a mut R
Box<R>
rand::rngs::adapter::read::ReadRng<R>
rand::rngs::adapter::reseeding::ReseedingRng<R, Rsdr>
rand::rngs::entropy::EntropyRng
rand::rngs::mock::StepRng
rand::rngs::std::StdRng
rand::rngs::thread::ThreadRng
and 6 others
= note: required because of the requirements on the impl of `rand::Rng` for `StdRng`
note: required by a bound in `new_with_count`
--> /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/wagyu-model-0.6.3/src/mnemonic.rs:44:26
|
44 | fn new_with_count<R: Rng>(rng: &mut R, word_count: u8) -> Result<Self, MnemonicError>;
| ^^^ required by this bound in `new_with_count`
So as far as I can tell from the documentation on docs.rs it appears that StdRng does actually implement RngCore. I've also found this question that indicates I might be borrowing to many time but I'm not sure if it is relevant here because I don't think I am borrowing as many times.
Finally on the projects Github account they have instances of calling the method the same way I am doing (method call, rng assignment). This is what prompted me to use this method. Their program also works when you run it. So the question I have is what am I doing wrong when trying to call this method?
At the time of writing, the newest versions are:
rand = "0.8.5"
wagyu-ethereum = "0.6.3"
wagyu-model = "0.6.3"
It seems that a version mismatch exists here. wagyu-ethereum = "0.6.3" depends on rand = "0.7.3", while the current default if you do cargo add rand is rand = "0.8.5".
You can see this in cargo tree:
rust_test v0.1.0 (/home/me/work/rust_test)
├── rand v0.8.5
│ ├── libc v0.2.139
│ ├── rand_chacha v0.3.1
│ │ ├── ppv-lite86 v0.2.17
│ │ └── rand_core v0.6.4
│ │ └── getrandom v0.2.8
│ │ ├── cfg-if v1.0.0
│ │ └── libc v0.2.139
│ └── rand_core v0.6.4 (*)
├── wagyu-ethereum v0.6.3
│ ├── base58 v0.1.0
│ ├── bitvec v0.17.4
│ │ ├── either v1.8.0
│ │ └── radium v0.3.0
│ ├── ethereum-types v0.9.2
│ │ ├── ethbloom v0.9.2
│ │ │ ├── crunchy v0.2.2
│ │ │ ├── fixed-hash v0.6.1
│ │ │ │ ├── byteorder v1.4.3
│ │ │ │ ├── rand v0.7.3
│ │ │ │ │ ├── getrandom v0.1.16
│ │ │ │ │ │ ├── cfg-if v1.0.0
│ │ │ │ │ │ └── libc v0.2.139
│ │ │ │ │ ├── libc v0.2.139
│ │ │ │ │ ├── rand_chacha v0.2.2
│ │ │ │ │ │ ├── ppv-lite86 v0.2.17
│ │ │ │ │ │ └── rand_core v0.5.1
│ │ │ │ │ │ └── getrandom v0.1.16 (*)
│ │ │ │ │ └── rand_core v0.5.1 (*)
│ │ │ │ ├── rustc-hex v2.1.0
│ │ │ │ └── static_assertions v1.1.0
│ │ │ ├── impl-rlp v0.2.1
│ │ │ │ └── rlp v0.4.6
│ │ │ │ └── rustc-hex v2.1.0
│ │ │ ├── impl-serde v0.3.2
│ │ │ │ └── serde v1.0.152
│ │ │ │ └── serde_derive v1.0.152 (proc-macro)
│ │ │ │ ├── proc-macro2 v1.0.49
│ │ │ │ │ └── unicode-ident v1.0.6
│ │ │ │ ├── quote v1.0.23
│ │ │ │ │ └── proc-macro2 v1.0.49 (*)
│ │ │ │ └── syn v1.0.107
│ │ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ │ ├── quote v1.0.23 (*)
│ │ │ │ └── unicode-ident v1.0.6
│ │ │ └── tiny-keccak v2.0.2
│ │ │ └── crunchy v0.2.2
│ │ ├── fixed-hash v0.6.1 (*)
│ │ ├── impl-rlp v0.2.1 (*)
│ │ ├── impl-serde v0.3.2 (*)
│ │ ├── primitive-types v0.7.3
│ │ │ ├── fixed-hash v0.6.1 (*)
│ │ │ ├── impl-codec v0.4.2
│ │ │ │ └── parity-scale-codec v1.3.7
│ │ │ │ ├── arrayvec v0.5.2
│ │ │ │ ├── bitvec v0.17.4 (*)
│ │ │ │ ├── byte-slice-cast v0.3.5
│ │ │ │ └── serde v1.0.152 (*)
│ │ │ ├── impl-rlp v0.2.1 (*)
│ │ │ ├── impl-serde v0.3.2 (*)
│ │ │ └── uint v0.8.5
│ │ │ ├── byteorder v1.4.3
│ │ │ ├── crunchy v0.2.2
│ │ │ ├── rustc-hex v2.1.0
│ │ │ └── static_assertions v1.1.0
│ │ └── uint v0.8.5 (*)
│ ├── hex v0.4.3
│ ├── hmac v0.7.1
│ │ ├── crypto-mac v0.7.0
│ │ │ ├── generic-array v0.12.4
│ │ │ │ └── typenum v1.16.0
│ │ │ └── subtle v1.0.0
│ │ └── digest v0.8.1
│ │ └── generic-array v0.12.4 (*)
│ ├── pbkdf2 v0.3.0
│ │ ├── byteorder v1.4.3
│ │ ├── crypto-mac v0.7.0 (*)
│ │ └── rayon v1.6.1
│ │ ├── either v1.8.0
│ │ └── rayon-core v1.10.1
│ │ ├── crossbeam-channel v0.5.6
│ │ │ ├── cfg-if v1.0.0
│ │ │ └── crossbeam-utils v0.8.14
│ │ │ └── cfg-if v1.0.0
│ │ ├── crossbeam-deque v0.8.2
│ │ │ ├── cfg-if v1.0.0
│ │ │ ├── crossbeam-epoch v0.9.13
│ │ │ │ ├── cfg-if v1.0.0
│ │ │ │ ├── crossbeam-utils v0.8.14 (*)
│ │ │ │ ├── memoffset v0.7.1
│ │ │ │ │ [build-dependencies]
│ │ │ │ │ └── autocfg v1.1.0
│ │ │ │ └── scopeguard v1.1.0
│ │ │ │ [build-dependencies]
│ │ │ │ └── autocfg v1.1.0
│ │ │ └── crossbeam-utils v0.8.14 (*)
│ │ ├── crossbeam-utils v0.8.14 (*)
│ │ └── num_cpus v1.15.0
│ │ └── libc v0.2.139
│ ├── rand v0.7.3 (*)
│ ├── regex v1.7.0
│ │ ├── aho-corasick v0.7.20
│ │ │ └── memchr v2.5.0
│ │ ├── memchr v2.5.0
│ │ └── regex-syntax v0.6.28
│ ├── rlp v0.4.6 (*)
│ ├── secp256k1 v0.17.2
│ │ └── secp256k1-sys v0.1.2
│ │ [build-dependencies]
│ │ └── cc v1.0.41
│ ├── serde v1.0.152 (*)
│ ├── serde_json v1.0.91
│ │ ├── itoa v1.0.5
│ │ ├── ryu v1.0.12
│ │ └── serde v1.0.152 (*)
│ ├── sha2 v0.8.2
│ │ ├── block-buffer v0.7.3
│ │ │ ├── block-padding v0.1.5
│ │ │ │ └── byte-tools v0.3.1
│ │ │ ├── byte-tools v0.3.1
│ │ │ ├── byteorder v1.4.3
│ │ │ └── generic-array v0.12.4 (*)
│ │ ├── digest v0.8.1 (*)
│ │ ├── fake-simd v0.1.2
│ │ └── opaque-debug v0.2.3
│ ├── tiny-keccak v1.5.0
│ │ └── crunchy v0.2.2
│ └── wagyu-model v0.6.3
│ ├── base58 v0.1.0
│ ├── base58-monero v0.2.1
│ │ ├── async-stream v0.2.1
│ │ │ ├── async-stream-impl v0.2.1 (proc-macro)
│ │ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ │ ├── quote v1.0.23 (*)
│ │ │ │ └── syn v1.0.107 (*)
│ │ │ └── futures-core v0.3.25
│ │ ├── futures-util v0.3.25
│ │ │ ├── futures-core v0.3.25
│ │ │ ├── futures-macro v0.3.25 (proc-macro)
│ │ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ │ ├── quote v1.0.23 (*)
│ │ │ │ └── syn v1.0.107 (*)
│ │ │ ├── futures-task v0.3.25
│ │ │ ├── pin-project-lite v0.2.9
│ │ │ ├── pin-utils v0.1.0
│ │ │ └── slab v0.4.7
│ │ │ [build-dependencies]
│ │ │ └── autocfg v1.1.0
│ │ ├── thiserror v1.0.38
│ │ │ └── thiserror-impl v1.0.38 (proc-macro)
│ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ ├── quote v1.0.23 (*)
│ │ │ └── syn v1.0.107 (*)
│ │ ├── tiny-keccak v2.0.2 (*)
│ │ └── tokio v0.2.25
│ │ ├── bytes v0.5.6
│ │ ├── futures-core v0.3.25
│ │ ├── memchr v2.5.0
│ │ └── pin-project-lite v0.1.12
│ ├── bech32 v0.6.0
│ ├── byteorder v1.4.3
│ ├── crypto-mac v0.7.0 (*)
│ ├── ethereum-types v0.9.2 (*)
│ ├── failure v0.1.8
│ │ ├── backtrace v0.3.57
│ │ │ ├── addr2line v0.14.1
│ │ │ │ └── gimli v0.23.0
│ │ │ ├── cfg-if v1.0.0
│ │ │ ├── libc v0.2.139
│ │ │ ├── miniz_oxide v0.4.4
│ │ │ │ └── adler v1.0.2
│ │ │ │ [build-dependencies]
│ │ │ │ └── autocfg v1.1.0
│ │ │ ├── object v0.23.0
│ │ │ └── rustc-demangle v0.1.21
│ │ └── failure_derive v0.1.8 (proc-macro)
│ │ ├── proc-macro2 v1.0.49 (*)
│ │ ├── quote v1.0.23 (*)
│ │ ├── syn v1.0.107 (*)
│ │ └── synstructure v0.12.6
│ │ ├── proc-macro2 v1.0.49 (*)
│ │ ├── quote v1.0.23 (*)
│ │ ├── syn v1.0.107 (*)
│ │ └── unicode-xid v0.2.4
│ ├── ff v0.6.0
│ │ ├── byteorder v1.4.3
│ │ └── rand_core v0.5.1 (*)
│ ├── hex v0.4.3
│ ├── rand v0.7.3 (*)
│ ├── rand_core v0.5.1 (*)
│ ├── ripemd160 v0.8.0
│ │ ├── block-buffer v0.7.3 (*)
│ │ ├── digest v0.8.1 (*)
│ │ └── opaque-debug v0.2.3
│ ├── rlp v0.4.6 (*)
│ ├── secp256k1 v0.17.2 (*)
│ ├── serde_json v1.0.91 (*)
│ ├── sha2 v0.8.2 (*)
│ └── uint v0.8.5 (*)
└── wagyu-model v0.6.3 (*)
Usually, Cargo tries to find a single common version of a library for all dependencies, but 0.7.x and 0.8.x are not compatible according to Rust's semver rules, so it includes the library twice. Of course it can't allow those two to be used with each other, as the results would be unpredictable.
While the problem is complicated and obscure, the solution is simple:
Use rand = "0.7.3" in your Cargo.toml until wagyu gets upgraded to rand = "0.8.x".
You could open an issue in their issue-tracker about it, but it seems that the project as a whole didn't get maintained since over a year. Their website doesn't even exist any more. So be aware that this project might be abandoned.

Google Cloud Storage NodeJS multiple read requests loading too slow

how do you do?
I'm trying to figure out why some requests to my Images API (usually the last ones) are taking over than 1 minute to load. The first ones are basically instantaneous. Search all over the internet, but had no apropriate answer yet. I am using Google Cloud to storage the images and NodeJS at the server, who is providing the images as a bufferized writing head to the browser.
You can check what am I saying accessing the website (18 year old content):
https://divinasacompanhantes.com/
As you can see, some images just don't load properly. I'm worried because this website is expected to have thousands more profiles, all over the world.
I am using PM2 to handle the services at the server side (2GB available memory). Here's the table:
┌─────┬─────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼─────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 7 │ ServiceAfiliado │ default │ 1.0.0 │ fork │ 31312 │ 20m │ 3 │ online │ 0% │ 55.9mb │ root │ disabled │
│ 0 │ ServiceAvaliacao │ default │ 1.0.0 │ fork │ 31249 │ 20m │ 3 │ online │ 0% │ 55.2mb │ root │ disabled │
│ 8 │ ServiceBlog │ default │ 1.0.0 │ fork │ 31330 │ 20m │ 3 │ online │ 0% │ 61.1mb │ root │ disabled │
│ 1 │ ServiceChat │ default │ 1.0.0 │ fork │ 31256 │ 20m │ 3 │ online │ 0% │ 57.3mb │ root │ disabled │
│ 9 │ ServiceConfig │ default │ 1.0.0 │ fork │ 31337 │ 20m │ 3 │ online │ 0% │ 56.2mb │ root │ disabled │
│ 10 │ ServiceImage │ default │ 1.0.0 │ fork │ 31904 │ 0s │ 13 │ online │ 0% │ 19.1mb │ root │ disabled │
│ 2 │ ServiceLead │ default │ 1.0.0 │ fork │ 31269 │ 20m │ 3 │ online │ 0% │ 54.8mb │ root │ disabled │
│ 3 │ ServiceMail │ default │ 1.0.0 │ fork │ 31276 │ 20m │ 3 │ online │ 0% │ 43.3mb │ root │ disabled │
│ 4 │ ServicePagamento │ default │ 1.0.0 │ fork │ 31289 │ 20m │ 3 │ online │ 0% │ 42.5mb │ root │ disabled │
│ 5 │ ServiceParceiro │ default │ 1.0.0 │ fork │ 31296 │ 20m │ 3 │ online │ 0% │ 60.1mb │ root │ disabled │
│ 6 │ ServicePerfil │ default │ 1.0.0 │ fork │ 31309 │ 20m │ 3 │ online │ 0% │ 69.7mb │ root │ disabled │
└─────┴─────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
The route handling this specific request:
router.get('/image/:imageId', async function (req, res) {
try {
let imageId = req.param('imageId')
let returnImage = await cloudController.getImageFromBucket('fotos_perfil', imageId)
res.writeHead(200, {'Content-Type': 'image/jpg'});
returnImage.on('data', (data) => {
res.write(data)
})
returnImage.on('error', (error) => {
res.status(400).send('Erro lendo a imagem')
console.error(error)
})
returnImage.on('end', () => {
res.end()
})
} catch (err) {
res.status(500).send('Internal Server Error')
}
})
And the controller associated:
async function getImageFromBucket(bucket, imageId) {
return new Promise((resolve, reject) => {
try {
let imageInfo = storage.bucket(bucket).file(imageId).createReadStream()
resolve(imageInfo)
} catch (e) {
reject(e)
}
})
}
Can anyone provide me some ideas to solve this? I've read the official Google documentation and the tip is to use fast-crc32c, but only. No clues on how to configure...

How to create react app using create-react-app with reactjs 15 version [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have a project which is written 3 years ago in reactjs 15 version and also it is single tier architecture project. I am right now converting it to 3 tier project architecture. So I thought of having the react part alone. My question is how should I create a reactJS folder structure using the new create-react-app and add the already existing code into it. I know this question might be broad. But any steps will help me to better understand the structure to be followed in react. Its been like only 2 months I am learning reactjs.
"react": "^15.6.1",
"react-csv": "^1.0.8",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "^15.6.1",
"react-dropzone": "^4.2.3",
"react-flipcard": "^0.2.1",
"react-notification-system": "^0.2.16",
"react-pdf": "^2.4.2",
"react-router": "^3.0.0",
"react-router-dom": "^4.2.2",
"react-stars": "^2.2.5",
"react-table": "^6.7.4",
"react-tabs-navigation": "^0.4.4",
"react-toastr": "^2.8.2",
"semantic-ui-react": "^0.63.5",
"superagent": "^3.8.1",
"universal-cookie": "^2.1.0",
"url-loader": "^4.1.0",
"x-frame-options": "^1.0.0"
I would recommend you to make components folder in src folder. There you can structure components to atoms, molecules, organisms, templates and pages if you are a fan of a Atomic design as I am. From there every component should be separated in separate folder and have component.types.js/ts, component.constants.js/ts, component.scss, component.js/tsx. Types would refer to prop and any other types related to that component. Constants, components and scss file are quite obvious as for what they are used. Also you can have test folder in every component where you can write tests.
Also you can have common folder in src where you can put your utility files, for example custom hooks, http setup etc.
Another important folder in src is config. All config your app needs can be in there in different files if that is needed.
Last but not the least is assests foloder inside src. As name suggests you put all of your static assets (fonts, images, videos...).
I think this is very good basis to start from and expand your folder structure as you see fit and as project is needed. Also none of this i strict to naming but those are some conventions that you can read here.
awesome-app
├── src
│ ├── components
│ │ ├── atoms
│ │ │ ├── button
│ │ │ │ ├── button.types.ts
│ │ │ │ ├── button.component.tsx
│ │ │ │ ├── button.constants.ts
│ │ │ │ ├── button.scss
│ │ │ │ ├── test
│ │ │ │ ├── button.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── molecules
│ │ │ ├── action-card
│ │ │ │ ├── action-card.types.ts
│ │ │ │ ├── action-card.component.tsx
│ │ │ │ ├── action-card.constants.ts
│ │ │ │ ├── action-card.scss
│ │ │ │ ├── test
│ │ │ │ ├── action-card.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── organisms
│ │ │ ├── school-module-row
│ │ │ │ ├── school-module-row.types.ts
│ │ │ │ ├── school-module-row.component.tsx
│ │ │ │ ├── school-module-row.constants.ts
│ │ │ │ ├── school-module-row.scss
│ │ │ │ ├── test
│ │ │ │ ├── school-module-row.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── pages
│ │ │ ├── users-page
│ │ │ │ ├── users-page.types.ts
│ │ │ │ ├── users-page.component.tsx
│ │ │ │ ├── users-page.constants.ts
│ │ │ │ ├── users-page.scss
│ │ │ │ ├── test
│ │ │ │ ├── users-page.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ ├── styles
│ │ ├── base
│ │ │ ├── _base.scss
│ │ │ ├── _font.scss
│ │ │ └── ...
│ │ └── ...
│ │
│ ├── assets
│ │ ├── fonts
│ │ │ └── ...
│ │ ├── images
│ │ │ └── ...
│ │ └── ...
│ ├── config
│ │ └── ...
│ └── redux
└── actions
└── ...

Python ModuleNotFoundError. Probably a simple mistake

I am trying to setup up some test cases using pytest for a project i'm working on and have setup my directory like so.
C:.
│ OpenGLTestCase.py
│ Sprite.py
│ SpriteManager.py
│ SpriteRenderer.py
│ Texture.py
│ __init__.py
│
├───.pytest_cache
│ │ .gitignore
│ │ CACHEDIR.TAG
│ │ README.md
│ │
│ └───v
│ └───cache
│ lastfailed
│ nodeids
│ stepwise
│
├───tests
│ │ colorGrid.png
│ │ OpenGLTestCaseExample.py
│ │ OpenGLTestCaseExample2.py
│ │ test.png
│ │ test.svg
│ │ test2.png
│ │ test3.png
│ │ test_over_colorGrid_at_128left_256_top.png
│ │ test_over_uvGrid_at_128left_256_top.png
│ │ test_render_image_expected.png
│ │ test_render_triangle_expected.png
│ │ test_sprite_manager.py
│ │ test_Texture.py
│ │ uvGrid.png
│ │
│ └───__pycache__
│ test_sprite_manager.cpython-37-pytest-5.0.0.pyc
│ test_sprite_manager.cpython-37-PYTEST.pyc
│ test_Texture.cpython-37-pytest-5.0.0.pyc
│ test_Texture.cpython-37-PYTEST.pyc
│
└───__pycache__
OpenGLTestCase.cpython-37.pyc
Sprite.cpython-37.pyc
SpriteManager.cpython-37.pyc
SpriteRenderer.cpython-37.pyc
Texture.cpython-37.pyc
__init__.cpython-37.pyc
The parent folder that holds all of this is called "pygameOpenGLUtil". I have my main 4 files in the highest directory along with my __init__.py. When I try and run pytest at this level it says throws a "ModuleNotFoundError: No module named 'pygameOpenGLUtil'". This thrown in my test_sprite_manager.py file. I've gotten this to work in other projects before but I can't seem to figure out what is wrong with this one I am sure i'm just forgetting something small.
Here is my __init__.py:
from .OpenGLTestCase import *
from .Sprite import *
from .SpriteManager import *
from .SpriteRenderer import *
from .Texture import *
And here is my test_sprite_manager.py:
import pygame
from OpenGL.GL import *
from pygameOpenGLUtil import *
class SpriteManagerTest(OpenGLTestCase):
def test_add_sprite(self):
test_sprite_map = SpriteManager()
test_sprite_one = Sprite(test_sprite_map)
test_sprite_one = Sprite(test_sprite_map)
if __name__ == "__main__":
unittest.main()
I am running python3.7.3 and pytest version 5.0.0

Spawning a new process on node on an headless Raspberry

I'm currently trying to spawn a process inside my node server to take a screenshot of the only screen attached to my raspberry with this command :
var scrot = childProcess.spawn(path.join(__dirname, "bin", "scrot", "scrot"), [options.output]);
This command work on my local machine but I get a code 2 response when I try to run it on my headless raspberry under Debian. I suspect it is because my node process is spawned at the beginning of the boot routine, before the x server is started.
The pstree command show me this :
systemd─┬─avahi-daemon───avahi-daemon
├─bluetoothd
├─cron
├─2*[dbus-daemon]
├─dbus-launch
├─dhcpcd
├─hciattach
├─login───startx───xinit─┬─Xorg───{InputThread}
│ └─openbox─┬─openbox-autosta───sh───chromium-browse─┬─ch+
│ │ ├─ch+
│ │ ├─{A+
│ │ ├─{B+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{C+
│ │ ├─{D+
│ │ ├─{N+
│ │ ├─2*+
│ │ ├─3*+
│ │ ├─{T+
│ │ ├─7*+
│ │ ├─{c+
│ │ ├─{e+
│ │ ├─{g+
│ │ ├─{i+
│ │ ├─{r+
│ │ └─{s+
│ └─ssh-agent
├─node───9*[{node}]
Is there a way to add a child process to the x server context ?
Thanks for any help in advance,
C.

Resources