Error in Dojo 1.8 upgrade Error:{"message":"'registry' is undefined"} - dojo

I want to set the data in bodydiv how it possible.
Error in Dojo 1.8 upgrade Error:{"message":"'registry' is undefined"}
function setBodyData(link) {
if(!stringExists(link)) {
return;
}
dojo.xhrGet ({
url: link
,timeout: 50000
,content: {session_id:session_logout}
,handleAs:'text'
,load:function(data){
alert("data:"+dumpObj(data));
var l_object = dojo.byId('bodyDiv');
//dijit.byId('bodyDiv').innerHTML = data;
registry.byId('bodyDiv').set('content',data);
}

If understand correctly you now get the error? "'dijit.byId(...)' is null or not an object"?
Make sure the div 'bodyDiv' exists and try:
dom.byId("bodyDiv").innerHTML = data;
Of cause you must also require "dojo/dom".

Related

How can I override the jetbrains jdk dependency required by idea-ultimate or idea-community in config.nix?

I’ve been setting up my local nix config as per nixpkgs manual's declarative package management.
I’d like to include idea-ultimate as one of myPackages, but at this time the dependency idea has on the jetbrains jdk is broken, pointing to a non-existing package for macOS.
It’s trying to download jbrsdk-11_0_2-osx-x64-b485.1.tar.gz instead of jbrsdk-11_0_4-osx-x64-b485.1.tar.gz.
I was assuming I could fix that by overriding jetbrainsjdk as follows, but I’m getting: error: attribute 'jetbrainsjdk' missing, at /Users/ldeck/.config/nixpkgs/config.nix:4:20 when I do anything like nix-env -qa ‘jetbrains.*’.
What is the right way to override idea-ultimate so that it uses the fixed jdk?
Here’s my ~./config/nixpkgs/config.nix.
{
allowUnfree = true;
packageOverrides = pkgs: rec {
jetbrainsjdk = pkgs.jetbrainsjdk.override {
version = "520.11";
src = pkgs.fetchurl {
url = "https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b${jetbrainsjdk.version}.tar.gz";
sha256 = "0d1qwbssc8ih62rlfxxxcn8i65cjgycdfy1dc1b902j46dqjkq9z";
};
};
myProfile = pkgs.writeText "my-profile" ''
export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
'';
myPackages = with pkgs; buildEnv {
name = "my-packages";
paths = [
(runCommand "profile" {} ''
mkdir -p $out/etc/profile.d
cp ${myProfile} $out/etc/profile.d/my-profile.sh
'')
aspell
bc
coreutils
direnv
emacs
emscripten
ffmpeg
gdb
git
hello
jq
nixops
nox
scala
silver-searcher
];
pathsToLink = [ "/share/man" "/share/doc" "/bin" "/etc" "/Applications" ];
extraOutputsToInstall = [ "man" "doc" ];
};
};
}
UPDATE 1
Thanks to #ChrisStryczynski who suggested I needed with pkgs, I’ve gotten a little further.
But now the problem is when attempting to install idea-ultimate with the custom jdk, it’s still requiring the broken, non-existing, jbrsdk-11_02-osx-x64-b485.1.tar.gz.drv from somewhere.
Updated config and logs below.
{
allowUnfree = true;
packageOverrides = pkgs: **with pkgs;** rec {
myJetbrainsJdk = **pkgs.jetbrains.jdk.overrideAttrs** (oldAttrs: rec {
version = "520.11";
src = pkgs.fetchurl {
url = "https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b520.11.tar.gz";
sha256 = "0d1qwbssc8ih62rlfxxxcn8i65cjgycdfy1dc1b902j46dqjkq9z";
};
});
myIdeaUltimate = pkgs.jetbrains.idea-ultimate.override {
jdk = myJetbrainsJdk;
};
...
myPackages = with pkgs; buildEnv {
...
myIdeaUltimate
];
...
};
};
}
Logs
nix-channel --update; nix-env -iA nixpkgs.myPackages
unpacking channels...
replacing old 'my-packages'
installing 'my-packages'
these derivations will be built:
/nix/store/9kfi3k9q6hi7z3lwann318hndbah535v-idea-ultimate.desktop.drv
/nix/store/ica1m5yq3f3y05xnw7ln1lnfvp0yjvyf-download_file?file_path=jbrsdk-11_0_4-osx-x64-b520.11.tar.gz.drv
/nix/store/bf2hwhrvfl8g77gdiw053rayh06x0120-jetbrainsjdk-520.11.drv
/nix/store/fazsa1a4l70s391rjk9yyi2hvrg0zbmp-download_file?file_path=jbrsdk-11_0_2-osx-x64-b485.1.tar.gz.drv
/nix/store/fwwk976sd278zb68zy9wm5pkxss0rnhg-jetbrainsjdk-485.1.drv
/nix/store/s3m2bpcyrnx9dcq4drh95882n0mk1d6m-ideaIU-2019.2.4-no-jbr.tar.gz.drv
/nix/store/9kiajpmmsp3i6ysj4vdqq8dzi84mnr73-idea-ultimate-2019.2.4.drv
/nix/store/jh1ixm54qinv8pk6kypvv6n6cfr4sws8-my-packages.drv
these paths will be fetched (0.02 MiB download, 0.12 MiB unpacked):
/nix/store/hp90sbwznq1msv327f0lb27imvcvi80h-libnotify-0.7.8
building '/nix/store/9kfi3k9q6hi7z3lwann318hndbah535v-idea-ultimate.desktop.drv'...
copying path '/nix/store/hp90sbwznq1msv327f0lb27imvcvi80h-libnotify-0.7.8' from 'https://cache.nixos.org'...
building '/nix/store/fazsa1a4l70s391rjk9yyi2hvrg0zbmp-download_file?file_path=jbrsdk-11_0_2-osx-x64-b485.1.tar.gz.drv'...
trying https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_2-osx-x64-b485.1.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404 Not Found
error: cannot download download_file?file_path=jbrsdk-11_0_2-osx-x64-b485.1.tar.gz from any mirror
builder for '/nix/store/fazsa1a4l70s391rjk9yyi2hvrg0zbmp-download_file?file_path=jbrsdk-11_0_2-osx-x64-b485.1.tar.gz.drv' failed with exit code 1
building '/nix/store/ica1m5yq3f3y05xnw7ln1lnfvp0yjvyf-download_file?file_path=jbrsdk-11_0_4-osx-x64-b520.11.tar.gz.drv'...
cannot build derivation '/nix/store/fwwk976sd278zb68zy9wm5pkxss0rnhg-jetbrainsjdk-485.1.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/9kiajpmmsp3i6ysj4vdqq8dzi84mnr73-idea-ultimate-2019.2.4.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/jh1ixm54qinv8pk6kypvv6n6cfr4sws8-my-packages.drv': 1 dependencies couldn't be built
error: build of '/nix/store/jh1ixm54qinv8pk6kypvv6n6cfr4sws8-my-packages.drv' failed
Thanks to How do you discover the override attributes for a derivation, a solution has been found using an overlay.
# ~/config/nixpkgs/overlays/02-jetbrains.nix
self: super:
{
jetbrains = super.jetbrains // {
jdk = super.jetbrains.jdk.overrideAttrs (oldAttrs: rec {
version = "520.11";
src = super.fetchurl {
url = "https://bintray.com/jetbrains/intellij-jbr/download_file?file_path=jbrsdk-11_0_4-osx-x64-b520.11.tar.gz";
sha256 = "3fe1297133440a9056602d78d7987f9215139165bd7747b3303022a6f5e23834";
};
passthru = oldAttrs.passthru // {
home = "${self.jetbrains.jdk}/Contents/Home";
};
});
idea-ultimate = super.jetbrains.idea-ultimate.overrideAttrs (_: {
name = "idea-ultimate.2019.2.4";
src = super.fetchurl {
url = "https://download.jetbrains.com/idea/ideaIU-2019.2.4-no-jbr.tar.gz";
sha256 = "09mz4dx3zbnqw0vh4iqr8sn2s8mvgr7zvn4k7kqivsiv8f79g90a";
};
});
};
}
Install: nix-env -iA 'nixpkgs.jetbrains.idea-ultimate'.
Execute: idea-ultimate.
The crucial part of the puzzle was overriding the passthru.home variable to point to the overlayed JDK rather than the one required by super. Otherwise, you’ll be downloading the old JDK for runtime purposes.
passthru = oldAttrs.passthru // {
home = "${self.jetbrains.jdk}/Contents/Home”;
};
Without /Contents/Home appended, idea won’t startup since self.jetbrains.jdk isn’t a valid home.
Instead of:
nix-env -iA nixpkgs.myPackages
Just do:
nix-env -iA nixpkgs.myIdeaUltimate
The problem being:
myPackages = with pkgs; buildEnv {
...
myIdeaUltimate
];
...
};
Here you are still referencing the old pkgs.myIdeaUltimate.
Nixos seems to do some processing that replaces the pkgs with the appropriate from packageOverrides.

