Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hey guys i'm building a tweak for instagram i'm adding a sub preference called instatroll similar to trolltwitter to change the number of followers to any number the user sets (using PSEditTextCell) here is my code so far
#import <Foundation/Foundation.h>
static NSMutableDictionary *plist = [[NSMutableDictionary alloc] initWithContentsOfFile:#"/var/mobile/Library/Preferences/com.idevicelover.InstaEnhancer.plist"];
NSNumber *chosenNumber = [NSNumber numberWithInt:999];
int number = chosenNumber;
static BOOL followerson = NO;
%hook IGUser -(void)setFollowerCount:(NSNumber*)fp8{
followerson = [[plist objectForKey:#"followerson"]boolValue];
if(followerson){
%orig(number);
}
else{
%orig;
}
}
%end
%ctor
{
NSDictionary *InstaEnhancer = [[NSDictionary alloc] initWithContentsOfFile:#"/var /mobile /Library/Preferences/com.idevicelover.InstaEnhancer.plist"];
if ([InstaEnhancer objectForKey:#"numberoffollowers"]) number = [[InstaEnhancer objectForKey:#"numberoffollowers"] intValue];
[InstaEnhancer release];
}
i'm getting this error when compiling :"assigning to NSNumber * from incompatible type "int"
NSNumber is an object. In order to use it as a primitive data type such as an int, you have to pull that type of value out of it with the appropriate method:
NSNumber *chosenNumber = [NSNumber numberWithInt:999];
int number = [chosenNumber intValue];
Also, later on, here:
number = [[InstaEnhancer objectForKey:#"numberoffollowers"] intValue];
If at this point number is an int (I have no clue as this syntax isn't C++ or Objective-C) then this should be fine. But if number is of type NSNumber *, then you need to drop the call to intValue:
number = [InstaEnhancer objectForKey:#"numberoffollowers"];
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 10 months ago.
Improve this question
Have this code where i am trying to run a loop for few times to make sure i do get my result, but for some reason, i am still getting an error displayed on sreen and it is not even doing the cflog so i can know what is going on, any help will be appreciated
var aData = [];
for (i = 1; i <= 10; i++) {
try {
var a = {};
var as = calltoapitoogetdata;
a['count'] = as;
ArrayAppend(aData, mData);
var retJSON = serializeJSON(aData);
writedump(retJSON);
//return serializeJSON(aData);
break;
} catch (any e) {
i = i + 1;
cflog(text = "Call failed #i#", application = true, file = "loogevent");
writedump(i);
}
}
Thanks
If your code is still erroring it is most likely coming from the cflog call being made in your cfcatch. If you are running a version of Adobe ColdFusion the script version would be :
WriteLog(type="Error", file="myapp.log", text="[#ex.type#] #ex.message#");
https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-t-z/writelog.html
Lucee has made many of the CFScript functions equivalent of their tag names but with Adobe CF there are a number of functions that do not comply with this. <cfdump> -> writeDump for example.
Too long for a comment.
I think troubleshooting is easier if all available information is right in front of you on the screen. So, I would troubleshoot like this. Your code is below with my additions in uppercase:
var aData = [];
for (i = 1; i <= 10; i++) {
try {
WRITEOUTPUT('TRY NUMBER #I# <BR>);
var a = {};
var as = calltoapitoogetdata;
WRITEDUMP(AS);
a['count'] = as;
ArrayAppend(aData, mData);
var retJSON = serializeJSON(aData);
writedump(retJSON);
//return serializeJSON(aData);
break;
} catch (any e) {
i = i + 1; // THIS LINE IS NOT NECESSARY
WRITEOUTPUT('CATCH NUMBER #I# <BR>);
cflog(text = "Call failed #i#", application = true, file = "loogevent"); //THIS LINE GETS REPLACED BY
WRITEDUMP(E);
writedump(i); // THIS LINE GOES AWAY
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I need to select every inline code blocks (not multilane)
Here is text https://regex101.com/r/8e7nPL/7
Example of inline blocks that I need to extract: f.call();, yield(), Fiber
this could help you:
function test(text) {
var re = /`([^`\n]+)`/g;
let match;
while(match = re.exec(text)) {
console.log('match', match);
}
}
test(
`
Пример создания файбера и передача ему в качестве аргумента вызываемой функции:
\`\`\`
auto f = new Fiber(&foo);
\`\`\`
\`f.call();\` вызов файбера
\`Fiber.yield();\` метод \`yield()\` класса \`Fiber\` вызывающий преостановку выполнение текущей функции
Пример:
\`\`\`
import std.stdio;
import core.thread;
void main()
{
auto f = new Fiber(&foo);
f.call(); // Prints Hello
f.call(); // Prints World
}
void foo()
{
writeln("Hello");
Fiber.yield();
writeln("World");
}
\`\`\`
Результат:
\`\`\`
> app.exe
Hello
World\`
`
)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Is it possible to use an operator || in json like this :
{
"ven":{
"source":"logicCtrl" ,
"msg":"radio_volume" || "radio-mute", || "radio3",
"type":"int"
}
}
i can after get data by parsing data in C++ side like this :
QFile jsonFile("VenParser.json");
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "problème d'overture du fichier, exit";
}
QByteArray jsonData = jsonFile.readAll();
QJsonParseError *err = new QJsonParseError();
QJsonDocument doc = QJsonDocument::fromJson(jsonData, err);
if (err->error != 0)
qDebug() << err->errorString();
Venparser myparser;
if (doc.isNull())
{
qDebug() << "Document invalide";
}
else if (doc.isObject())
{
//recuperer l'object json
QJsonObject jObject = doc.object();
//convertir l'object json to variantmap
QVariantMap mainMap = jObject.toVariantMap();
// variant map
QVariantMap Map = mainMap["ven"].toMap();
myparser.source = Map["source"].toString();
myparser.msg = Map["msg"].toString();
myparser.type = Map["type"].toString();
header.H file : i define my struct
struct Venparser {
QString source;
QString msg;
QString type;
My problem is that i don't want a list in my "msg" but something like this :
when i call myparser.msg , then it will check just the value i need in msg and return it.
"msg":"radio_volume" || "radio-mute", || "radio3",
Thanks,
Your example with the || token is not a valid JSON. You can read more about its format here. However, if I understand you correctly, you can easily use JSON arrays for your task.
JSON:
{
"ven": {
"source": "logicCtrl",
"msg": ["radio_volume", "radio-mute", "radio3"],
"type": "int"
}
}
C++:
You can access the msg array using the toStringList() method. Also, you can use QVariantList and toList() respectively if you fill your array with data different from strings.
QStringList messages = Map["msg"].toStringList();
Now the messages variable contains "radio_volume", "radio-mute" and "radio3" values so you can extract the required string any way you need using your code.
If you still need to parse your exact example (which is technically not a valid JSON as I said before), you will have to go with writing your own parser, which is a bit wide topic for the answer.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Currently I have a config file of the following form:
under Time {
TimeStep = 0.001;
MaxTime = 0.2;
MaxIts = 400;
Type = Implicit;
under Implicit {
Type = ForwardEuler;
Jacobian = FiniteDifference;
under Newton {
MaxIts = 20;
Eps = 0.01;
}
}
}
First Question: I want to write a set of bash scripts that can
set property = value in a file; add it if it is not there.
get property from such a file.
line-by-line editting is not suitable here: take MaxIts for example, the script needs to distinguish between Time.MaxIts and Time.Implicit.MaxIts.
Second Question: I want to write a bash script that transforms above into:
Time.TimeStep = 0.001;
Time.MaxTime = 0.2;
Time.MaxIts = 400;
Time.Type = Implicit;
Time.Implicit.Type = ForwardEuler;
Time.Implicit.Jacobian = FiniteDifference;
Time.Implicit.Newton.MaxIts = 20;
Time.Implicit.Newton.Eps = 0.01;
so that sed or awk can do the job simply.
Here's how to do the 2nd part:
$ cat tst.awk
function descend(name) {
while ( (getline > 0) && !/}/ ) {
if ( /{/ ) {
descend(name "." $2)
}
else {
sub(/^[[:space:]]+/,"")
print name "." $0
}
}
}
{ descend($2) }
$ awk -f tst.awk file
Time.TimeStep = 0.001;
Time.MaxTime = 0.2;
Time.MaxIts = 400;
Time.Type = Implicit;
Time.Implicit.Type = ForwardEuler;
Time.Implicit.Jacobian = FiniteDifference;
Time.Implicit.Newton.MaxIts = 20;
Time.Implicit.Newton.Eps = 0.01;
I'm sure you can write a script to do the reverse mapping and then you can just do all the manipulation related to your first question on the flat format above.
I'm new to grails 1.3.7 and I try to access my database and to show my data on a gsp. Now Ive got the following problem: I've got a list of questions (listofQuestions) and a list of answers (listofAnswers). To each question belongs one Lpicanswer object which contains various answers (answera, answerb)
So when I create those lists, in the end I've got one list containing the questions and one list containing lpicanswer-objects. each lpicanswerobject has an lpicid (which is the id of the question), so that they are related to each other.
Here is the code to create those lists:
List listofQuestions = []
List listofAnswers = []
def ques
def question
def ans
// we create a questions list containing questions
// we create a answers list containing answers-objects for a question
for (int i = 0; i <= cacheService.questionList.size()-1; i++) {
ques = Lpicquestions.get(cacheService.questionList[i]);
question = ques.question;
listofQuestions.add(question);
}
for (int i = 0; i <= cacheService.questionList.size(); i++) {
ans = Lpicanswers.get(cacheService.questionList[i]);
listofAnswers.add(ans);
}
return new ModelAndView("/result/resultdetail", [ qlist : listofQuestions, alist : listofAnswers ]);}
now I want to show them on my gsp. here is what I do:
<g:each in="${qlist}">
<b>${it}</b><br/>
${alist.answera}<br/>
${alist.answerb}<br/>
${alist.answerc}<br/>
${alist.answerd}<br/>
${alist.answere}<br/>
${alist.answerf}<br/>
${alist.answerg}<br/>
${alist.answerh}<br/>
</g:each>
what happens is, that the questions are given out correct, but the answers of course not. For each question all answersa, all answersb, etc are shown (like: [answera-from-question1, answera-from-question2] and so on) how can I solve this?
any help will be apreciated! :-)
[EDIT] Here is the structure of lpicquestions and lpicanswers, thanks for helping!! :-)
package com.lpic
class Lpicquestions {
int lpicchapter
String question
static constraints = {
question(nullable:false, blank:false, maxSize:1000)
lpicchapter(nullable:false, blank:false)
}
}
package com.lpic
class Lpicanswers {
Lpicquestions lpicid
String answera
String answerb
String answerc
String answerd
String answere
String answerf
String answerg
String answerh
static constraints = {
}
}
aList is not an object or map. So you can't put something like:
${alist.answera}
change the view to.
<g:each var="question" in="${qlist}">
<b>${question}</b><br/>
<g:each var="answer" in="${aList}">
<g:if test="${answer.lpicid?.question == question}">
<b>${answer.answera}</b><br/>
<b>${answer.answerb}</b><br/>
<b>${answer.answerc}</b><br/>
<b>${answer.answerd}</b><br/>
<b>${answer.answere}</b><br/>
<b>${answer.answerf}</b><br/>
<b>${answer.answerg}</b><br/>
<b>${answer.answerh}</b><br/>
</g:if>
</g:each>
</g:each>
if assuming that cacheService.questionList contains list of id for Lpicquestions
change
for (int i = 0; i <= cacheService.questionList.size(); i++) {
//ans = Lpicanswers.get(cacheService.questionList[i]);
ans = Lpicanswers.findWhere(['lpicid' : Lpicquestions.get(cacheService.questionList[i])]);
listofAnswers.add(ans);
}