I am using WebStorm 2017, but i have faced annoying issue with Line comments wrap
Before:
"devDependencies" : {
"gulp" : "latest", /* Manager */
"gulp-babel" : "latest", /* Minify JS (ES2015) */
"gulp-babili" : "latest", /* gulp-babel */
"gulp-csso" : "latest", /* Minify CSS */
"gulp-htmlmin" : "latest", /* Minify HTML */
"gulp-rigger" : "latest", /* Insert file to file */
"gulp-sass" : "latest", /* Compile SASS */
"gulp-sourcemaps" : "latest", /* Sourcemap to JS\CSS */
"gulp-uncss" : "latest", /* Clear CSS */
"gulp-util" : "latest", /* Gulp util */
"rimraf" : "latest" /* File delete */
}
After:
"devDependencies" : {
"gulp" : "latest",
/* Manager */
"gulp-babel" : "latest",
/* Minify JS (ES2015) */
"gulp-babili" : "latest",
/* gulp-babel */
"gulp-csso" : "latest",
/* Minify CSS */
"gulp-htmlmin" : "latest",
/* Minify HTML */
"gulp-rigger" : "latest",
/* Insert file to file */
"gulp-sass" : "latest",
/* Compile SASS */
"gulp-sourcemaps" : "latest",
/* Sourcemap to JS\CSS */
"gulp-uncss" : "latest",
/* Clear CSS */
"gulp-util" : "latest",
/* Gulp util */
"rimraf" : "latest"
/* File delete */
}
How to disable line wrap for comments? In to all formats, json, js etc...
Need some help.
Comments are kept on same line to me when formatting JavaScript object literals.
For JSON, try setting Objects to Do not wrap in Settings | Editor | Code Style | JSON | Wrapping and Braces
Related
Using the nodejs AWS SDK i'm trying to update my quickSight DataSet with a csv file in S3 bucket.
When calling the AWS quicksight update-data-set command(https://docs.aws.amazon.com/cli/latest/reference/quicksight/update-data-set.html) I'm getting the following error:
'physicalTableMap.string.member.s3Source.dataSourceArn' failed to satisfy constraint: Specified resource is not reachable in this region ('us-east-1')
I checked my quicksight region and s3 bucket region all set to 'us-east-1', so not sure why it's still complaining about region? IAM is also set to us-east-1
the dataSourceArn i'm passing is the arn for the S3 csv file.
Code
const updateDataSetParams: UpdateDataSetRequest = {
AwsAccountId: awsAccountId /* required */,
DataSetId: getEnvironmentKeyValue("AWS_PERMISSIONS_DATA_SET_ID") /* required */,
ImportMode: "SPICE" /* required */,
Name: getEnvironmentKeyValue("AWS_PERMISSIONS_DATA_SET_DISPLAY_NAME") /* required */,
PhysicalTableMap: {
string: {
S3Source: {
DataSourceArn: getEnvironmentKeyValue("AWS_PERMISSIONS_S3_DATA_SOURCE_ARN") /* required */,
InputColumns: [
/* required */
{
Name: "UserName" /* required */,
Type: "STRING" /* required */
},
{
Name: "CompanyName" /* required */,
Type: "STRING" /* required */
},
{
Name: "BranchIds" /* required */,
Type: "STRING" /* required */
}
/* more items */
],
UploadSettings: {
ContainsHeader: true,
Delimiter: ",",
Format: "CSV"
// StartFromRow: 2
}
}
}
}
};
const updateDataSet = await quicksight.updateDataSetAsync(updateDataSetParams);
p:s , I manage to call other quicksight commands like create-namespace and create-user which all work fine. Only when I try to update the dataset.
Cross-posting to drupal.stackexchange.com
I am creating a custom field to eventually be displayed in a custom paragraph. I need to upload a JS file for the widget view, but can't seem to get it to work. Can anyone see what I am doing wrong or need to do differently?
I can add the field to the paragraph, add the paragraph to a document and see the fields, but I see no evidence of the JS being attached (the file is not downloaded in the browser and does not activate).
Any help or suggestions are appreciated.
file: src/Plugin/Field/FieldWidget/get_libguides_listings_widget.php:
<?php
namespace Drupal\get_libguides_listings\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
class get_libguides_listings_widget extends WidgetBase {
/**
* {#inheritdoc}
*/
public function formElement(
FieldItemListInterface $items,
$delta, array $element, array &$form,
FormStateInterface $form_state) {
$element['Subject_IDs'] = [
'#type'=>'textfield',
'#title'=>$this->t('Subject IDs to Display'),
'#description'=>$this->t('BLAH'),
'#default_value'
=>isset($items->getValue()[$delta]['Subject_IDs'])
?$items->getValue()[$delta]['Subject_IDs']
:'',
'#states'=>[
'visible' => [
[':input[name$="default_value_input[field_libguides_listing][0][SearchBy]"]'
=>['value'=>'subject']],
'or',
[':input[name$="default_value_input[field_libguides_listing][0][SearchBy]"]'
=>['value'=>'both']],
],
],
];
$element['Subject_IDs']['#attached'][]
= 'get_libguides_listings/get_searchby';
return $element;
}
}
file: get_libguides_listings.libraries.yml:
get_searchby:
js:
js/get_searchby.js: {}
dependencies:
- core/jquery
- core/drupal
- core/drupalSettings
file: js/get_searchby.js
/**
* #file
*/
(function(){
alert('hello there');
(function ($, Drupal)
{
Drupal.behaviors.get_searchby = {
attach: function (context, settings)
{
alert('hello');
}
};
}(jQuery, Drupal));
}());
Turns out I forgot the 'library' key $element['Subject_IDs']['#attached']['library'][] = ...
I have some code as below:
/* global document */
/* global window */
/* global Blob */
import FileSaver from 'file-saver';
export const createDownloadFromBlob = (blob, filename, extension) => {
FileSaver.saveAs(blob, `${filename}.${extension}`);
};
export const createDownload = (content, filename, extension) => {
createDownloadFromBlob(new Blob([content], { type: 'application/octet-stream' }), filename, extension);
};
I want to use Jest to unit-test these two methods, but I don't know where to start. Any help would be appreciated.
I would mock out FileSaver with a spy:
import FileSaver from 'file-saver';
jest.mock('file-saver', ()=>({saveAs: jest.fn()}))
As you cant compare Blobs I would mock this as well:
global.Blob = function (content, options){return ({content, options})}
now you can run your test and use expect like this
createDownload('content', 'filename', 'extension')
expect(FileSaver.saveAs).toHaveBeenCalledWith(
{content:'content', options: { type: 'application/octet-stream' }},
'filename.extension'
)
In Typescript: If you create a Blob with a ArrayBuffer or binary data then you need handle that case separately than strings.
import * as CRC32 from 'crc-32';
(window as any).global.Blob = function(content, options) {
// for xlxs blob testing just return the CRC of the ArrayBuffer
// and not the actual content of it.
if (typeof content[0] !== 'string') {
content = CRC32.buf(content);
}
return {content: JSON.stringify(content), options};
};
I'm trying to add Fenom Tempate to Yii2 application, but I'm getting a lot of different kinds errors.
I've tried to create a component ViewRenderer and to write code like here, but with my own namespace:
namespace app\components\fenom;
use Yii;
use yii\base\View;
use yii\base\ViewRenderer as BaseViewRenderer;
class ViewRenderer extends BaseViewRenderer {
/**
* #var string the directory, where stores templates.
*/
public $templatePath = '#app/views';
/**
* #var string the directory, where stores compiled templates in PHP files.
*/
public $compilePath = '#runtime/Fenom/compile';
/**
* #var int|array bit-mask or array of Fenom settings.
* #see https://github.com/bzick/fenom/blob/master/docs/en/configuration.md#template-settings
*/
public $options = 0;
/**
* #var \Fenom object that renders templates.
*/
public $fenom;
public function init() {
$this->fenom = \yii\fenom\Fenom::factory($this->templatePath, $this->compilePath, $this->options);
}
public function render($view, $file, $params) {
$params['this'] = $view;
return $this->fenom->fetch($file, $params);
}
}
Added this component to config
'components' => [
'view' => [
'class' => 'yii\web\View',
'renderers' => [
'tpl' => [
'class' => 'app\components\fenom\ViewRenderer',
'options' => [
'auto_reload' => true,
],
],
// ...
],
],
But I'm getting errors. Bad namespace or unwritable directory or another and another errors.
So, my question is: How to add Fenom to Yii2? What and Where should I write (in config, components, or other folders)? What way is the fastest and the most efficient?
Please tell me how to do it properly?
Well, I did it. I'm not sure if this is correct, but...
I made the fenom folder inside the components folder. I put files from the src folder of fenom repo into the /components/fenom.
Also in this folder I created a ViewRenderer.php file. It contains code:
<?php
namespace app\components\fenom;
use Yii;
use yii\base\ViewRenderer as BaseViewRenderer;
class ViewRenderer extends BaseViewRenderer {
/**
* #var string the directory, where stores templates.
*/
public $templatePath = '#app/views';
/**
* #var string the directory, where stores compiled templates in PHP files.
*/
public $compilePath = '#runtime/Fenom/compile';
/**
* #var int|array bit-mask or array of Fenom settings.
* #see https://github.com/bzick/fenom/blob/master/docs/en/configuration.md#template-settings
*/
public $options = ['auto_reload' => true];
/**
* #var \Fenom object that renders templates.
*/
public $fenom;
public function init() {
// put main Fenom class into the yii classmap
Yii::$classMap['Fenom'] = __DIR__.'/Fenom.php';
// call Fenom class autoloader (https://github.com/fenom-template/fenom/blob/master/docs/en/start.md#custom-loader)
\Fenom::registerAutoload(__DIR__."./");
// Yii::getAlias - because it's not understand Yii aliases???
$this->fenom = \Fenom::factory(Yii::getAlias($this->templatePath), Yii::getAlias($this->compilePath), $this->options);
}
public function render($view, $file, $params) {
$params['this'] = $view;
$dirPath = '';
// this is because Fenom do not understand absolute paths???
if (strpos($file, 'views') != false)
$dirPath = explode('views', $file)[1];
if (strpos($file, 'widgets') != false)
$dirPath = explode('widgets', $file)[1];
if (strpos($file, 'modules') != false)
$dirPath = explode('modules', $file)[1];
return $this->fenom->fetch($dirPath, $params);
}
}
I've added ViewRenderer component into the config file:
'components' => [
'view' => [
'class' => 'yii\web\View',
'renderers' => [
'tpl' => [
'class' => 'app\components\fenom\ViewRenderer',
],
],
],
// ...
and created folders inside the runtime folder
- runtime
- Fenom
- compile
- cache
compile - for compiled filed, cache - for cached filed
That's it.
For testing:
/views/site/index.tpl file contains:
{$testtext}
/controllers/SiteController → actionIndex contains:
public function actionIndex() {
return $this->render('index.tpl', ['testtext' => 'It works! Test text']);
}
result:
Something like that...
Installation
Since fenom is an extension on its own, you should use composer to install it. From the docs:
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist y2i/yii2-fenom "*"
or add
"y2i/yii2-fenom": "*"
to the require section of your composer.json file.
Usage
The class element in your config file should be a fully qualified class name, not a path to the class file. As such, if installed using composer, you can use the following:
'class' => 'y2i\fenom\ViewRenderer'
I'm trying to get into unreal engine 4 module development, starting out with blank module for starters, but hitting a block at the start.
Tutorial that I went through for a non-game module: https://wiki.unrealengine.com/An_Int...to_UE4_Plugins. I tried going exactly by the source and later modifying everything to TestPlugin (since I couldn't get it to work by the tutorial either).
For some reason, whenever I try to activate the module within the editor, I get the "can't find the "Module" module". I am trying to figure out if I missed something, here is the code that I have so far:
../Engine/Plugins/TestPlugin/TestPlugin.uplugin
{
"FileVersion" : 3,
"FriendlyName" : "Test Plugin",
"Version" : 1,
"VersionName": "1.0",
"EngineVersion" : 1579795,
"Description" : "Description goes here",
"Category" : "Test.Module",
"CreatedBy" : "arhon",
"CreatedByURL" : "http://stackoverflowcom",
"CanContainContent" : "true",
"Modules" :
[
{
"Name" : "Module",
"Type" : "Developer",
"LoadingPhase" : "PreDefault"
}
]
}
../Engine/Plugins/TestPlugin/Source/TestPlugin/TestPlugin.cpp
void FTestPlugin::StartupTestPlugin()
{
if (ITestPlugin::IsAvailable())
{
UE_LOG(TestPlugin, Log, TEXT("%s"), ITestPlugin::Get().IsThisNumber42(42) ? TEXT("True") : TEXT("False"));
UE_LOG(TestPlugin, Log, TEXT("%s"), ITestPlugin::Get().IsThisNumber42(12) ? TEXT("True") : TEXT("False"));
}
}
../Engine/Plugins/TestPlugin/Source/TestPlugin/TestPlugin.Build.cs
using UnrealBuildTool;
public class TestPlugin : ModuleRules
{
public TestPlugin(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { "TestPlugin" });
DynamicallyLoadedModuleNames.AddRange(new string[] { "StandAlone" });
}
}
../Engine/Plugins/TestPlugin/Source/TestPlugin/Public/ITestPlugin.h
#pragma once
#include "ModuleManager.h"
/**
* The public interface to this module. In most cases, this interface is only public to sibling modules
* within this plugin.
*/
class ITestPlugin : public ITestPluginInterface
{
public:
/**
* Singleton-like access to this module's interface. This is just for convenience!
* Beware of calling this during the shutdown phase, though. Your module might have been unloaded already.
*
* #return Returns singleton instance, loading the module on demand if needed
*/
static inline ITestPlugin& Get()
{
return FModuleManager::LoadModuleChecked< ITestPlugin >("TestPlugin");
}
/**
* Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true.
*
* #return True if the module is loaded and ready to use
*/
static inline bool IsAvailable()
{
return FModuleManager::Get().IsModuleLoaded("TestPlugin");
}
virtual bool IsThisNumber42(int32 num) = 0;
};
../Engine/Plugins/TestPlugin/Source/TestPlugin/Private/TestPluginPrivatePCH.h
#include "ITestPlugin.h"
// You should place include statements to your module's private header files here. You only need to
// add includes for headers that are used in most of your module's source files though.
../Engine/Plugins/TestPlugin/Source/TestPlugin/Private/TestPlugin.h
#pragma once
class TestPluginImpl : public ITestPlugin
{
public:
/** IModuleInterface implementation */
void StartupTestPlugin();
void ShutdownTestPlugin();
bool IsThisNumber42(int32 num);
};
../Engine/Plugins/TestPlugin/Source/TestPlugin/Private/TestPlugin.cpp
#include "TestPluginPrivatePCH.h"
#include "TestPlugin.h"
void TestPluginImpl::StartupTestPlugin()
{
}
void TestPluginImpl::ShutdownTestPlugin()
{
}
bool TestPluginImpl::IsThisNumber42(int32 num)
{
return num == 42;
}
IMPLEMENT_MODULE(TestPluginImpl, TestPlugin)
In the .uplugin file, look at your module name, then in testplugin.cpp, look at this line:
IMPLEMENT_MODULE(TestPluginImpl, TestPlugin)
I'm sure they need to match.
e.g.:
"Modules" :
[
{
"Name" : "NebulaAudioAnalysisPlugin",
"Type" : "Runtime"
}
]
and my implementation looks like:
IMPLEMENT_MODULE(FNebulaAudioAnalysisPlugin, NebulaAudioAnalysisPlugin)
I found this all out the hard way...