Call fetchgit without SSL Verify

I'm trying to use fetchgit to download source repos from my lab's private GitLab server, which currently self-signs its SSL certificate.
default.nix:
with (import <nixpkgs> {});
{ test-pkg = callPackage ./test-pkg.nix {
buildPythonPackage = python35Packages.buildPythonPackage;
};
}
test-pkg.nix:
{ buildPythonPackage,fetchgit }:
buildPythonPackage rec {
pname = "test-pkg";
version = "0.2.1";
src = fetchgit {
url = "https://gitlabserver/experiment-deployment/test-pkg";
rev = "refs/tags/v${version}";
sha256 = "43c2c9e5e7a16b6c88ba3088a9bfc82f7db8e13378be7c78d6c14a5f8ed05afd";
};
}
Which results in the error when I call nix-shell
fatal: unable to access 'https://gitlabserver/experiment-deployment/test-pkg/': SSL certificate problem: self signed certificate
Looking at, build-support/fetchgit, it seems that fetchgit is made with mkDerivation, so I tried to make a new fetchgit using overrideAttrs. I pass in the git environment variable to make git ignore SSL verification, expecting that the variable will be initialized during the setup phase.
revised default.nix:
with (import <nixpkgs> {});
let fetchgit-no-verify = fetchgit.overrideAttrs { GIT_SSL_NO_VERIFY=true;} ;
in rec {
test-pkg = callPackage ./test-pkg.nix {
buildPythonPackage = python35Packages.buildPythonPackage;
fetchgit = fetchgit-no-verify;
};
}
I thought I was really clever when I thought of this over the weekend, only to discover that when implemented my new error states that
error: attribute 'overrideAttrs' missing, at [...]/default.nix:2:26
Inspecting fetchgit in nix repl shows that it is a functor attribute set. I tried for a little bit to get to the overrideAttrs, without success. Trying again I saw that git could be passed to to fetchGit,
re-revised default.nix:
with (import <nixpkgs> {});
let git = git.overrideAttrs { GIT_SSL_NO_VERIFY=true;} ;
fetchgit-no-verify = fetchgit.override { git=git-no-verify;} ;
in rec {
test-pkg = callPackage ./test-pkg.nix {
buildPythonPackage = python35Packages.buildPythonPackage;
fetchgit = fetchgit-no-verify;
};
}
but the new error:
error: attempt to call something which is not a function but a set, at /nix/store/jmynn33vcn3mcscsch0zf46fz9wsw05y-nixpkgs-20.03pre193309.c4196cca9ac/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:318:55
Finally, onto my questions. Is there a way to add the environment variable to the fetchgit or git derivations? Is there perhaps another way to connect--some builtin option I missed? I could use a private repository, using ssh and avoiding https, however due to how we deploy experiments I'd like to avoid that.
I was able to make this work with this ugly thing.
default.nix:
with (import <nixpkgs> {});
let fetchgit-no-verify = fetchgit // {
__functor = self : args :
(fetchgit.__functor self args).overrideAttrs (oldAttrs:{GIT_SSL_NO_VERIFY=true;});
} ;
in rec {
test-pkg = callPackage ./test-pkg.nix {
buildPythonPackage = python35Packages.buildPythonPackage;
fetchgit = fetchgit-no-verify;
};
}
fetchgit-no-verify uses the fetchgit functor set to begin with and overwrites the __functor attribute with a new function. The new functor just applies its arguments and then calls overrideAttrs.
This works, but I'm happy to award the answer to anybody who can add some insight or comes with another solution. For one, I'd like to know how the fetchgit derivation becomes a functor. Is this something callPackage does?.

