unable to install new version of dhcpcd5 Posted: 12 Dec 2021 07:44 AM PST im new to raspberry pi. i am trying to upgrade pi by typing sudo apt update and then sudo apt upgrade.but getting the following error. I have tried almost every solution available on web but still unable to find a solution. enter image description here |
Rails 6 deployment to Heroku Posted: 12 Dec 2021 07:43 AM PST This is my first Rails Application. I have already deployed my first part to heroku and I've been watching and reading countless resources and still can't figure out why I'm getting so many errors. I believe I've done everything needed(depending on the resources that I've read) But I still can't figure out what to do next the problem is happening when Heroku deployment gets to Compiling part it says: Compilation failed: ModuleNotFoundError: Module not found: Error: Can't resolve 'jquery' in '/tmp/build_8e2b420f/app/javascript/packs' ** ** Heroku's Build Log: -----> Building on the Heroku-20 stack -----> Using buildpacks: 1. heroku/ruby 2. heroku/nodejs -----> Ruby app detected -----> Installing bundler 2.2.21 -----> Removing BUNDLED WITH version in the Gemfile.lock -----> Compiling Ruby/Rails -----> Using Ruby version: ruby-3.0.0 -----> Installing dependencies using bundler 2.2.21 Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 Fetching gem metadata from https://rubygems.org/ Fetching gem metadata from https://rubygems.org/............ Using rake 13.0.6 Using concurrent-ruby 1.1.9 Using minitest 5.14.4 Using zeitwerk 2.5.1 Using builder 3.2.4 Using erubi 1.10.0 Using racc 1.6.0 Using crass 1.0.6 Using rack 2.2.3 Using nio4r 2.5.8 Using websocket-extensions 0.1.5 Using marcel 1.0.2 Using mini_mime 1.1.2 Using bundler 2.2.21 Using method_source 1.0.0 Using thor 1.1.0 Using bcrypt 3.1.16 Using msgpack 1.4.2 Using orm_adapter 0.5.0 Using ffi 1.15.4 Using pg 1.2.3 Using rails_serve_static_assets 0.0.5 Using rails_stdout_logging 0.0.5 Using tilt 2.0.10 Using semantic_range 3.0.0 Using turbolinks-source 5.2.0 Using i18n 1.8.11 Using tzinfo 2.0.4 Using activesupport 6.1.4.1 Using nokogiri 1.12.5 (x86_64-linux) Using rack-test 1.1.0 Using websocket-driver 0.7.5 Using mail 2.7.1 Using sprockets 4.0.2 Using request_store 1.5.0 Using bootsnap 1.9.3 Using warden 1.2.9 Using puma 5.5.2 Using rack-proxy 0.7.0 Using rails_12factor 0.0.3 Using sassc 2.4.0 Using turbolinks 5.2.1 Using globalid 1.0.0 Using activemodel 6.1.4.1 Using jbuilder 2.11.3 Using rails-dom-testing 2.0.3 Using loofah 2.12.0 Using rails-html-sanitizer 1.4.2 Using activejob 6.1.4.1 Using activerecord 6.1.4.1 Using actionview 6.1.4.1 Using actionpack 6.1.4.1 Using actioncable 6.1.4.1 Using actionmailer 6.1.4.1 Using railties 6.1.4.1 Using sprockets-rails 3.4.1 Fetching simple_form 5.1.0 Using activestorage 6.1.4.1 Using actionmailbox 6.1.4.1 Using actiontext 6.1.4.1 Using responders 3.0.1 Using sassc-rails 2.1.2 Using webpacker 5.4.3 Using rails 6.1.4.1 Using devise 4.8.0 Using sass-rails 6.0.0 Using acts_as_tenant 0.5.1 Fetching devise_invitable 2.0.5 Installing devise_invitable 2.0.5 Installing simple_form 5.1.0 Bundle complete! 23 Gemfile dependencies, 68 gems now installed. Gems in the groups 'development' and 'test' were not installed. Bundled gems are installed into `./vendor/bundle` Bundle completed (2.03s) Cleaning up the bundler cache. -----> Installing node-v12.16.2-linux-x64 -----> Installing yarn-v1.22.4 -----> Detecting rake tasks -----> Preparing app for Rails asset pipeline Running: rake assets:precompile yarn install v1.22.4 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/4] Resolving packages... warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. [2/4] Fetching packages... info fsevents@2.3.2: The platform "linux" is incompatible with this module. info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.13: The platform "linux" is incompatible with this module. info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning " > @headlessui/react@1.4.2" has unmet peer dependency "react@^16 || ^17 || ^18". warning " > @headlessui/react@1.4.2" has unmet peer dependency "react-dom@^16 || ^17 || ^18". warning " > @heroicons/react@1.0.5" has unmet peer dependency "react@>= 16". warning " > bootstrap@5.1.3" has unmet peer dependency "@popperjs/core@^2.10.2". [4/4] Building fresh packages... Done in 14.29s. I, [2021-12-12T15:25:10.706400 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/Signin_Signup_pic-112df9bf1621e3ea05a18b7a5983105c693c1762541e0a7d8838977d1ccfd554.jpg I, [2021-12-12T15:25:10.707683 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/application-3f35e6e0cfaacbb507cafb997dfc956437a9ae4c1ab0e3ab363fcc04c4bc043d.css I, [2021-12-12T15:25:10.708102 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/application-3f35e6e0cfaacbb507cafb997dfc956437a9ae4c1ab0e3ab363fcc04c4bc043d.css.gz I, [2021-12-12T15:25:10.708502 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/bootstrap-054832e226071f14f0483e581758ca81c92cbc6e4b3f23ed854f56803a2795d4.css I, [2021-12-12T15:25:10.708665 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/bootstrap-054832e226071f14f0483e581758ca81c92cbc6e4b3f23ed854f56803a2795d4.css.gz I, [2021-12-12T15:25:10.709109 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/custom-171e879c2550072c4ca3e52e96e20dea629dd85963c6ea8c2b53522103472e6b.css I, [2021-12-12T15:25:10.709398 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/custom-171e879c2550072c4ca3e52e96e20dea629dd85963c6ea8c2b53522103472e6b.css.gz I, [2021-12-12T15:25:10.710204 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/pages-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.css I, [2021-12-12T15:25:10.710733 #284] INFO -- : Writing /tmp/build_8e2b420f/public/assets/pages-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.css.gz Compiling... Compilation failed: ModuleNotFoundError: Module not found: Error: Can't resolve 'jquery' in '/tmp/build_8e2b420f/app/javascript/packs' at /tmp/build_8e2b420f/node_modules/webpack/lib/Compilation.js:925:10 at /tmp/build_8e2b420f/node_modules/webpack/lib/NormalModuleFactory.js:401:22 at /tmp/build_8e2b420f/node_modules/webpack/lib/NormalModuleFactory.js:130:21 at /tmp/build_8e2b420f/node_modules/webpack/lib/NormalModuleFactory.js:224:22 at /tmp/build_8e2b420f/node_modules/neo-async/async.js:2830:7 at /tmp/build_8e2b420f/node_modules/neo-async/async.js:6877:13 at /tmp/build_8e2b420f/node_modules/webpack/lib/NormalModuleFactory.js:214:25 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:213:14 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:41:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js:30:40 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/forEachBail.js:30:14 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43 at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/Resolver.js:285:5 at eval (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1) at /tmp/build_8e2b420f/node_modules/enhanced-resolve/lib/RootPlugin.js:37:38 at _next42 (eval at create (/tmp/build_8e2b420f/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1) resolve 'jquery' in '/tmp/build_8e2b420f/app/javascript/packs' Parsed request is a module using description file: /tmp/build_8e2b420f/package.json (relative path: ./app/javascript/packs) Field 'browser' doesn't contain a valid alias configuration resolve as module looking for modules in /tmp/build_8e2b420f/app/javascript using description file: /tmp/build_8e2b420f/package.json (relative path: ./app/javascript) Field 'browser' doesn't contain a valid alias configuration using description file: /tmp/build_8e2b420f/package.json (relative path: ./app/javascript/jquery) no extension Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery doesn't exist .mjs Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.mjs doesn't exist .js Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.js doesn't exist .sass Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.sass doesn't exist .scss Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.scss doesn't exist .css Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.css doesn't exist .module.sass Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.module.sass doesn't exist .module.scss Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.module.scss doesn't exist .module.css Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.module.css doesn't exist .png Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.png doesn't exist .svg Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.svg doesn't exist .gif Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.gif doesn't exist .jpeg Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.jpeg doesn't exist .jpg Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/app/javascript/jquery.jpg doesn't exist as directory /tmp/build_8e2b420f/app/javascript/jquery doesn't exist /tmp/build_8e2b420f/app/javascript/packs/node_modules doesn't exist or is not a directory /tmp/build_8e2b420f/app/javascript/node_modules doesn't exist or is not a directory /tmp/build_8e2b420f/app/node_modules doesn't exist or is not a directory /tmp/node_modules doesn't exist or is not a directory /node_modules doesn't exist or is not a directory looking for modules in /tmp/build_8e2b420f/node_modules using description file: /tmp/build_8e2b420f/package.json (relative path: ./node_modules) Field 'browser' doesn't contain a valid alias configuration using description file: /tmp/build_8e2b420f/package.json (relative path: ./node_modules/jquery) no extension Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery doesn't exist .mjs Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.mjs doesn't exist .js Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.js doesn't exist .sass Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.sass doesn't exist .scss Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.scss doesn't exist .css Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.css doesn't exist .module.sass Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.module.sass doesn't exist .module.scss Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.module.scss doesn't exist .module.css Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.module.css doesn't exist .png Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.png doesn't exist .svg Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.svg doesn't exist .gif Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.gif doesn't exist .jpeg Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.jpeg doesn't exist .jpg Field 'browser' doesn't contain a valid alias configuration /tmp/build_8e2b420f/node_modules/jquery.jpg doesn't exist as directory /tmp/build_8e2b420f/node_modules/jquery doesn't exist ! ! Precompiling assets failed. ! ! Push rejected, failed to compile Ruby app. ! Push failed |
SvelteKit Navigation goto State Posted: 12 Dec 2021 07:43 AM PST In SvelteKit navigation goto allows to pass state in the second argument such as: import { goto } from '$app/navigation'; // ... goto('/login', { state: { foo: 'bar' } }); The documents do not make it clear how state can be consumed/retrieved after the resulting navigation has occurred. state does not seem to be present on $page nor seems to be available on $navigating . How do you consume state passed to second argument of goto() ? Is it currently missing and you have to create your own writable store to manage this state? This is an adapter-static SvelteKit application. |
How to fix Asynctask error caused by Caused by: java.lang.NumberFormatException: For input string: "pets" Posted: 12 Dec 2021 07:43 AM PST i'm getting error: Caused by: java.lang.NumberFormatException: For input string: "pets" while trying to insert data into the database. While clicking on the insert option on the mainActivity it was supposed to insert data into the database and show that data into MainActivity but cuz of the error my application is getting crashed. How to solve this error? 2021-12-12 02:21:07.435 11934-11959/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.example.myapplication, PID: 11934 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:415) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923) Caused by: java.lang.NumberFormatException: For input string: "pets" at java.lang.Long.parseLong(Long.java:594) at java.lang.Long.parseLong(Long.java:636) at android.content.ContentUris.parseId(ContentUris.java:89) at com.example.myapplication.data.PetProvider.query(PetProvider.java:100) at android.content.ContentProvider.query(ContentProvider.java:1379) at android.content.ContentProvider.query(ContentProvider.java:1475) at android.content.ContentProvider$Transport.query(ContentProvider.java:278) at android.content.ContentResolver.query(ContentResolver.java:1185) at android.content.ContentResolver.query(ContentResolver.java:1116) at android.content.CursorLoader.loadInBackground(CursorLoader.java:71) at android.content.CursorLoader.loadInBackground(CursorLoader.java:46) at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:321) at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:74) at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:62) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923) `package com.example.myapplication.data; import android.content.ContentProvider; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.net.Uri; import android.util.Log; import android.widget.EditText; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.nio.file.Path; public class PetProvider extends ContentProvider { private PetdbHepler petdbHepler; public static String CONTENT_AUTHORITY = "com.example.myapplication"; //To make this a usable URI, we use the parse method which takes in a URI string and returns a Uri. public static Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY); //This constants stores the path for each of the tables which will be appended to the base content URI. public static final String PATH_PETS = "pets"; public static final String LOG_TAG = PetProvider.class.getSimpleName(); /** * URI matcher code for the content URI for the pets table */ private static final int PETS = 100; /** * URI matcher code for the content URI for a single pet in the pets table */ private static final int PET_ID = 101; /** * UriMatcher object to match a content URI to a corresponding code. * The input passed into the constructor represents the code to return for the root URI. * It's common to use NO_MATCH as the input for this case. */ private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); // Static initializer. This is run the first time anything is called from this class. static { // The calls to addURI() go here, for all of the content URI patterns that the provider // should recognize. All paths added to the UriMatcher have a corresponding code to return // when a match is found. sUriMatcher.addURI(CONTENT_AUTHORITY, PATH_PETS, PETS); sUriMatcher.addURI(CONTENT_AUTHORITY, PATH_PETS + "/#", PET_ID); } @Override public boolean onCreate() { petdbHepler = new PetdbHepler(getContext()); return false; } @Nullable @Override public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) { //steps To follow to query the database //first we nedd to get access to the database //second we need to pass the uri and check if the query is for whole table or for a single pet using uri matcher //atlast we need to switch according to the uri // so here is our code SQLiteDatabase database = petdbHepler.getReadableDatabase(); /*since we are only quering the database we need to use getReadableDatabase and this step is to access the database which is first step*/ Cursor cursor; int matcher = sUriMatcher.match(uri);//second we need to pass the uri and check if the query is for whole table or for a single pet using uri matcher switch (matcher) { case PETS: cursor = database.query(Petcontract.PetsEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder); case PET_ID: // For the PET_ID code, extract out the ID from the URI. // For an example URI such as "content://com.example.android.pets/pets/3", // the selection will be "_id=?" and the selection argument will be a // String array containing the actual ID of 3 in this case. // // For every "?" in the selection, we need to have an element in the selection // arguments that will fill in the "?". Since we have 1 question mark in the // selection, we have 1 String in the selection arguments' String array. selection = Petcontract.PetsEntry._ID + "?"; selectionArgs = new String[]{String.valueOf(ContentUris.parseId(uri))}; cursor = database.query(Petcontract.PetsEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder); Log.e("PetProvider", "Hereis the problem"); break; default: throw new IllegalArgumentException("cannot query unknown uri" + uri); } // Set notification URI on the Cursor, // so we know what content URI the Cursor was created for. // If the data at this URI changes, then we know we need to update the Cursor cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor; } @Nullable @Override public String getType(@NonNull Uri uri) { return null; } @Nullable @Override public Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) { final int match = sUriMatcher.match(uri); switch (match) { case PETS: return insertPet(uri, contentValues); default: throw new IllegalArgumentException("Insertion is not supported for " + uri); } } private Uri insertPet(Uri uri, ContentValues contentValues){ // Check that the name is not null String name = contentValues.getAsString(Petcontract.PetsEntry.COLUMN_NAME); if (name == null) { throw new IllegalArgumentException("Pet requires a name"); } // Check that the gender is valid Integer gender = contentValues.getAsInteger(Petcontract.PetsEntry.COLUMN_GENDER); if (gender == null) { throw new IllegalArgumentException("Pet requires valid gender"); } // If the weight is provided, check that it's greater than or equal to 0 kg Integer weight = contentValues.getAsInteger(Petcontract.PetsEntry.COLUMN_WEIGHT); if (weight != null && weight < 0) { throw new IllegalArgumentException("Pet requires valid weight"); } SQLiteDatabase sqLiteDatabase = petdbHepler.getWritableDatabase(); long id = sqLiteDatabase.insert(Petcontract.PetsEntry.TABLE_NAME, null, contentValues); // Notify all listeners that the data has changed for the pet content URI getContext().getContentResolver().notifyChange(uri, null); return ContentUris.withAppendedId(Petcontract.PetsEntry.content_uri, id); } @Override public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) { // Get writeable database SQLiteDatabase database =petdbHepler.getWritableDatabase(); int rowsDeleted; final int match = sUriMatcher.match(uri); switch (match) { case PETS: // Delete all rows that match the selection and selection args return database.delete(Petcontract.PetsEntry.TABLE_NAME, selection, selectionArgs); case PET_ID: // Delete a single row given by the ID in the URI selection = Petcontract.PetsEntry._ID + "=?"; selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) }; rowsDeleted = database.delete(Petcontract.PetsEntry.TABLE_NAME, selection, selectionArgs); // If 1 or more rows were deleted, then notify all listeners that the data at the // given URI has changed if (rowsDeleted != 0) { getContext().getContentResolver().notifyChange(uri, null); return database.delete(Petcontract.PetsEntry.TABLE_NAME, selection, selectionArgs); } else{ return rowsDeleted; } default: throw new IllegalArgumentException("Deletion is not supported for " + uri); } } @Override public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) { SQLiteDatabase database = petdbHepler.getWritableDatabase(); int rowsUpdated = database.update(Petcontract.PetsEntry.TABLE_NAME, values, selection, selectionArgs); if (rowsUpdated != 0) { getContext().getContentResolver().notifyChange(uri, null); return rowsUpdated; } else { return database.update(Petcontract.PetsEntry.TABLE_NAME, values, selection, selectionArgs); } } }` |
kNN-argument "cl" is missing, with no default Posted: 12 Dec 2021 07:43 AM PST I'm trying to predict the topic using the title by kNN model and I'm getting the error- kNN-argument "cl" is missing, with no default. Could you please help me execute this model? Dataset link-https://archive.ics.uci.edu/ml/machine-learning-databases/00432/Data/News_Final.csv library(tm) library(wordcloud) library(RColorBrewer) library(wordcloud) library(topicmodels) library(plyr) library(ggplot2) library(e1071) library(caret) library(class) news_full <- read.csv('~/Downloads/DMML-Project/SentimentAnalysis/News_Final.csv') news_title_topic <- news_full[,c("Title","Topic")] print(news_title_topic) sample <- sample.int(n = nrow(news_title_topic), size = floor(.8*nrow(news_title_topic)), replace = F) news_title_topic <- news_title_topic[sample, ] set.seed(123) # Set Seed so that same sample can be reproduced in future also # Now Selecting 75% of data as sample from total 'n' rows of the data sample <- sample.int(n = nrow(news_title_topic), size = floor(0.1*nrow(news_title_topic)), replace = F) train <- news_title_topic[sample, ] test <- news_title_topic[-sample, ] #processing for training source <- VectorSource(train$Title) corpus <- Corpus(source) corpus <- tm_map(corpus, content_transformer(tolower)) print(corpus) corpus <- tm_map(corpus, removeNumbers) corpus <- tm_map(corpus, removePunctuation) corpus <- tm_map(corpus, stripWhitespace) corpus <- tm_map(corpus, removeWords, stopwords('english')) mat <- DocumentTermMatrix(corpus) mat <- removeSparseTerms(mat, 0.98) mat4 <- weightTfIdf(mat) mat4 <- as.matrix(mat4) #processing for testing source1 <- VectorSource(test$Title) corpus1 <- Corpus(source1) corpus1 <- tm_map(corpus1, content_transformer(tolower)) corpus1 <- tm_map(corpus1, removeNumbers) corpus1 <- tm_map(corpus1, removePunctuation) corpus1 <- tm_map(corpus1, stripWhitespace) #corpus1 <- tm_map(corpus1,stopwords('english')) mat1 <- DocumentTermMatrix(corpus1) mat1 <- removeSparseTerms(mat1, 0.98) mat5 <- weightTfIdf(mat1) mat5 <- as.matrix(mat5) #Applying K-means here, the below code is giving me an error classifier <- knn(mat4, mat5, k = 3, prob=TRUE, use.all = TRUE) inspredicted <- predict(classifier,mat5) confusionMatrix(as.factor(inspredicted),as.factor(test$Topic)) |
How do I make a newsletter service using Python? Posted: 12 Dec 2021 07:43 AM PST I'm pretty sure it would require smtplib, SQL to store the emails, a front end for user interaction, and what else? |
hide some text of post data on using php Posted: 12 Dec 2021 07:43 AM PST how to hide/show to make truncated text on php. I'm searching for a long time. I have found some example but these all are shown without tags in between. In my case, I have some text and some html tags in the article. Something like.... <div>hello world <div>some other text here.</div></div> |
Remove all characters after specific character from right to left Posted: 12 Dec 2021 07:43 AM PST I was trying to implement a function in Node.js that does what the title of this question requires. For example, if the caracters was _ Input foo_bar_baz Output foo_bar Input foo_bar_baz_foz Output foo_bar_baz |
cartopy v 0.20.1 throws various HTTP errors when trying to use cartopy.io.img_tiles Posted: 12 Dec 2021 07:42 AM PST I've been trying to use alternative basemaps/images/layers with cartopy instead of the low resolution stock images. I found cartopy.io.img_tiles and some examples of using it. All of my efforts using various services result in HTTP Error 404: Not Found . Minimal code that reproduces the error: fig = plt.figure() mapbox_satellite = cimgt.MapboxTiles(map_id='mapbox.satellite', access_token='pk.ey...qB7AXa40XGWFm_nuyQ') ax = fig.add_subplot(1, 1, 1, projection=mapbox_satellite.crs) ax.add_image(mapbox_satellite, 8) OSM also fails. One set of examples I was trying to work with: https://notebook.community/lmoresi/docker-web-notebook-server/notebooks/Example%20Working%20with%20on-demand%20mapping%20services |
Split date_start and date_end by hours on Metabase Posted: 12 Dec 2021 07:42 AM PST I have table with a column "Begin At" and another column "End At" that represent when a task begin and when a task end i would want to have a Bar display which display the cuantity of tasks that are being done in a specific hour along an interval of time. For example, from the following table I would want to be able to see that from 07/12/2021 21:00 to 07/12/2021 22:00 there were 3 tasks being done (row 1, row 2, row 3). And also as i will have several thousands of rows i would want to use the date widget from metabase in order to specify range of times. I have been struggling with this from the last week, i tried to create auxiliar questions where to query after but finally my only succeed was to hard code the 24 hours from a day but then i was not able to use the time widget and i needed to specify the dates myself on the sql each time i want to check a specific day and also i only was able to check from 24 to 24 hours, not from for example 02/12/2021 6:00 to 04/12/2021 18:00 My metabase is running on a PostgreSQL database. Is this even possible on Metabase? If not what are your advices to build this? Other plaforms? Pure SQL? Python? Thank you so much |
Adding a post+increment and pre-increment value without parentheses [closed] Posted: 12 Dec 2021 07:44 AM PST Why it is not allowed to make 3+++++9 , that is normaly (3++) + (++9) and that should be allowed? I know that we are not able to combinate increments, but we have artihmetic symbol between the both increments? So normally i thought that should be okay |
Creating a dictionary with keys having multiple values Posted: 12 Dec 2021 07:43 AM PST I need to create a dictionary of lists for the with 1 key having 5 values { customer_id: [name, date of birth, location, phone number, age] } How can I do that by taking input during runtime? How to store a date as a value in a dictionary |
how to reverse particular word in python string Posted: 12 Dec 2021 07:42 AM PST for each word which length exceeds 3 letters return that word in backward order. For example: AT DAWN LOOK TO THE EAST - input AT NWAD KOOL TO THE TSAE - output |
Render div with state only on phones Posted: 12 Dec 2021 07:43 AM PST is there some way how to render div conditionally with state but only for mobiles? I have show more button, but i need it only for phone resolution, also I need to display that div with className text every time on desktop const ListItem = ({ text }) => { let [showMore, setShowMore] = useState(false); return ( <div className="item"> <div> <div className={`text ${showMore ? "active" : ""}`}>{text}</div> </div> <button onClick={() => setShowMore((s) => !s)}>Show more</button> </div> ); }; |
GridSearchCV with MLPClassifier Posted: 12 Dec 2021 07:44 AM PST I am trying to use GridSearchCV to select the best parameters for a MLPClassifier using the wine dataset. from sklearn.preprocessing import MinMaxScaler from sklearn.datasets import load_wine from sklearn.model_selection import train_test_split from sklearn.pipeline import make_pipeline from sklearn.model_selection import GridSearchCV from sklearn.neural_network import MLPClassifier wine= load_wine() X_train, X_test, y_train, y_test = train_test_split(wine['data'], wine['target'], random_state=263) param_grid = { 'hidden_layer_sizes': [(50,),(100,),(300,)], 'alpha' : [0.01, 0.1,0.9], 'solver' :['adam', 'sgd','lbfgs'], 'learning_rate' : ['constant', 'adaptive','invscaling'], 'activation': ['relu', 'tanh','identity'], } pipe = make_pipeline(MinMaxScaler(), MLPClassifier(max_iter=2000000000, random_state=263)) pipe.fit(X_train, y_train) grid = GridSearchCV(pipe, param_grid=param_grid, cv=3,n_jobs = -1) grid.fit(X_train, y_train) Returns this error: ValueError: Invalid parameter alpha for estimator Pipeline(steps=[('minmaxscaler', MinMaxScaler()), ('mlpclassifier', MLPClassifier(max_iter=2000000000, random_state=263))]). I don't understand this since alpha is spelled correctly and all 3 options are within the correct bounds and are all floats. |
Python closest subset function Posted: 12 Dec 2021 07:43 AM PST I'm writing a closestSubset(s,A) function that takes an integer s and an array of positive integers A and returns an array consisting of elements of A which add up to s. If there is no subset that adds up to s, I want the function to instead return the subset which adds up to the value closest to s. For example: if A is [12, 79, 99, 91, 81, 47] and s is 150, it will return [12, 91, 47] as 12+91+47 is 150 if A is [15, 79, 99, 6, 69, 82, 32] and s is 150 it will return [69, 82] as 69+82 is 151, and there is no subset of A whose sum is 150. # Driver code: subset = closestSubset(5000,A) A typical recursive method might work here, but I would want to know a way of doing this iteratively if anyone knows. I understand how to produce this function if the correct numbers exist to form integer s but when there isn't, then how do I find the closest? Would I have to actually create a left and right range so that if for example the integer was 150, then any number closest to 150 by for e.g. 10 would be fine? |
Scenario if in input numbers are repeat Posted: 12 Dec 2021 07:44 AM PST Code: n = int(input("Type n: ")) def some_function(n): numbers, numbers_sum = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], 45 while True: digit = n % 10 n //= 10 if digit in numbers: numbers.remove(digit) numbers_sum -= digit else: break return numbers_sum print(some_function(n)) Program needs to print the sum of numbers that are not found in the input. I covered the scenario when numbers are not repeating and for this scenario if the input is 234567890 output is 1 . But don't have an idea for scenario when numbers are repeating.Etc. if the input is 22334567890 or 223344556677889900 output still needs to be 1 but it's not. P.S. I know 0 doesn't make difference because we are doing with - and +. |
Remove rows from csv based on given criteria + export updated csv with ne file name Posted: 12 Dec 2021 07:42 AM PST Trying to figure out the code to remove the rows in csv file where in column Date there is date starting with 202110 (and any day). So all rows from October should be removed. Then I want to save csv with orginal name + 'updated'. I think that both part where I am trying to remove row is incorrect and save the file. Could you help? My current code is import os import glob import pandas as pd from pathlib import Path sourcefiles = source_files = sorted(Path(r'/Users/path/path/path').glob('*.csv')) for file in sourcefiles: df = pd.read_csv(file) df2 = df[~df.Date.str.contains('202110')] df2.to_csv("Updated.csv") # How to save with orginal file name + word "updated" |
raise ImportError('Unable to find zbar shared library') when deploying to azure web app Posted: 12 Dec 2021 07:43 AM PST I have python project which i am trying to deploy to azure web app from my windows pc . It works perfectly fine on windows local pc but when deploing there i got this error log below. Log from azure web app: 2021-12-12T15:13:47 Welcome, you are now connected to log-streaming service. Starting Log Tail -n 10 of existing logs ---- /home/LogFiles/__lastCheckTime.txt (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/__lastCheckTime.txt)12/12/2021 15:13:24 /home/LogFiles/kudu/trace/046d6a19f398-24f4f7a7-d50b-4ea9-be24-c7c34e2d5366.txt (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/046d6a19f398-24f4f7a7-d50b-4ea9-be24-c7c34e2d5366.txt) 2021-12-12T10:52:10 Outgoing response, type: response, statusCode: 404, statusText: NotFound /home/LogFiles/kudu/trace/046d6a19f398-3df0f78c-d0d0-4e08-a612-9e9ad0816062.txt (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/046d6a19f398-3df0f78c-d0d0-4e08-a612-9e9ad0816062.txt) 2021-12-12T11:12:10 Outgoing response, type: response, statusCode: 404, statusText: NotFound /home/LogFiles/kudu/trace/046d6a19f398-a222a843-e436-4f93-b238-b4bc721aba7a.txt (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/046d6a19f398-a222a843-e436-4f93-b238-b4bc721aba7a.txt) 2021-12-12T10:12:09 Startup Request, url: /, method: HEAD, type: request, pid: 79,1,5, ScmType: None, SCM_DO_BUILD_DURING_DEPLOYMENT: true /home/LogFiles/kudu/trace/7a8a200c580b-f1a5986f-5cfc-4ca1-aafe-30f1230d1e60.txt (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/7a8a200c580b-f1a5986f-5cfc-4ca1-aafe-30f1230d1e60.txt) 2021-12-12T15:12:10 Startup Request, url: /api/vfs/site/wwwroot/?_=1639321905938, method: GET, type: request, pid: 67,1,4, ScmType: None, SCM_DO_BUILD_DURING_DEPLOYMENT: true /home/LogFiles/2021_12_12_10-30-0-10_default_docker.log (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/2021_12_12_10-30-0-10_default_docker.log) 2021-12-12T11:44:40.357915732Z return prototype((fname, load_libzbar())) 2021-12-12T11:44:40.357921832Z File "/tmp/8d9bd6318a7b507/antenv/lib/python3.8/site-packages/pyzbar/wrapper.py", line 115, in load_libzbar 2021-12-12T11:44:40.357927632Z libzbar, dependencies = zbar_library.load() 2021-12-12T11:44:40.357933732Z File "/tmp/8d9bd6318a7b507/antenv/lib/python3.8/site-packages/pyzbar/zbar_library.py", line 65, in load 2021-12-12T11:44:40.357940032Z raise ImportError('Unable to find zbar shared library') 2021-12-12T11:44:40.357946132Z ImportError: Unable to find zbar shared library 2021-12-12T11:44:40.358272136Z [2021-12-12 11:44:40 +0000] [41] [INFO] Worker exiting (pid: 41) 2021-12-12T11:44:40.563733800Z [2021-12-12 11:44:40 +0000] [39] [INFO] Shutting down: Master 2021-12-12T11:44:40.563780701Z [2021-12-12 11:44:40 +0000] [39] [INFO] Reason: Worker failed to boot. /home/LogFiles/2021_12_12_10-30-0-10_docker.log (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/2021_12_12_10-30-0-10_docker.log) 2021-12-12T11:38:17.033Z ERROR - Container barcodessecret_0_a5c0ed86 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging. 2021-12-12T11:38:17.108Z INFO - Stopping site barcodessecret because it failed during startup. 2021-12-12T11:44:10.056Z INFO - Starting container for site 2021-12-12T11:44:10.058Z INFO - docker run -d -p 8000:8000 --name barcodessecret_0_cc711f28 -e WEBSITE_SITE_NAME=barcodessecret -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=barcodessecret.azurewebsites.net -e WEBSITE_INSTANCE_ID=e8a25aeda9f8112c52a78edbf794ec6bc124d323fe575e4a705382f2e36592ba -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.8_20210810.1 2021-12-12T11:44:14.616Z INFO - Initiating warmup request to container barcodessecret_0_cc711f28 for site barcodessecret 2021-12-12T11:44:30.360Z INFO - Waiting for response to warmup request for container barcodessecret_0_cc711f28. Elapsed time = 15.7438301 sec 2021-12-12T11:44:43.805Z ERROR - Container barcodessecret_0_cc711f28 for site barcodessecret has exited, failing site start 2021-12-12T11:44:43.821Z ERROR - Container barcodessecret_0_cc711f28 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging. 2021-12-12T11:44:43.871Z INFO - Stopping site barcodessecret because it failed during startup. /home/LogFiles/2021_12_12_10-30-1-36_default_docker.log (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/2021_12_12_10-30-1-36_default_docker.log) /home/LogFiles/2021_12_12_10-30-1-36_docker.log (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/2021_12_12_10-30-1-36_docker.log) 2021-12-12T15:13:24.974Z INFO - Starting container for site 2021-12-12T15:13:24.974Z INFO - docker run -d -p 8000:8000 --name barcodessecret_0_73b46eaa -e WEBSITE_SITE_NAME=barcodessecret -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=barcodessecret.azurewebsites.net -e WEBSITE_INSTANCE_ID=b48e99ae39c2631bdbfaff480078c704864fb7435737f78ac9c0af67dc0f25d5 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.8_20210810.1 2021-12-12T15:13:28.990Z INFO - Initiating warmup request to container barcodessecret_0_73b46eaa for site barcodessecret 2021-12-12T15:13:44.398Z INFO - Waiting for response to warmup request for container barcodessecret_0_73b46eaa. Elapsed time = 15.4079531 sec /home/LogFiles/webssh/.log (https://barcodessecret.scm.azurewebsites.net/api/vfs/LogFiles/webssh/.log) Ending Log Tail of existing logs --- Starting Live Log Stream --- I've tried diffrent solution including putting zbar-py into my requirments.txt file as shown below: opencv-python-headless==4.5.1.48 flask flask-sqlalchemy flask-login ezdxf matplotlib qrcode zbar-py pyzbar pyzbar[scripts] How can i solve this? |
Is wix affected by log4j? Posted: 12 Dec 2021 07:44 AM PST From an public presentation I know that the website creation tool wix is using Java, not sure if they are using log4j2, I have not found anything on their web page. Is wix affected by the log4j2 vulnerability CVE-2021-44228? |
several arguments in lambda Posted: 12 Dec 2021 07:43 AM PST I have some lambdas which describes functions and making plots of them f1 = lambda x1: x1 ... f10 = lambda x10: 5-np.sqrt(-x10*x10-10*x10-24) x1=np.linspace(-5 ,5, 50) ... x10=np.linspace(-6 ,-4, 50) fig, ax = plt.subplots(figsize=(8,8)) ax.grid(axis='both') plt.subplots_adjust(left=0.2, bottom=0.3) ax.set_xlim(-15,15) ax.set_ylim(-15,15) line1, = ax.plot(x1, f1(x1), color = "black") ... line10, = ax.plot(x10, f10(x10), color = "black") After I have a function which rotates f1 xy=(x,f1) def T_via_numpy(xy, radians, a, b): x,y=xy c, s = np.cos(radians), np.sin(radians) T=np.matrix([[c, s, a], [-s, c, b], [0, 0, 1]]) x1=[] y1=[] for i in x: M = np.dot(T, [i, y(i), 1]) x1.append(float(M.T[0])) y1.append(float(M.T[1])) return x1, y1 def update(val): x1, y1 = T_via_numpy(xy, math.radians(FiSlider), xSlider, ySlider) fig.canvas.draw_idle() How can I compare f1-f10 in one so T_via_numpy will rotate all functions at the same time? |
Display different pop up windows for different image buttons Posted: 12 Dec 2021 07:44 AM PST I was making this project website and I came across this idea of making a pop-up box to show the products' description. As I was making the pop-up message box which would appear on clicking different images, I saw that it was showing same messages for different products even after giving different description for each one of them. I don't know JavaScript much but some code must be added there I guess. Here is the code- $(".modal-trigger").click(function(e){ e.preventDefault(); dataModal = $(this).attr("data-modal"); $("#" + dataModal).css({"display":"block"}); // $("body").css({"overflow-y": "hidden"}); //Prevent double scrollbar. }); $(".close-modal, .modal-sandbox").click(function(){ $(".modal").css({"display":"none"}); // $("body").css({"overflow-y": "auto"}); //Prevent double scrollbar. }); .modal, .modal-box { z-index: 900; } .modal-sandbox { position: fixed; width: 100%; height: 100%; top: 0; left: 0; background: transparent; } .modal { display: none; position: fixed; width: 100%; height: 100%; left: 0; top: 0; background: rgb(0,0,0); background: rgba(0,0,0,.8); overflow: auto; } .modal-box { position: relative; width: 80%; max-width: 920px; margin: 100px auto; animation-name: modalbox; animation-duration: .4s; animation-timing-function: cubic-bezier(0,0,.3,1.6); } .modal-header { padding: 20px 40px; background: #546E7A; color: #ffffff; } .modal-body { background: #ECEFF1; padding: 60px 40px; } /* Close Button */ .close-modal { text-align: right; cursor: pointer; } /* Animation */ @-webkit-keyframes modalbox { 0% { top: -250px; opacity: 0; } 100% { top: 0; opacity: 1; } } @keyframes modalbox { 0% { top: -250px; opacity: 0; } 100% { top: 0; opacity: 1; } } .modal-trigger, button { top: 100%; left: 100%; padding: 20px 40px; background: transparent; color: #ffffff; border: 1px solid #ffffff; text-decoration: none; } .modal-trigger { position: absolute; top: 100%; left: 100%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); transform: translate(-50%, -50%); transition: ease .2s; } button { border: 1px solid #333333; outline: none; color: #333333; } .modal-trigger:hover { padding: 20px 60px; } <body> <div class="services-container container-fluid"> <div class="container sess-in-cont"> <div class="session-title row"> <h2>Our Services</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse venenatis magna odio, eu vehicula augue suscipit ac. Pellentesque quis dui lorem. </p> </div> <div class="sess-row row"> <div class="col-md-4"> <div class="serv-det"> <figure class="imghvr-fade"> <img src="assets/images/services/s1.jpg" alt=""> <figcaption> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse venenatis magna odio, eu vehicula augue suscipit ac. Pellentesque quis dui lorem. Vestibulum sed blandit diam, <a href="#" class="modal-trigger" data-modal="modal-name">Modal open!</a> </figcaption> </figure> <h6>Telecom</h6> </div> </div> <div class="modal" id="modal-name"> <div class="modal-sandbox"></div> <div class="modal-box"> <div class="modal-header"> <div class="close-modal">✖</div> <h1>ex1</h1> </div> <div class="modal-body"> <p>Product 1 Description 1</p> <p>This is first product description</p> <br /> <button class="close-modal">Close!</button> </div> </div> </div> <div class="col-md-4"> <div class="serv-det"> <figure class="imghvr-fade"> <img src="assets/images/services/s2.jpg" alt=""> <figcaption> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse venenatis magna odio, eu vehicula augue suscipit ac. Pellentesque quis dui lorem. Vestibulum sed blandit diam, <a href="#" class="modal-trigger" data-modal="modal-name">Modal open!</a> </figcaption> </figure> <h6>Networking</h6> </div> </div> <div class="modal" id="modal-name"> <div class="modal-sandbox"></div> <div class="modal-box"> <div class="modal-header"> <div class="close-modal">✖</div> <h1>ex2</h1> </div> <div class="modal-body"> <p>Product 2 Decription 2</p> <p>This is second description</p> <br /> <button class="close-modal">Close! </button> </div> </div> </div> </body> This is a template I picked up from codepen.io. |
how to distinguish between no time and midnight in COleDateTime class Posted: 12 Dec 2021 07:44 AM PST We use the DD-MM-YYYY HH:mm:ss date and time format API between frontend and backend. However, there are cases that backend gets only the date since time wasn't selected at the frontend side. The GET call parameter will look like this: startTime=16-11-2021 At the backend side, we use the COleDateTime class in order to parse the date and time. The problem is that the time in the case above is initialized to 00:00:00 when actually no time is sent. I need a way to distinguish between no time sent and midnight as the actual time is significant in our system and there is a big difference between no time sent and midnight. It seems that the ParseDateTime function expects to get a flag in its second parameter VAR_TIMEVALUEONLY to Ignore the date portion during parsing. So for that, I need to implement a parse function in order to know if I got the time or not where it is expected that the ParseDateTime function would be set as an undefined time like -1 when no time is sent. Is there a way to distinguish between no time to midnight in COleDateTime class? If not, maybe you have another way I can use public libraries like <chrono> which could solve my problem? |
Navigation Link Using a form SwiftUI Posted: 12 Dec 2021 07:44 AM PST I want to move to another view using a button from a form, I'm trying to make a settings page. The code below, I managed how to open a URL from a form, now I want to open another page but I didn't now how to do it. struct FormRowLinkView: View { var icon: String var color: Color var text: String var link: String var body: some View { HStack{ ZStack{ RoundedRectangle(cornerRadius: 8, style: .continuous) .fill(color) Image(systemName: icon) .imageScale(.large) .foregroundColor(Color.white) } .frame(width: 36, height: 36, alignment: .center) Text(text).foregroundColor(Color.gray) Spacer() Button(action: { guard let url = URL(string: self.link), UIApplication.shared.canOpenURL(url as URL) else { return } UIApplication.shared.open(url as URL) }) {} Image(systemName: "chevron.right") .font(.system(size: 14, weight: .semibold, design: .rounded)) } .accentColor(Color(.systemGray2)) } } struct FormRowLinkView_Previews: PreviewProvider { static var previews: some View { FormRowLinkView(icon: "globe", color: Color.pink, text: "Website", link: "") .previewLayout(.fixed(width: 375, height: 60)) .padding() } } |
Determine the maximum number of teams that can be formed based on team size skills array etc Posted: 12 Dec 2021 07:43 AM PST This is code question asked by Amazon on Hacker Rank. Please help to resolve it. Amazon is hosting a team hackathon. - Each team will have exactly teamSize developers.
- A developer's skill level is denoted by skill[i].
- The difference between the maximum and minimum skill levels within a team cannot exceed a threshold, maxDiff.
Determine the maximum number of teams that can be formed from the contestants. |
Install gcc-arm-none-eabi or arm-none-eabi-gcc on android with termux Posted: 12 Dec 2021 07:44 AM PST I need to install arm-none-eabi-gcc / gcc-arm-none-eabi ARM compiler on android in order to convert C++ to ASM (M3 Cortex), on android device with AArch64 architecture (not rooted) using third party Termux app as terminal and linux enviroment emulator for that arm compiler. Using Termux with it's API I'm planning to create a simple android app which will do the convertion task easily, by running arm compiler from shell with parameters to convert C++ to ASM. I tried many times following online articles to build the arm compiler but could not be able to install that package. For example: $ sudo apt-get remove binutils-arm-none-eabi gcc-arm-none-eabi $ sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa $ sudo apt-get update $ sudo apt-get install gcc-arm-none-eabi $ sudo apt-get install gdb-arm-none-eabi Because, I use Termux as terminal and linux enviroment emulator, I fail to build the arm compiler everytime. How to install that arm compiler on android (posible using termux), if all I want is to run the compiler from shell with parameters to get C++ converted to ASM (M3 Cortex) arm-none-eabi-gcc -O2 -mthumb -c test.c -o test.o |
ASP.Net Core 5 MVC Bootstrap Render Div When Screen Smaller Than X Width Posted: 12 Dec 2021 07:44 AM PST I am creating an ASP.Net Core 5 App with Bootstrap 5. I want to conditionally render the Header elements based on screen width. This is the header when the browser is larger, like on a laptop. Right now, everything collapses into the bootstrap hamburger menu. What I want to happen is for the Hello David, Logout, and Cart Info button to be placed to the right of the My Shopping Cart Logo, and for the Home, Privacy, and Search to go to the hamburger menu. Here is the current view when everything is collapsed. And what I want to accomplish is something like But now that I am looking at it, maybe I will get rid of the Log Out button, and make logout part of the Hello David drop down. So in order to accomplish something like this, I need to check for when the screen is smaller than x width...Whenever Bootstrap collapses everything down. I have done lots of Googling, and I see posts about media queries, but I get the sense that media queries are for something like React or Angular. How would I accomplish this in ASP.Net Core 5 MVC? Here is my code. <nav class="navbar navbar-expand-lg navbar-light bg-light"> <div class="container-fluid"> <a class="navbar-brand" asp-controller="Products" asp-action="Index"><img src="@(Configuration.GetValue<string>("StorageContainerURL"))/store-logo.png" ) class="img-fluid" style="max-height:75px;width:auto" alt="Alternate Text" /></a> @*I want to render*@ @* <partial name="_Identity.cshtml" /> @*This is the Hello David and Logout Button <ul class="navbar-nav mb-2 mb-lg-0"> @await Component.InvokeAsync("ShoppingCartSummary") @*This is the Shopping Cart Button" </ul> *@ @*if the screen is < X width*@ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link text-dark" asp-area="" asp-controller="Products" asp-action="Index">Home</a> </li> <li class="nav-item"> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> </li> @if (!User.IsInRole("Seller")) { <li class="nav-item"> <a class="nav-link text-dark" asp-area="" asp-controller="Account" asp-action="EditProfile">Become a Seller</a> </li> } </ul> <form class="d-flex" asp-controller="Products" asp-action="Filter"> <input name="searchString" class="form-control me-1" type="search" placeholder="Search for a product..." aria-label="Search"> <button class="btn btn-outline-success me-2" type="submit">Search</button> </form> <partial name="_Identity.cshtml" /> @*This is the Hello David and Logout Button*@ <ul class="navbar-nav mb-2 mb-lg-0"> @await Component.InvokeAsync("ShoppingCartSummary") @*This is the Shopping Cart Button*@ </ul> </div> </div> </nav> Edit: I figured it out. I wanted to show the answer, but I do not want to take credit for the answer. This will only be visible on xs, sm, and md screens. <div class="d-block d-lg-none"> This will only be visible on lg and larger screens. <div class="d-none d-lg-block"> This is applicable to Bootstrap 5. See Bootstrap 5 Hiding Elements |
PackageManager namenotfoundexception Posted: 12 Dec 2021 07:43 AM PST I'm new to android programming. I've created an app using Eclipse with a MainActivity.java and ClassFragment.java files. ClassFragment is a frangment. And I'm using newly updated appcompat library. I just want to implement a toast in my fragment with will show the version vode and version name of the app. I've used the following code PackageManager pInfo = getActivity().getPackageManager.getPackageInfo(getActivity().getPackageName, 0); But its showing java compilation error PackageManager namenotfoundexception. Pls help me out from this. Thanks in advance. |
Clone a private repo of github with username and password Posted: 12 Dec 2021 07:43 AM PST I have configured Account A on my system with Global configurations and I can clone all my repos from there. Now I don't want to change the configuration and I want to clone and do all operations of account B with my username and password. How can I do this? I have tried: git clone username:passwordgit@github.com:*****/******.git But with no success. |
fs.watch fired twice when I change the watched file Posted: 12 Dec 2021 07:43 AM PST fs.watch( 'example.xml', function ( curr, prev ) { // on file change we can read the new xml fs.readFile( 'example.xml','utf8', function ( err, data ) { if ( err ) throw err; console.dir(data); console.log('Done'); }); }); OUTPUT: - some data
- Done X 1
- some data
- Done X 2
It is my usage fault or ..? |
No comments:
Post a Comment