How to add reference in Rmarkdown in R? - reference

I have tried to make auto-reference in my rmarkdown document, unfortunately, I couldn't figured out the proper way of inserting Reference. Here is my report in my [github][1] account, which I put as a links all my references.
I have already installed bibtex.
My Rmarkdown header is:
title: "Case Study - Bellabeat Fitness App Data Analysis in R"
author: "Mohamed Ibrahim Abdilaahi"
date: '`Sys.Date()`'
output:
html_html:
numer_sections: true
toc: true
bibliography: reference.bib
I have also created reference file saved as .bib
Here is my syntax error:
Error in eval(xfun::parse_only(name)) : object 'html_html' not found
Calls: <Anonymous> ... create_output_format -> create_output_format_function -> eval -> eval
Execution halted
I am in desperate need for your help, this will also help me my ongoing real projects.
[1]: https://github.com/Moheid/fitbit_repo

Related

How Do I resolve "Illuminate\Queue\InvalidPayloadException: Unable to JSON encode payload. Error code: 5"

Trying out the queue system for a better user upload experience with Laravel-Excel.
.env was been changed from 'sync' to 'database' and migrations run. All the necessary use statements are in place yet the error above persists.
The exact error happens here:
Illuminate\Queue\Queue.php:97
$payload = json_encode($this->createPayloadArray($job, $queue, $data));
if (JSON_ERROR_NONE !== json_last_error()) {
throw new InvalidPayloadException(
If I drop ShouldQueue, the file imports perfectly in-session (large file so long wait period for user.)
I've read many stackoverflow, github etc comments on this but I don't have the technical skills to deep-dive to fix my particular situation (most of them speak of UTF-8 but I don't if that's an issue here; I changed the excel save format to UTF-8 but it didn't fix it.)
Ps. Whilst running the migration, I got the error:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `jobs` add index `jobs_queue_index`(`queue`))
I bypassed by dropping the 'add index'; so my jobs table is not indexed on queue but I don't feel this is the cause.
One thing you can do when looking into json_encode() errors is use the json_last_error_msg() function, which will give you a bit more of a readable error message.
In your case you're getting a '5' back, which is the JSON_ERROR_UTF8 error code. The error message back for this is a slightly more informative one:
'Malformed UTF-8 characters, possibly incorrectly encoded'
So we know it's encountering non-UTF-8 characters, even though you're saving the file specifically with UTF-8 encoding. At first glance you might think you need to convert the encoding yourself in code (like this answer), but in this case, I don't think that'll help. For Laravel-Excel, this seems to be a limitation of trying to queue-read .xls files - from the Laravel-Excel docs:
You currently cannot queue xls imports. PhpSpreadsheet's Xls reader contains some non-utf8 characters, which makes it impossible to queue.
In this case you might be stuck with a slow, non-queueable option, or need to convert your spreadsheet into a queueable format e.g. .csv.
The key length error on running the migration is unrelated. It has been around for a while and is a side-effect of using an older version of MySQL/MariaDB. Check out this answer and the Laravel documentation around index lengths - you need to add this to your AppServiceProvider::boot() method:
Schema::defaultStringLength(191);

How to create source type image in python code?

I am trying to create the source type image from python script in obs. Want to know proper steps to create source in script. I already checked, no proper doc for python scripting available.
obs.obs_source_create('banner-image','xyz')
obs.obs_source_create('banner-image','xyz')
Logs
TypeError: obs_source_create() takes exactly 4 arguments (2 given)
I want to create source type image from scrip & add that source to my current scene
This may be a simple FFI implementation, so try:
obs.obs_source_create('banner-image', 'xyz', None, None)
Source: First hit on Google when searching for "obs_source_create":
https://obsproject.com/docs/reference-sources.html
Excerpt:
obs_source_t *obs_source_create(const char *id, const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
Creates a source of the specified type with the specified settings.
The “source” context is used for anything related to presenting or modifying video/audio. Use obs_source_release to release it.
Parameters:
id – The source type string identifier
name – The desired name of the source. If this is not unique, it will be made to be unique
settings – The settings for the source, or NULL if none
hotkey_data – Saved hotkey data for the source, or NULL if none
Returns:
A reference to the newly created source, or NULL if failed

Need Help Understanding Node JS Syntax Error

Can anyone please help me to understand the syntax error based on the attached screenshot below?
My script is supposed to access a given JSON and return the specific value, but somehow it's returning this error.
Edit 1
I tested my script with a dummy JSON and the script didn't return any error, so I suspect my original JSON might be giving problem. Here's my JSON.
{
"og_object": {
"id": "1192199560899293",
"description": "Hi everyone I have an important announcement to make. So ever since Penny started school, I've been having mixed feelings. \u00a0Besides having a bit of space to myself to breathe and rest my brain/legs, I'm actually a bit bittersweet cos my little baby, who used to sleep at weird hours and gobble puree",
"title": "Fighter and Penny's new sibling",
"type": "article",
"updated_time": "2017-04-12T01:17:57+0000"
},
"share": {
"comment_count": 0,
"share_count": 109
},
"id": "http://fourfeetnine.com/2017/03/05/fighter-and-pennys-new-sibling/"
}
Edit 2
Here's my script that I run that produces the error.
var objects = require('./output.txt');
console.log(objects);
output.txt is the file that contains the JSON that I pasted in Edit 1
var objects = require('./output.txt');
The require() function belongs to the module loading system. Despite the name, it can actually load several types of files and directories and not only Node modules. As per the high-level algorithm in pseudocode shown in docs:
require(X)
If X begins with './' or '/' or '../'
a. LOAD_AS_FILE(Y + X)
[...]
LOAD_AS_FILE(X)
If X is a file, load X as JavaScript text. STOP
If X.js is a file, load X.js as JavaScript text. STOP
If X.json is a file, parse X.json to a JavaScript Object. STOP
If X.node is a file, load X.node as binary addon. STOP
Since you get SyntaxError, output.txt does not contain valid JavaScript code.
If you really want to load JSON, you need to enforce subrule #3 by renaming the file to output.json.
Thanks to #Jordan suggestion. The fault is indeed due to wrong file extension. After changing the file extension from .txt to .json, then the syntax error disappeared.

How can I create a new syntax language definition for Sublime Text 3?

I would like to setup a new language definition for log files with a certain format. I've been scouring the interwebs for a tutorial that actually works, and I've yet to find one. I've tried creating sublime-syntax files, AAAPackageDev files (both JSON and YAML), plus one other syntax package that I can't remember the name of -- none of them seem to work, with some of them leaving out important details, like where to save files, how to get the syntax definition to appear as an option (I suspect this is related to save location), or how the keyword.other.joelog scope relates to the keyword.other theme color (do you just drop the last bit? does the last bit have to match the scope set out in the header?). It's been very frustrating.
At its simplest, I'd like to take the following file and highlight it:
2015-11-25 14:35:11 [LOG] Blah Blah Blah
2015-11-25 14:35:11 [LOG] some log statement
2015-11-25 14:35:11 [LOG] some other log statement
2015-11-25 14:35:11 [DEBUG] some embedded filename: [[ /path/to/file ]]
2015-11-25 14:35:11 [INFO] .............. blah blah ..............
2015-11-25 14:35:11 [DEBUG] <<PASS>> Directory not found: [[ /some/dir/name ]]
2015-11-25 14:35:11 [ERROR] <<FAIL>> Directory found: [[ /some/other/dir/name ]]
2015-11-25 14:35:11 [WARNING] some strange condition occurred
Ultimately I'd like syntax definitions similar to the following:
LOG lines should be "normal" text
DEBUG lines should be treated entirely as comments
ERROR lines should be treated as something else (e.g. a variable)
INFO lines as normal except the word INFO should be highlighted as something (e.g. a keyword)
WARNING similar to either ERROR or INFO
have embedded strings in the format of [[ some string ]] highlighted as a string, irrespective of the type of line it's on
have <<PASS>> and <<FAIL>> highlighted with different colors, irrespective of the type of line they're on
I'd be happy getting any of this to work when manually selecting the mode, and especially happy if I could have the mode selected based on the full filename (it would be selected based on a prefix, rather than just a suffix, e.g. joelog-20151126-110719.log keying off of both the 'joelog' prefix and the 'log' suffix).
Is this possible to do? I can write this in JSON, YAML, XML, Martian -- any language or style definition would be fine, if only I knew the rules.
Edit: Sorry, I meant to include the pages I've tried to follow:
http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html
http://www.sublimetext.com/docs/3/syntax.html
http://www.sublimetext.com/docs/3/packages.html
https://github.com/SublimeText/AAAPackageDev
https://github.com/SublimeText/AAAPackageDev/blob/master/Syntax%20Definitions/Sublime%20Text%20Syntax%20Def%20%28YAML%29.YAML-tmLanguage
https://packagecontrol.io/packages/SyntaxHighlightTools
With sublime-syntx files I couldn't figure out how to get it to show up as an option. With AAAPackageDev files, I could get my new syntax definition to show up, but it never highlighted anything, even when doing nothing more than following the tutorial (abandoning all of my own desires, just trying to get something to highlight in any fashion).
Thanks!
I started all over again and nothing worked...until I deleted all of my files and attempts, and then started yet again from scratch. Something in those files was preventing other definitions from being read in, maybe? No clue, but now it's working, finally.
The success I had was with PackageDev. Here's what I came up with (it's still in progress):
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: JoeLog
scopeName: source.joelog
fileTypes: [joe]
uuid: 0fb395f8-9fb7-41c2-8b56-51f971de8505
patterns:
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[DEBUG\] (<<PASS>>).*$
name: comment.joelog
captures:
'1': {name: constant.other.symbol.joelog}
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[DEBUG\] (<<FAIL>>).*$
name: variable.joelog
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[DEBUG\].*$
name: comment.joelog
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[ERROR\].*$
name: variable.joelog
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[LOG\].*$
name: support.class.joelog
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[INFO\].*$
name: support.function.joelog
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[WARNING\].*$
name: keyword.other.joelog
- match: \[WARNING\]
name: keyword.other.joelog
- match: ^\d+-\d+-\d+ \d+:\d+:\d+ \[FATAL\].*$
name: invalid.illegal.joelog
- begin: ^\d+-\d+-\d+ \d+:\d+:\d+ \[STACK TRACE\].*$
end: ^\s*$
name: invalid.illegal.joelog
...
I still don't know half of what I'm doing, but at least something is working. I'd like to be able to color in <<PASS>> and <<FAIL>> without having to duplicate the DEBUG definition, as those strings may appear on other lines, and I don't want to duplicate all of them, but I haven't figured out how to do that, yet (any pointers would be welcome).
Scopes were picked out because of the colors in use in my chosen theme, but that's probably a bad idea, and I should go with scopes that makes sense from a contextual standpoint. But I'll leave that for another day. The TmTheme Editor was a big help in seeing what scopes are defined in my theme and what the actual scope names were.
I used the ApplySyntax package (available via Package Control) to select this new syntax based on the full file name, not just the extension.
Here is a list of commonly used scopes that I compiled by re-engineering some color-themes and using your helpful link to the TmThemeEditor:
# Common generic scopes used in sublime-syntax / color-scheme
comment
comment.line
constant
constant.character
constant.character.escape
constant.language
constant.numeric
constant.other
constant.other.symbol
entity
entity.name.class
entity.name.filename
entity.name.function
entity.name.tag
entity.name.type.class
entity.other.attribute-name
entity.other.inherited-class
invalid
invalid.deprecated
keyword
keyword.control
keyword.control.import
keyword.operator
keyword.other
punctuation
punctuation.definition.string.begin
punctuation.definition.string.end
punctuation.definition.tag
punctuation.definition.tag.begin
punctuation.definition.tag.end
punctuation.definition.variable
storage
storage.modifier
storage.type
storage.type.class
storage.type.function
string
string.regexp
support
support.class
support.constant
support.function
support.other.variable
support.type
variable
variable.function
variable.language
variable.other
variable.parameter

How to skip Cucumber steps?

I have the scenario like:
Given I go to this page
When I type cucumber
And I click
Then I should see the text
And I should not see the line
If I run this scenario it will execute all the 5 steps. But I want to skip the 4th step (Then I should see the text) and execute the 5th step.
Please give me your suggestions. Thanks in advance. :)
TL;DR - don't do it - you're (probably) getting it wrong. And you can't (easily) do it. As Aslak wrote (one of Cucumber main creators):
A step can have the following results:
undefined (no matching stepdef)
pending (a matching stepdef that throws PendingException)
passed (a matching stepdef that doesn't throw anything)
failed (a matching stepdef that throws an exception that isn't PendingException)
skipped (a step following a step that threw any exception (undefined, pending or failed))
What you're asking for is a new kind of result - ignored. It could be
implemented by throwing an IgnoredException. This would mean that
skipped would have to be changed to: (a step following a step that
threw any exception (undefined, pending or failed) - unless the
exception was IgnoredException)
I'm not sure I like this. It sounds like more complicated than it
needs to be. You already have the necessary information that something
is amiss - your step will either fail or be pending. I don't see the
value in continuing to execute the following steps. You still have to
implement the failing/pending step.
As long as you're reminded that "there is work to be done here" I
don't think it's wortwhile complicating Cucumber to tell you what kind
of work needs to be done...
Aslak
Whole discussion is here: http://comments.gmane.org/gmane.comp.programming.tools.cucumber/10146
I have had to skip steps conditionally based on environments. I used next to skip steps. Here is an example on how to do what you wanted.
Then /^I should see the text/$ do
next if #environment == 'no text'
...
<The actual step definition>
...
end

Resources