Image require with variable path not working - reactjs

Actually trying to check if file(image) exists to add it to render.
Confused that this code works
let i = 2;
let s = require('../../public' + this.cardData.image.optional_path + '-' + i + '.jpg');
and as a result s = Module
And this one produce an error
let i = 2;
let path = '../../public' + this.cardData.image.optional_path + '-' + i + '.jpg';
let z = require(path);
Error message:
Uncaught Error: Cannot find module '../../public/images/catgory1/images-2.jpg'
Did i missed something ?

Related

How to write a 2D array to a single column in Google Sheets, using Google Apps Script?

I'm trying to write the array to a single column, but despite everything seems right to me, it keeps throwing me an error:
Here's the piece of code:
function getGFTickersData() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("LIST OF STOCKS");
var tickerRng = ss.getRange(2, 1, ss.getLastRow(), 1).getValues();
//var TDSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("TickersData");
var TDSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet10");
var tickerArr = [];
for (var b = 0; b < tickerRng.length; b++) {
var tickerToArr = [tickerRng[b]];
if (tickerToArr != '') {
var gFinFormula = "=query(googlefinance(" + '"' + tickerToArr + '"' + ",'all shares'!A4,'all shares'!D3,'all shares'!D4,'all shares'!D5)," + '"' + "select *" + '"' + ",1)";
var repeated = [].concat(... new Array(105).fill(tickerToArr))
tickerArr.push(repeated)
}
}
Logger.log(tickerArr[0]);
TDSheet.getRange(TDSheet.getLastRow() + 1, 1, tickerArr.length, 1).setValues(tickerArr);
}
Appreciate any pointers!
From your following replying,
The array is composed of about 200k element, each showing in the array 105 times. I want to write all of them, one on the top of the other in a single column.
How about the following modification?
From:
tickerArr.push(repeated)
To:
tickerArr = tickerArr.concat(repeated);
References:
push()
concat()

Alway get an error "No attribute named 'name' is defined" if try to process multiple lines from csv data feed

In my test script I try to process 100 lines data from csv data feed via following statement:
private val scn = scenario("test_scn").feed(insertFeeder, 100).exec(httpReq)
But I always get an error:
[ERROR] HttpRequestAction - 'httpRequest-1' failed to execute: No attribute named 'name' is defined
Could you please help me to find out the root cause? thank you.
Here is the script:
private val insertFeeder = csv("test_data.csv").queue
private val csvHeader = GeneralUtil.readFirstLine(""test_data.csv"")
private val httpConf = http .baseURL("http://serviceURL") .disableFollowRedirect .disableWarmUp .shareConnections
private var httpReq = http("insert_request") .post("/insert")
for (i <- 0 to 99) {
val paramsInArray = csvHeader.split(",")
for (param <- paramsInArray) {
if (param.equalsIgnoreCase("name")) {
httpReq = httpReq.formParam(("name" + "[" + i +"]").el[String] , "${name}")
}
if (param.equalsIgnoreCase("url")) {
httpReq = httpReq.formParam(("url" + "[" + i +"]").el[String] , "${url}")
}
if (!param.equalsIgnoreCase("name") && !param.equalsIgnoreCase("url")) {
val firstArg = param + "[" + i + "]"
val secondArg = "${" + param + "}"
httpReq = httpReq.formParam(firstArg, secondArg)
}
}
}
private val scn = scenario("test_scn") .feed(insertFeeder, 100) .exec(httpReq)
setUp( scn.inject( constantUsersPerSec(1) during (1200 seconds) ).protocols(httpConf) ).assertions(global.failedRequests.count.lte(5))
And the data in test_data.csv is:
name,url,price,size,gender
image_1,http://image_1_url,100,xl,male
image_2,http://image_2_url,90,m,female
image_3,http://image_3_url,10,s,female
...
image_2000,http://image_2000_url,200,xl,male
By the way, if I process only 1 line, it works well.
Read the document again, and fixed the issue. If feed multiple records all at once, the attribute names will be suffixed from 1.
https://gatling.io/docs/current/session/feeder/#csv-feeders