how to update file name dynametically when upload in ionic 4

hi i am using Ionic 4 with angular 7 in my project.
Currently i am facing difficulties on upload image.
File Transfer works fine with a static name like:
let options: FileUploadOptions = {
fileKey: 'file',
fileName: 'name.jpg',
headers: {}
.....
}
it working fine. but i need dynamic name. so i updated accordingly
this.temp_image_name = new Date().getTime()+'.jpg';
let options: FileUploadOptions = {
fileKey: 'file',
fileName: this.temp_image_name,
headers: {}
.....
}
but it not working and file name return empty. have any idea on this issue.
Thanks
i solved the issue in server side, before save or upload i renamed the file.
$temp = explode(".", $_FILES["file"]["name"]);
$newfilename = time() . '.' . end($temp);
$target_path = $target_path . $newfilename;
and return the newfileName to use the name for next use.
I tested the snippet just to be sure that combining a number getTime() and a string was ok, but it didn't seem to have any issues:
You are using a class level variable which may be being affected by something.
Try:
let temp_image_name = new Date().getTime()+'.jpg';
let options: FileUploadOptions = {
fileKey: 'file',
fileName: temp_image_name,
headers: {}
.....
}
It seems like you should not be using this plugin at all anyway as it is deprecated.

Paypal Php Sdk - NotifyUrl is not a fully qualified URL Error

