In Rails 5, how do i define an application specific config variable? - initialization

I'm using Rails 5. How do I define a non-environment specific application configuration variable? I tried creating this in config/initializers/global.rb
config.num_currencies_in_index = 12
but am greeted with this error
NameError: undefined local variable or method `config' for main:Object
/Users/davea/Documents/workspace/cindex/config/initializers/global.rb:1:in `<top (required)>'

I would suggest creating a module in initializers called Constants and then just define GLOBAL_VARIABLES under that namespace and use them in your app. This way you can't accidentaly override Rails config.
so your initializer would look like
module Constants
NUM_CURRENCIES_IN_INDEX = 12.freeze
end
then you can use it in your code with Constants::NUM_CURRENCIES_IN_INDEX

Related

Next.js doesn't pick up variables from the .env file

I want to use a variable from the .env file, but I'm getting the following error:
Uncaught (in promise) IntegrationError: Please call Stripe() with your publishable key. You used an empty string.
code
import Stripe from "stripe";
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY);
.env
NEXT_PUBLIC_STRIPE_SECRET_KEY=***
In Next.js you should declare your environment variables in a .env.localĀ file.
For more informations check the official docs.
However, as suggested by #juliomalves, you can declare your environment variables in a .env.* file, making sure that you respect the environment variables load order.

"TS2729 [ERROR]: Property 'boundary' used before its initialization" in extern library

After updating my deno version to 1.9 today I had started having the following problem when running my tests or my scripts:
TS2729 [ERROR]: Property 'boundary' is used before its initialization.
readonly dashBoundary = encoder.encode(`--${this.boundary}`);
~~~~~~~~
at https://deno.land/std#0.63.0/mime/multipart.ts:266:52
'boundary' is declared here.
constructor(reader: Deno.Reader, private boundary: string) {
~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/std#0.63.0/mime/multipart.ts:269:36
I checked and I am not using the mime repository anywhere in my code, instead some other repositories must use it.
I am using the following repositories:
x/abc
std/uuid
std/fs
std/path
std/fmt
std/testing
I made sure that I am explicitely using the newest version for all of the imports of the std library (std version 0.93.0).
When I am running the files that are importing the std library (instead of running the entire application) no errors occur.
Does anyone have an idea how to resolve the error?
It seems like the repository x/abc was the problem.
I did not add a version when importing it implicitly. When importing implicitly it in the following way it worked:
import abc from "https://deno.land/x/abc#v1.3.1/mod.ts";

Execute external jar file from pentaho

I am trying to execute a custom jar file from the modified javascript value. My Jar name is JsonParsing.jar which I have placed in lib folder. When I am trying to execute a method in the jar its giving me the error:
ReferenceError: "JsonParsing" is not defined.
Code Snippet:
var package1 = JsonParsing.parseJson.ParseJSON;
xyz=package1.processJson(data);
The Javascript kettle uses is Rhino. Rhino gives Javascript access to Java classes, but it's not completely transparent.
Check out the Rhino docs on Scripting Java.
I have resolved the issue. I was missing the Packages thing while creating the instance. As I had a static method in my class I have to call it in the following way. (parseJson is my package name and ParseJSON is my class name) . Here Packages is the default class provided by Rhino
var call = Packages.parseJson.ParseJSON;
xyz=call.processJson(data);
If it is a non static method I had to create an object in the following way
var call = new Pakages.parseJson.ParseJSON();
xyz=call.processJson(data);

Symfony2: overriding Sensio FrameworkExtraBundle template guesser

I am trying to override the standard template guesser ( located in Sensio\Bundle\FrameworkExtraBundle\Templating; ) becouse I want to use annotations to set the view but need to change the logic of how the actual view file is chosen.
I have seen this: https://github.com/elnur/ElnurTemplateGuesserBundle
but I was wondering if there is a way to just override the service in configuration.
I tried setting:
services:
sensio_framework_extra.view.guesser:
class: myCompany\myBundle\Templating\TemplateGuesser
but I get:
ContextErrorException: Catchable Fatal Error:
Argument 1 passed to Sensio\Bundle\FrameworkExtraBundle\Templating\TemplateGuesser::__construct()
must implement interface Symfony\Component\HttpKernel\KernelInterface, none given
Am I supposed to set an argument in the service config setting? But how do I reference the HttpKernel?
Or am I missing something?
TIA.
You can inject the kernel the same way the as the original TemplateGuesser. The name of the Kernel service is just simply kernel.
services:
sensio_framework_extra.view.guesser:
class: myCompany\myBundle\Templating\TemplateGuesser
arguments: [ "#kernel" ]
To see a full list of services in the container, run
$ php app/console container:debug
Of which you'll see the kernel listed as one of them.

Drupal 7 - image module and contrib module

I wrote a module with "image" in dependecies. But I can't use the functions in image.gd.php
Apache log:
Call to undefined function image_gd_save()
Can you help me?
If you're doing this outside of the normal operation of the image/system modules you'll need to make sure the relevant file is included first:
module_load_include('inc', 'system', 'image.gd');

Resources