How can I add '€' in extjs?

All is in the question, is there a way to display the € symbol in extjs?
I tried
var euroMoney = function(v) {
v = (Math.round((v - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
v = String(v);
var ps = v.split('.'),
whole = ps[0],
sub = ps[1] ? ',' + ps[1] : ',00',
r = /(\d+)(\d{3})/;
while (r.test(whole)) {
whole = whole.replace(r, '$1' + '.' + '$2');
}
v = whole + sub;
return v + " €";
}
But for euroMoney(1) it returns me
1,00 €
This happens when your text editor saves it the wrong way. Make sure the encoding in your text editor is set to UTF-8 and you should be fine.

How to read msExchMailboxSecurityDescriptor attribute in C#

I am trying to read all the user attributes in AD.
How to read msExchMailboxSecurityDescriptor attribute in C# ?
I used the following code but I got a cast error. Any suggestions would be welcome.
DirectoryObjectSecurity oSec = new ActiveDirectorySecurity();
oSec.SetSecurityDescriptorBinaryForm((byte[])val);
String m_Value = oSec.GetSecurityDescriptorSddlForm(AccessControlSections.All);
return m_Value;
Ok. I was able to figure it out. The code is given below for anyone interested. I wish Microsoft had put out some code samples so that people do not have to break their heads.
SecurityDescriptor sd = (SecurityDescriptor) p_InputValue;
AccessControlList acl = (AccessControlList)sd.DiscretionaryAcl;
String m_Trustee = "";
String m_AccessMask = "";
String m_AceType = "";
String m_ReturnValue="";
foreach (AccessControlEntry ace in (IEnumerable)acl)
{
m_Trustee = m_Trustee + "," + ace.Trustee;
m_AccessMask = m_AccessMask + "," + ace.AccessMask.ToString();
m_AceType = m_AceType + "," +ace.AceType.ToString();
}
m_ReturnValue="Trustee: " + m_Trustee + " " + "AccessMask: " + m_AccessMask + "AceType: " + m_AceType;
return m_ReturnValue

XMPP implementation in silverlight authentication returns failure

I am trying to implement Xmpp protocol in silverlight and trying to connect to Facebook, here I am getting everything correct until <challenge .. > obtained from server.
I am using X Facebook platform authentication.
I have done this with following code:
byte[] ch = Convert.FromBase64String(message.challenge);
string challenge = System.Text.Encoding.UTF8.GetString(ch, 0, ch.Length);
string response = "";
long callId = DateTime.UtcNow.Ticks;
MD5 md = new MD5();
String signature1 = "api_key=203366556348506"
+ "call_id=" + callId
+ "method=auth.xmpp_login"
+ param[2]
+ "session_key=" + messageClient.SessionKey
+ "v=1.0"
+ messageClient.AppSecret;
md.Value = signature1;
response = "method=auth.xmpp_login&api_key=203366556348506&session_key=bc6d6e00462cc2bb73a824bd.4-100001565408667&call_id=" + callId + "&sig=c47d741cb8f18c4e78b990f48e2f63aa&v=1.0&" + param[2];
message.Request = "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(response)) + "</response>";
this.messageClient.SendMessageAsync(message);
But I am getting following message from server:
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
Please let me know where I am going wrong.
Try following code:
String signature1 = "api_key=" + messageClient.ApiKey
+ "call_id=" + callId
+ "method=auth.xmpp_login"
+ param[2]
+ "session_key=" + messageClient.SessionKey
+ "v=1.0"
+ messageClient.AppSecret;
md.Value = signature1;
response = "method=auth.xmpp_login&api_key=" + messageClient.ApiKey + "&session_key=" + messageClient.SessionKey + "&call_id=" + callId + "&sig=" + md.FingerPrint.ToLower() + "&v=1.0&" + param[2];
I have changed response string to the one above.
This has returned success for me. Hope this will help you.

Resources