Posts

Showing posts from July 11, 2018

magento 2 Uncaught TypeError: Argument 1 passed to __construct() must be an instance of MagentoBackendBlockTemplateContext

magento 2 Uncaught TypeError: Argument 1 passed to __construct() must be an instance of MagentoBackendBlockTemplateContext In Magento 2.2 i have create a module and there i am getting this error. Uncaught TypeError: Argument 1 passed to __construct() must be an instance of MagentoBackendBlockTemplateContext, instance of MagentoFrameworkObjectManagerObjectManager given My file path appcodeNamespaceModulenameBlockAdminhtmlExporterEditTabForm.php <?php namespace NamespaceModulenameBlockAdminhtmlExporterEditTab; class Form extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface { protected $exporter; public function __construct( MagentoBackendBlockTemplateContext $context, MagentoFrameworkRegistry $registry, MagentoFrameworkDataFormFactory $formFactory, RaveinfosysOrderexporterModelExporter $exporter, array $data = ) { $this->exporter = $exporter; $this->_formFactory = $for

How to convert unusual unicode string with number to integer in python

How to convert unusual unicode string with number to integer in python I have some fairly hairy unicode strings with numbers in them that I'd like to test the value of. Normally, I'd just use str.isnumeric to test for whether it could be converted via int() but I'm encountering cases where isnumeric returns True but int() raises an exception. str.isnumeric int() isnumeric True int() Here's an example program: >>> s = '⒍' >>> s.isnumeric() True >>> int(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: '⒍' Unicode is always full of surprises, so I'm happy to just be robust to this case and use a try/except block to catch unusual numbers. However, I'd be happier if I could still convert them to integers. Is there a consistent way to do this? 3 Answers 3

Not changing .hbs files triggering nodemon restarts

Not changing .hbs files triggering nodemon restarts I use handlebars and nodemon on Windows. I've noticed (when using the debug argument for nodemon), hbs files - even when they aren't being edited - trigger a nodemon change. debug Are the files actually changing? Why are they changing if I'm not editing them? [11:22:46] [nodemon] files triggering change check: ..forgot-sent.hbs [11:22:46] [nodemon] matched rule: C:UsersmeDocumentsmyappviews/**/* [11:22:46] [nodemon] changes after filters (before/after): 1/1 [11:22:46] [nodemon] restarting due to changes... [11:22:46] [nodemon] viewsforgot-sent.hbs How can I make nodemon refresh when files are changed, and not refresh when files are not changed? Edit : looks like a bug on nodemon/Windows, see https://github.com/remy/nodemon/issues/1208 Try running with nodemon -L – souravlahoti Apr 24 at 10:43

Android - Change a column type in SQLite database dynamically at runtime

Image
Android - Change a column type in SQLite database dynamically at runtime I have an application, where I am detecting the type of a particular column at run-time, on page load. Please refer the below code: public String fncCheckColumnType(String strColumnName){ db = this.getWritableDatabase(); String strColumnType = ""; Cursor typeCursor = db.rawQuery("SELECT typeof (" + strColumnName +") from tblUsers, null); typeCursor.moveToFirst(); strColumnType = typeCursor.getString(0); return strColumnType; } The above method simply detects the type of column with column Name 'strColumnName'. I am getting the type of column in this case. Now, I want to change the column type to TEXT if I am receiving INTEGER as the column type. For this, I tried the below code: public String fncChangeColumnType(String strColumnName){ db = this.getWritableDatabase(); String newType = ""; Cursor chang

Proper syntax for Laravel Eloquent insert/update

Proper syntax for Laravel Eloquent insert/update I have seemingly simple problem that I still can't solve after days of browsing around. Say I have Debitur model. class Debitur extends Model { protected $table = 'debiturs'; protected $fillable = [ 'name', 'address', ]; public function debiturWife(){ return $this->hasOne('AppDebiturWife'); } } And I have a DebiturWife model. class DebiturWife extends Model { protected $table = 'debitur_wifes'; protected $fillable = [ 'nama', 'address', 'photo', ]; public function debitur(){ return $this->belongsTo('AppDebitur'); } } I can get Debitur and DebiturWife data in the DebiturController like this: return Debitur::with('debiturWife')->find($debitur_id); Now I want to create a new Debitur and DebiturWife, how do I do that? Something like $debitur = new Debitur; $debitur->name = $re

xpath query to process XML output

xpath query to process XML output I am trying to process some XML output on a Juniper router through slax. The following is the XML data that I am working on. <filesystem> <filesystem-name>/dev/ad2s1f</filesystem-name> <total-blocks junos:format="34G">70754788</total-blocks> <used-blocks junos:format="5.6G">11800836</used-blocks> <available-blocks junos:format="25G">53293572</available-blocks> <used-percent> 18</used-percent> <mounted-on>/var</mounted-on> </filesystem> I want to get available-blocks attribute value of "25G" . @attribute is not working for me or my syntax is wrong. Can anyone help with a xpath query? I'm looking for something like this: available-blocks "25G" @attribute var $test = $var_data/available-blocks[@*]; 1 Answer 1 Is your xmlns defined?

Up vote and down vote in Laravel eloquent

Up vote and down vote in Laravel eloquent I want to create an up vote and down vote system for my website where a unique user can vote up/down for one post and next time he only allow to opposite to get off from database and after that he again can up or down vote. In this case I have: users table : id name debates table : id post upvotes table: id user_id debate_id and similarly downvote table: id user_id debate_id Is that a good way to manage and track up vote and down vote concept? 2 Answers 2 I think, you can use a single table to track the votes and the structure could be something like this votes Table : votes id | user_id | debate_id | vote Here, vote field could be tinyInt with defauld null . vote tinyInt null And, in vote field, you just keep two different values depending on the vote type, for example, if a user up votes then insert a value of 1 in the vote field and for down vote, i

Add custom form data into ORDER tab (WooCommerce)!

Image
Add custom form data into ORDER tab (WooCommerce)! I have created one custom form (Wordpress Woo-commerce) for purchasing products. I need to insert data into ORDER tab OR After Orders I would like to create one more tab called Subscription Orders same like Orders, but inside this post type data is only for subscription orders. Can you please guide and help me, How I can achieve this. I have also put screenshots so you can get better idea. Thank you in advance. 1 Answer 1 try to override template of woocomerce via themes and use the hooks. https://docs.woocommerce.com/document/template-structure/ https://docs.woocommerce.com/wc-apidocs/hook-docs.html can you please elaborate more. I am very new to WooCommerce.@markantonay – Harsh Jul 4 at 6:57

Apache Lucene Indexer Search with CJKAnalyzer

Apache Lucene Indexer Search with CJKAnalyzer I am using Apache lucene Indexer Search to search text, and I am using CJKAnalyzer. It search provided word by character, It means If I Search for Japanese word "ぁxまn" , then its showing all the words which is having any character of the provided Japanese word. But I dont want this I want search whole word or the word which is having above mentioned word. e.g. If I indexed 3 words. i.e "ぁxまn" , "ぁxま", "まn" case 1 : If I search for "ぁxまn" then it should only give one result. case 2 : If I search for "ぁx" then it should give two result. Now In my case If I search for the word "ぁxまn" then its giving three results which is wrong. ------------------- Indexing code --------------------------------- writer = getIndexWriter(); List<Document> documents = new ArrayList<>(); Document document1 = createDocument(1, "ぁxまn", "

Spring Boot - OAuth with Roles and Authorities

Spring Boot - OAuth with Roles and Authorities I am new to Spring Boot, and I am trying to configure OAuth 2.0. I was able to access the API using the access token, but am getting 403 when i am trying access JSP pages. AuthorizationServerConfig.java @Configuration @EnableAuthorizationServer public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter { @Autowired @Qualifier("authenticationManagerBean") private AuthenticationManager authenticationManager; @Bean public JwtAccessTokenConverter accessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); converter.setSigningKey("QWERTY"); return converter; } @Bean public TokenStore tokenStore() { return new JwtTokenStore(accessTokenConverter()); } @Override public void configure(ClientDetailsServiceConfigurer configurer) throws Exception { configurer.inMemory().withClient(Utils.CLIEN_ID).secret(Utils.CLIENT_SECRET).authorities("ADMIN", &

Ajax php page and url change on load using load() function without refreshing

Ajax php page and url change on load using load() function without refreshing I am recently Creating a Blog site and it is based on php version 5.6.Now I am stuck over a week to achieve "ajax page load as well as url changing when click on navigation without refreshing the entire page". I have followed many suggestion from stakeoverflow and jQuery Forum.But own't make it properly. I have menu with dropdown and also have dropdown-toggle data attribute. Somtimes my code works fine but dropdown and dropdown-toggle won't work. Can anyone give me the way to achieve this.I am just a beginner of ajax. Here is my code. dropdown dropdown-toggle dropdown dropdown-toggle header.php <?php require_once "../vendor/autoload.php"; include "../lib/Database.php"; include "../config/config.php"; include "../helpers/Format.php"; $fm= new Format(); $db = new Database(); $query ="SELECT * FROM `tbl_po

Yii2 - UrlManager and params with hypens

Yii2 - UrlManager and params with hypens I have the following URLs: http://test.local/index.php?r=site%2Findex&slug=blog-detail http://test.local/index.php?r=site%2Findex&slug=blog http://test.local/ I want to get: http://test.local/blog http://test.local/blog-detail http://test.local/ I am sending all requests to SiteController::actionIndex($slug) , I am using Basic Application Template. SiteController::actionIndex($slug) So far, I have been able to hide index.php and site/index . index.php site/index 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ '<slugw+>' => 'site/index', ], ] But it seems w+ does not match strings with - . Also if slug is empty it should show: http://test.local/ . w+ - http://test.local/ 2 Answers 2 w does not match - . You need to use [w-

How to track utm_source in Google Analytics using gtag?

How to track utm_source in Google Analytics using gtag? I'm having difficulties tracking utm_source, utm_medium with gtag. I have an SPA in AngularJS, so all the page views are fired dynamically. I've been looking for solutions to track these values from gtag, but the only hint I found is this: <!-- Global site tag (gtag.js) - Google Analytics --> https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X window.dataLayer = window.dataLayer || ; function gtag(){dataLayer.push(arguments)}; gtag('js', new Date()); gtag('set', 'page_title', 'FBIA: '+ia_document.title); gtag('set', 'campaignSource', 'Facebook'); gtag('set', 'campaignMedium', 'Social Instant Article'); gtag('config', 'UA-XXXXXXXX-X'); Source: https://gist.github.com/danielmcclure/559c2fe2433035f72d80fe45755af7bf Unfortunately this is not working for me, neither for others: https://www.en.advertisercommu

Why does this C# code throw an error: Use of unassigned local variable 'n'

Why does this C# code throw an error: Use of unassigned local variable 'n' On MSDN, this code is posted at https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/try-catch I am unable to understand why it throws the error: Use of unassigned local variable 'n'. static void Main() { int n; try { // Do not initialize this variable here. n = 123; } catch { } // Error: Use of unassigned local variable 'n'. Console.Write(n); } What error?? For starters, you have no catch defined – cricket_007 Jul 3 at 4:16 Next time when you copy code with comments, copy the comments as well, and at least try to understand them. – Zohar Peled Jul 3 at 4:18

codename one - how to check if headphone plugged in

codename one - how to check if headphone plugged in I'm writing a program in Codename One, and my program needs to check if the user plugged in his headphones to his device (Computer/Iphone/ Android). How can i do that? thanks 1 Answer 1 You need to define the build hints android.headphoneCallback=true and ios.headphoneCallback=true . android.headphoneCallback=true ios.headphoneCallback=true Once you do that you need to add two methods to the main (lifecycle) class: public void headphonesDisconnected() { } public void headphonesConnected() { } These will be invoked appropriately and you can use them to process the event. See this somewhat old article covering this: https://www.codenameone.com/blog/upcoming-features.html By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie

Can't run the monkeyrunner script

Can't run the monkeyrunner script I want to do some test with monkeyrunner but it can't work, so I run the monkeyrunner in the terminal and got error like -Djava.ext.dirs=/Users/name/Library/Android/sdk/tools/lib:/Users/name/Library/Android/sdk/tools/lib/x86_64 is not supported. Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. I found the path /86_64 and I think that right, so what's wrong with that and how can I solve this problem? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to draw CATransform3D for this layer?

Image
How to draw CATransform3D for this layer? I'm using CATransform3D and CAShapeLayer to create layer like below Here is my code. let path = CGMutablePath() let startPoint = CGPoint(x: center.x - width / 2, y: center.y - height / 2) path.move(to: startPoint) path.addLine(to: CGPoint(x: startPoint.x + width, y: startPoint.y)) path.addLine(to: CGPoint(x: startPoint.x + width, y: startPoint.y + height)) path.addLine(to: CGPoint(x: startPoint.x, y: startPoint.y + height)) path.closeSubpath() let backgroundLayer = CAShapeLayer() backgroundLayer.path = path backgroundLayer.fillColor = UIColor.clear.cgColor backgroundLayer.strokeColor = boarderColor.cgColor var transform = CATransform3DIdentity transform.m34 = -1 / 500 let angle = 45.toRadians backgroundLayer.transform = CATransform3DRotate(transform, angle, 1, 0, 0) The output is like below. Can someone help to point out the reason? Thanks I don't know exactly what is going on, but if you use (0,