I have this code
$product_info = array();
if(isset($cms['site']['url_data']['product_id'])){
$product_info = $cms['class']['product']->get($cms['site']['url_data']['product_id']);
}
if(!isset($product_info['id'])){
/*
echo 'No product info.';
exit();
*/
header_url(SITE_URL.'?subpage=user_subscription#xl_xr_page_my%20account');
}
$fee = $product_info['yearly_price_end'] / 100 * $product_info['fee'];
$yearly_price_end = $product_info['yearly_price_end'] + $fee;
$fee = ($product_info['setup_price_end'] / 100) * $product_info['fee'];
$setup_price_end = $product_info['setup_price_end'] + $fee;
if(isset($_SESSION['discountcode_amount'])){
$setup_price_end = $setup_price_end - $_SESSION['discountcode_amount'];
unset($_SESSION['discountcode_amount']);
}
$error = false;
$plan_id = '';
$approvalUrl = '';
$ReturnUrl = SITE_URL.'payment/?payment_type=paypal&payment_page=process_agreement';
$CancelUrl = SITE_URL.'payment/?payment_type=paypal&payment_page=cancel_agreement';
$now = $cms['date'];
$now->modify('+5 minutes');
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
$cms['options']['plugin_paypal_clientid'], // ClientID
$cms['options']['plugin_paypal_clientsecret'] // ClientSecret
)
);
use PayPal\Api\ChargeModel;
use PayPal\Api\Currency;
use PayPal\Api\MerchantPreferences;
use PayPal\Api\PaymentDefinition;
use PayPal\Api\Plan;
use PayPal\Api\Patch;
use PayPal\Api\PatchRequest;
use PayPal\Common\PayPalModel;
use PayPal\Api\Agreement;
use PayPal\Api\Payer;
use PayPal\Api\ShippingAddress;
// Create a new instance of Plan object
$plan = new Plan();
// # Basic Information
// Fill up the basic information that is required for the plan
$plan->setName($product_info['name'])
->setDescription($product_info['desc_text'])
->setType('fixed');
// # Payment definitions for this billing plan.
$paymentDefinition = new PaymentDefinition();
// The possible values for such setters are mentioned in the setter method documentation.
// Just open the class file. e.g. lib/PayPal/Api/PaymentDefinition.php and look for setFrequency method.
// You should be able to see the acceptable values in the comments.
$setFrequency = 'Year';
//$setFrequency = 'Day';
$paymentDefinition->setName('Regular Payments')
->setType('REGULAR')
->setFrequency($setFrequency)
->setFrequencyInterval("1")
->setCycles("999")
->setAmount(new Currency(array('value' => $yearly_price_end, 'currency' => $cms['session']['client']['currency']['iso_code'])));
// Charge Models
$chargeModel = new ChargeModel();
$chargeModel->setType('SHIPPING')
->setAmount(new Currency(array('value' => 0, 'currency' => $cms['session']['client']['currency']['iso_code'])));
$paymentDefinition->setChargeModels(array($chargeModel));
$merchantPreferences = new MerchantPreferences();
// ReturnURL and CancelURL are not required and used when creating billing agreement with payment_method as "credit_card".
// However, it is generally a good idea to set these values, in case you plan to create billing agreements which accepts "paypal" as payment_method.
// This will keep your plan compatible with both the possible scenarios on how it is being used in agreement.
$merchantPreferences->setReturnUrl($ReturnUrl)
->setCancelUrl($CancelUrl)
->setAutoBillAmount("yes")
->setInitialFailAmountAction("CONTINUE")
->setMaxFailAttempts("0")
->setSetupFee(new Currency(array('value' => $setup_price_end, 'currency' => $cms['session']['client']['currency']['iso_code'])));
$plan->setPaymentDefinitions(array($paymentDefinition));
$plan->setMerchantPreferences($merchantPreferences);
// ### Create Plan
try {
$output = $plan->create($apiContext);
} catch (Exception $ex){
die($ex);
}
echo $output->getId().'<br />';
echo $output.'<br />';
Been working with paypal php sdk for some days now and my code stop working.
So i went back to basic and i am still getting the same damn error.
I am trying to create a plan for subscription but getting the following error:
"NotifyUrl is not a fully qualified URL"
I have no idea how to fix this as i dont use NotfifyUrl in my code?
Could be really nice if anyone had an idea how to fix this problem :)
Thanks
PayPal did a update to their API last night which has caused problem within their SDK.
They are sending back null values in their responses.
I MUST stress the error is not on sending the request to PayPal, but on processing their response.
BUG Report : https://github.com/paypal/PayPal-PHP-SDK/issues/1151
Pull Request : https://github.com/paypal/PayPal-PHP-SDK/pull/1152
Hope this helps, but their current SDK is throwing exceptions.
Use below simple fix.
Replace below function in vendor\paypal\rest-api-sdk-php\lib\PayPal\Api\MerchantPreferences.php
public function setNotifyUrl($notify_url)
{
if(!empty($notify_url)){
UrlValidator::validate($notify_url, "NotifyUrl");
}
$this->notify_url = $notify_url;
return $this;
}
If you get the same error for return_url/cancel_url, add the if condition as above.
Note: This is not a permanent solution, you can use this until getting the update from PayPal.
From the GitHub repo for the PayPal PHP SDK, I see that the error you mentioned is thrown when MerchantPreferences is not given a valid NotifyUrl. I see you're setting the CancelUrl and ReturnUrl, but not the NotifyUrl. You may simply need to set that as well, i.e.:
$NotifyUrl = (some url goes here)
$obj->setNotifyUrl($NotifyUrl);
Reason behind it!
error comes from.
vendor\paypal\rest-api-sdk-php\lib\PayPal\Validation\UrlValidator.php
line.
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
throw new \InvalidArgumentException("$urlName is not a fully qualified URL");
}
FILTER_VALIDATE_URL: according to this php function.
INVALID URL: "http://cat_n.domain.net.in/"; // IT CONTAIN _ UNDERSCORE.
VALID URL: "http://cat-n.domain.net.in/"; it separated with - dash
here you can dump your url.
vendor\paypal\rest-api-sdk-php\lib\PayPal\Validation\UrlValidator.php
public static function validate($url, $urlName = null)
{
var_dump($url);
}
And then check this here: https://www.w3schools.com/PHP/phptryit.asp?filename=tryphp_func_validate_url
you can check here what character will reason for invalid.

Strophe.attach not working - I am using openfire locally

I am trying to implment the XMPP Client. I am using BOSH Connection manager and can run the Strophe.connect but not Strophe.Attach. I have tried incrementing the RID, but no effect.. Any help please ? There is no error here, but the Strophe.Status.CONNECTED is never reached via the attach method and so I cannot send IQ or Presence.
Here is my code
try
{
var cookieJid = $.cookie("jid");
var cookieSid = $.cookie("sid");
var cookieRid = $.cookie("rid");
var connt = new Strophe.Connection("http://localhost:7070/http-bind/");
connt.attach(cookieJid, cookieSid, cookieRid + 1, function(status)
{
if (status === Strophe.Status.CONNECTED)
{
alert ("hola connected");
$("#userName").append("hola connected : " + connt.jid );
var iq = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:roster'});
connt.sendIQ(iq, handleRoster);
connt.send($pres());
}
});
}
catch (e)
{
$("#userName").append("Pinky error is " + e);
}
Edit
Thanks Eric and Charlie.
So I took the latest Strophe.js and now Attached status does work.
But the connection disconnects instantaneously. I am not even able to fetch the Roster.
We can possibly do every thing with Connection.attach() as we would with connection.connect(), right?
Any thoughts?
Change the line:
if (status === Strophe.Status.CONNECTED)
...to...
if (status === Strophe.Status.CONNECTED || status === Strophe.Status.ATTACHED)
Are you using the latest Strophe library? In the version I'm using, I see that the status can be these values:
Status: {
ERROR: 0,
CONNECTING: 1,
CONNFAIL: 2,
AUTHENTICATING: 3,
AUTHFAIL: 4,
CONNECTED: 5,
DISCONNECTED: 6,
DISCONNECTING: 7,
ATTACHED: 8
}
Make sure you convert your cookieRid to a Number by using new Number(cookieRid). Otherwise, when you do +1 on it, you will get "####1".
You can test this out for yourself in Javascript:
var s = "123";
alert(s+1); // "1231" and not "124"
Also, as Eric answered, there is a status ATTACHED so you need to handle that event.