I was running my c program in vs code and got this error - dynamic-language-runtime

Problem
[{
"resource": "/e:/C/pd.c",
"owner": "cpptools",
"severity": 8,
"message": "expected '=', ',', ';', 'asm' or 'attribute' before '{' token",
"source": "gcc",
"startLineNumber": 2,
"startColumn": 9,
"endLineNumber": 2,
"endColumn": 9
}]
Original Code
#include<stdio.h>
int main(int argc, char const *argv[])
{ int x, y;
printf("Enter Your No.1\n");
printf("Enter Your No.2\n");
return 0;
}

Related

Generate custom ores in custom dimension

I have recently created a custom dimension using data packs in Minecraft 1.16.5.
This dimension is a part of a mod that I am writing and I am currently trying to generate custom ores in that dimension; However, I was not able to generate ores in a custom dimension the same way that I generate ores in the Overworld or Nether. As I mentioned the dimension is handled via data packs (.json files) but the biomes are handled in game code (.java). I am very new to Java & modding, any suggestions would be appreciated.
Thanks in advance.
Minecraft version : 1.16.5
Forge version : 36.2.9
The current code for Overworld & Nether ore gen :
public class OreGeneration
{
public static void generateOres(final BiomeLoadingEvent event)
{
// Gigalium :
if(!(event.getCategory().equals(Biome.Category.THEEND)))
{
// Nether :
if(event.getCategory().equals(Biome.Category.NETHER))
{
generateOre(event.getGeneration(), OreFeatureConfig.FillerBlockType.NETHERRACK, BlockInit.GIGALIUM_NETHER_ORE.get().defaultBlockState(), 6, 25, 50, 2);
generateOre(event.getGeneration(), OreFeatureConfig.FillerBlockType.NETHERRACK, BlockInit.GIGALIUM_NETHER_ORE.get().defaultBlockState(), 4, 51, 120, 2);
}
// Overworld :
if(event.getCategory().equals(Biome.Category.SWAMP) || event.getCategory().equals(Biome.Category.TAIGA))
{
generateOre(event.getGeneration(), OreFeatureConfig.FillerBlockType.NATURAL_STONE, BlockInit.GIGALIUM_ORE.get().defaultBlockState(), 5, 12, 15, 2);
generateOre(event.getGeneration(), OreFeatureConfig.FillerBlockType.NATURAL_STONE, BlockInit.GIGALIUM_ORE.get().defaultBlockState(), 4, 16, 20, 2);
}
if(!(event.getCategory().equals(Biome.Category.SWAMP) && event.getCategory().equals(Biome.Category.TAIGA)))
{
generateOre(event.getGeneration(), OreFeatureConfig.FillerBlockType.NATURAL_STONE, BlockInit.GIGALIUM_ORE.get().defaultBlockState(), 4, 10, 13, 1);
generateOre(event.getGeneration(), OreFeatureConfig.FillerBlockType.NATURAL_STONE, BlockInit.GIGALIUM_ORE.get().defaultBlockState(), 3, 14, 18, 1);
}
}
}
private static void generateOre(BiomeGenerationSettingsBuilder settings, RuleTest fillerType, BlockState state, int veinSize, int minHeight, int maxHeight, int amount)
{
settings.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.configured(new OreFeatureConfig(fillerType, state, veinSize)).decorated(Placement.RANGE.configured(new TopSolidRangeConfig(minHeight, 0, maxHeight))).squared().count(amount));
}
}
Dimension code :
{
"type": "gigawhat_gigamod:gigaland",
"generator": {
"type": "minecraft:noise",
"seed": 0,
"settings": {
"bedrock_roof_position": -10,
"bedrock_floor_position": 0,
"sea_level": 80,
"disable_mob_generation": true,
"default_block": {
"Name": "gigawhat_gigamod:gigastone"
},
"default_fluid": {
"Name": "minecraft:water",
"Properties": {
"level": "0"
}
},
"noise": {
"height": 256,
"density_factor": 1,
"density_offset": -0.46875,
"size_horizontal": 1,
"size_vertical": 2,
"simplex_surface_noise": true,
"random_density_offset": true,
"amplified": true,
"sampling": {
"xz_scale": 1,
"y_scale": 1,
"xz_factor": 80,
"y_factor": 160
},
"bottom_slide": {
"target": -30,
"size": 0,
"offset": 0
},
"top_slide": {
"target": -10,
"size": 3,
"offset": 0
}
},
"structures": {
"structures": {}
}
},
"biome_source": {
"type": "minecraft:fixed",
"biome": "gigawhat_gigamod:gigaland_main_biome"
}
}
}
Biome Init code :
public class ModBiomes
{
public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, Gigamod.MOD_ID);
public static final RegistryObject<Biome> GIGALAND_MAIN_BIOME = BIOMES.register("gigaland_main_biome", () -> makeGigalandMainBiome(() -> ModConfiguredSurfaceBuilders.GIGALAND_SURFACE, 0.205f, 0.02f));
private static Biome makeGigalandMainBiome(final Supplier<ConfiguredSurfaceBuilder<?>> surfaceBuilder, float depth, float scale)
{
MobSpawnInfo.Builder mobspawninfo$builder = new MobSpawnInfo.Builder();
BiomeGenerationSettings.Builder biomegenerationsettings$builder = (new BiomeGenerationSettings.Builder()).surfaceBuilder(surfaceBuilder);
DefaultBiomeFeatures.addDefaultOverworldLandStructures(biomegenerationsettings$builder);
biomegenerationsettings$builder.addStructureStart(StructureFeatures.MINESHAFT);
DefaultBiomeFeatures.addDefaultCarvers(biomegenerationsettings$builder);
DefaultBiomeFeatures.addDefaultUndergroundVariety(biomegenerationsettings$builder);
mobspawninfo$builder.addSpawn(EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.BLAZE, 100, 10, 15));
return (new Biome.Builder()).precipitation(RainType.RAIN).biomeCategory(Category.EXTREME_HILLS).depth(depth).scale(scale).temperature(1.5F).downfall(0.9F).specialEffects((new BiomeAmbience.Builder()).waterColor(65518).waterFogColor(16763760).fogColor(16763760).skyColor(16763760).foliageColorOverride(9547008).grassColorOverride(9547008).ambientParticle(new ParticleEffectAmbience(ParticleTypes.LAVA, 0.003f)).skyColor(16763760).ambientLoopSound(SoundEvents.AMBIENT_CRIMSON_FOREST_LOOP).ambientMoodSound(new MoodSoundAmbience(SoundEvents.AMBIENT_WARPED_FOREST_MOOD, 6000, 8, 2.0D)).ambientAdditionsSound(new SoundAdditionsAmbience(SoundEvents.AMBIENT_NETHER_WASTES_MOOD, 0.0111D)).build()).mobSpawnSettings(mobspawninfo$builder.build()).generationSettings(biomegenerationsettings$builder.build()).build();
}
public static void register(IEventBus eventBus)
{
BIOMES.register(eventBus);
}
}
Answering my own question.
Instead of using event.getCategory().equals(SomeBiomeCategory) in the if statement in the OreGen class you should use event.getName().equals(YourModBiomeInit.BiomeName.getId(). Because event.getCategory().equals(SomeBiomeCategory) gets the category of the biome currently generating whilst event.getName().equals(YourModBiomeInit.BiomeName.getId() gets the registered name (or id).
So the if statement would look something like this :
if(event.getName().equals(YourModBiomeInit.SOME_BIOME.getId()))
{
// Generate ores ...
}

How to support vue template parse with recast?

I need to print the vue source code non-destructively after modifying the vue template ast.
The intent of the recast meets my needs, The react project has been completed, but I can’t see the way forward in the vue project.
const parser = require("#vue/compiler-sfc")
const ast = recast.parse(content, {
parser: parser
});
const output = recast.print(ast)
or
const parser = require("#vue/compiler-sfc")
const result = parser.parse(content)
const { template, script, styles } = result.descriptor
// template.ast.loc.source is vue <tamplate> code
const ast = recast.parse(template.ast.loc.source, {
parser: parser
});
const output = recast.print(ast)
got the same error:
node_modules\esprima\dist\esprima.js:5008
throw error;
^
Error: Line 1: Invalid regular expression: missing /
at ErrorHandler.constructError (node_modules\esprima\dist\esprima.js:5012:22)
at ErrorHandler.createError (node_modules\esprima\dist\esprima.js:5028:27)
at ErrorHandler.throwError (node_modules\esprima\dist\esprima.js:5035:21)
at Scanner.throwUnexpectedToken (node_modules\esprima\dist\esprima.js:5164:35)
at Scanner.scanRegExpBody (node_modules\esprima\dist\esprima.js:6157:19)
at Scanner.scanRegExp (node_modules\esprima\dist\esprima.js:6204:29)
at Tokenizer.getNextToken (node_modules\esprima\dist\esprima.js:6675:56)
at Object.tokenize (node_modules\esprima\dist\esprima.js:154:36)
at Object.parse (node_modules\recast\lib\parser.js:40:30)
at compiler (compiler.js:32:27) {
index: 14,
lineNumber: 1,
description: 'Invalid regular expression: missing /'
}
template.ast looks like:
{
"type": 1,
"ns": 0,
"tag": "template",
"tagType": 0,
"props": [],
"isSelfClosing": false,
"children": [
{
"type": 2,
"content": " ",
"loc": {
"start": { "column": 11, "line": 1, "offset": 10 },
"end": { "column": 3, "line": 2, "offset": 13 },
"source": "\n "
}
},
...

How to preload using where not filtering data

how to work with gorm with preload and filtering i have stuck for some time, maybe can help me
type JualmstModel struct {
Trnjualmstoid int `json:"jualid"`
Trnno string `json:"jualno"`
JualdtlModel []JualdtlModel `gorm:"foreignkey:Trnjualmstoid;association_foreignkey:Trnjualmstoid"`
}
type JualdtlModel struct {
Trnjualdtloid int `json:"jualdtlid"`
Trnjualmstoid int `json:"jualid"`
Item ItemModel `gorm:"foreignkey:itemoid;association_foreignkey:itemoid"`
Itemoid int `json:"Itemoid"`
}
type ItemModel struct {
Itemoid string `json:"itemid"`
Itemdesc string `json:"itemdesc"`
}
here is the model
DB.Find(b).
Preload("JualdtlModel.Item", "itemdesc like ?", "%"+menu+"%").
Find(b)
here the result
"jualid": 1,
"jualno": "INV/201902/0001",
"JualdtlModel": [
{
"jualdtlid": 1,
"jualid": 1,
"Item": {
"itemid": "22",
"itemdesc": "+ KEJU"
},
"Itemoid": 22
},
{
"jualdtlid": 2,
"jualid": 1,
"Item": {
"itemid": "",
"itemdesc": ""
},
"Itemoid": 87
},
i want to filter the item with some menu item, but when i add filter item it not filter all of my query
here debug result
SELECT * FROM [trnJualMst]
SELECT * FROM [trnJualDtl] WHERE ([trnjualmstoid] IN (1,2,3))
SELECT * FROM [mstItem] WHERE ([itemoid] IN (87,85,18,12,75,22,19,37,44,36,28,29,92,54,34)) AND (itemdesc like '%keju%')
What can I do so I can only load item that in filter?

Why are items apparently duplicated in my mongoDB database when I use find()?

I am going through the try.mongodb.org tutorial on their website (embedded terminal emulator on the webpage). I am on items t4 and t5 (you type tx for items in the tutorial).
In t4 we populate a database.
> t4. Saving and Querying
> Try adding some documents to the scores collection:
> for(i=0; i<10; i++) { db.scores.save({a: i, exam: 5}) };
>
> Try that, then enter
> db.scores.find();
> to see if the save succeeded. Since the shell only displays 10 results at time,
> you'll need to enter the 'it' command to iterate over the rest.
>
> (enter 'next' when you're ready)
I made exam 5 + i just for fun:
for(i=0; i<10; i++) { db.scores.save({a: i, exam: 5+i}) };
So what is in the database? I type in db.scores.find(); and get the following, which is what I had expected, although the order seems random. Fine.
>
[
{ "exam" : 14, "a" : 9, "_id" : { "$oid" : "52b1d16bcc937439340649c4" } },
{ "exam" : 5, "a" : 0, "_id" : { "$oid" : "52b1d191cc937439340649c5" } },
{ "exam" : 6, "a" : 1, "_id" : { "$oid" : "52b1d191cc937439340649c6" } },
{ "exam" : 7, "a" : 2, "_id" : { "$oid" : "52b1d191cc937439340649c7" } },
{ "exam" : 8, "a" : 3, "_id" : { "$oid" : "52b1d191cc937439340649c8" } },
{ "exam" : 10, "a" : 5, "_id" : { "$oid" : "52b1d191cc937439340649c9" } },
{ "exam" : 9, "a" : 4, "_id" : { "$oid" : "52b1d191cc937439340649ca" } },
{ "exam" : 11, "a" : 6, "_id" : { "$oid" : "52b1d191cc937439340649cb" } },
{ "exam" : 12, "a" : 7, "_id" : { "$oid" : "52b1d191cc937439340649cc" } },
{ "exam" : 13, "a" : 8, "_id" : { "$oid" : "52b1d191cc937439340649cd" } }
]
In t5 we search for items in that database:
>
5. Basic Queries You've already tried a few queries, but let's make them more specific. How about finding all documents where a == 2:
db.scores.find({a: 2});
Or what about documents where a > 15? db.scores.find({a: {'$gt': 15}});
The a== 2 search worked, but the > 15 one did not. First of all, based on item t4, there should be no entry for a greater than 15.
So I try greater than 6: db.scores.find({a: {'$gt': 6}});
And I get the following output, which is really surprising to me since there should only be 3 entries for a == 7, a == 8, and a == 9.
>
[
{ "exam" : 14, "a" : 9, "_id" : { "$oid" : "52b1d16bcc937439340649c4" } },
{ "exam" : 12, "a" : 7, "_id" : { "$oid" : "52b1d191cc937439340649cc" } },
{ "exam" : 13, "a" : 8, "_id" : { "$oid" : "52b1d191cc937439340649cd" } },
{ "exam" : 14, "a" : 9, "_id" : { "$oid" : "52b1d191cc937439340649ce" } },
{ "exam" : 12, "a" : 7, "_id" : { "$oid" : "52b1d1a8cc937439340649d6" } },
{ "exam" : 13, "a" : 8, "_id" : { "$oid" : "52b1d1a8cc937439340649d7" } },
{ "exam" : 14, "a" : 9, "_id" : { "$oid" : "52b1d1a8cc937439340649d8" } },
{ "exam" : 5, "a" : 7, "_id" : { "$oid" : "52b1d49fcc937439340649f1" } },
{ "exam" : 5, "a" : 9, "_id" : { "$oid" : "52b1d49fcc937439340649f3" } },
{ "exam" : 5, "a" : 8, "_id" : { "$oid" : "52b1d49fcc937439340649f4" } }
]
If you look at the initially outputted db.scores.find() id's on the right, the last character goes up with each entry -- 4, 5, 6, 7, 8, 9, a, b, c, d. But in the duplicated entries, take a look at the entries for a == 9. We have one ending in 4, one ending in e, and one ending in 3. It seems like in the brains of the operation the database has 30 entries, not 10.
{ "exam" : 14, "a" : 9, "_id" : { "$oid" : "52b1d16bcc937439340649c4" } },
{ "exam" : 14, "a" : 9, "_id" : { "$oid" : "52b1d191cc937439340649ce" } },
{ "exam" : 5, "a" : 9, "_id" : { "$oid" : "52b1d49fcc937439340649f3" } },
I noticed is that if I try to repopulate the database using the loop in t4 it doesn't seem to re-write the values. i.e. if I use for(i=0; i<10; i++) { db.scores.save({a: i, exam: 5}) }; as the example had suggested instead of my just for fun for(i=0; i<10; i++) { db.scores.save({a: i, exam: 5+i}) };. Not sure if that is helpful to diagnose the problem but it is another observation.
You're missing something very special,
I noticed is that if I try to repopulate the database using the loop
in t4 it doesn't seem to re-write the values. i.e. if I use for(i=0;
i<10; i++) { db.scores.save({a: i, exam: 5}) }; as the example had
suggested instead of my just for fun for(i=0; i<10; i++) {
db.scores.save({a: i, exam: 5+i}) };. Not sure if that is helpful to
diagnose the problem but it is another observation.
Repopulate the database running the query more than once will create 10 rows every single time. db.scores.save doesn't know what document to update because you didn't refer to an _id field, in that case it will always create 10 records. To update existing records you should provide an _id field from the previous inserts. I'm sure you run it more than once and you expect to have always 10 records, what's happening is you're inserting 10 records every time.
Try it removing the collection, run the loop once and execute your find, it will work.
Are you sure you didn't run the commands more than once? What do you see if you run db.scores.find().count(), that will tell you how many items are in the table.

Multidimensional array looping

I am working with steam api to loop through items in my backpack. Here is part of what I am returned.
{
"result": {
"status": 1,
"num_backpack_slots": 900,
"items": [
{
"id": 1828738510,
"original_id": 1828738510,
"defindex": 166,
"level": 5,
"quality": 6,
"inventory": 2147484295,
"quantity": 1,
"origin": 0,
"flag_cannot_trade": true,
"attributes": [
{
"defindex": 143,
"value": 1373392596,
"float_value": 118276915200.000000
},
{
"defindex": 292,
"value": 1115684864,
"float_value": 64.000000
},
{
"defindex": 388,
"value": 1115684864,
"float_value": 64.000000
},
{
"defindex": 153,
"value": 1065353216,
"float_value": 1.000000
}
]
},
{
"id": 1828947755,
"original_id": 1178542060,
"defindex": 5009,
"level": 1,
"quality": 6,
"inventory": 2147484021,
"quantity": 1,
"origin": 4
},
{
"id": 1828947766,
"original_id": 1179066746,
"defindex": 5005,
"level": 1,
"quality": 6,
"inventory": 2147483798,
"quantity": 1,
"origin": 4
},
{
"id": 1828947780,
"original_id": 1181421843,
"defindex": 5009,
"level": 1,
"quality": 6,
"inventory": 2147484020,
"quantity": 1,
"origin": 4
},
And so on.
What I would like to do is loop through this for my defindex using foreach(or something else that works). Here is my current code:
<?php
$api = "http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/? key=MyApiKey&steamid=MySteamId&format=json";
$json = (file_get_contents($api));
$schema = json_decode($json);
$total_metal = 0;
if ($schema-> result -> items[0] -> defindex == 5000)
{
$total_metal++;
}
if ($schema-> result -> items[0] -> defindex == 5001)
{
$total_metal+= 3;
}
if ($schema-> result -> items[0] -> defindex == 5002)
{
$total_metal+= 9;
}
print $total_metal;
?>
So far this returns 0 since the first variable is not any of these defindexes in this first one. What I need to do is have these 3 instances go through the whole array. From what I see I need to write a for each inside a for each but looking around I was not able to find anything that would help me. Thanks in advance.
You will need to loop through each item in your $schema. You can do this with a foreach loop.
foreach ($schema as $item)
In this loop, you will check the $item->defindex value against the three values you care about (5000, 5001, 5002).
$metal_array = array(5000, 5001, 5002);
If it matches one of these values, then you will perform the appropriate math.
if (in_array($metal_array, $item->defindex)
{
switch ($item->defindex)
{
case 5000:
$total_metal++; // or $total_metal += 1;
break;
case 5001:
$total_metal += 3;
break;
case 5002:
$total_metal += 9;
break;
}
}
This entire if block is in your foreach loop. At the end of the loop, $total_metal should contain the amount of metal in your backpack.
well if foreach doesn't work what about
for($i = 0; $i < ($schema-> result-> items.length; i++){
if ($schema-> result -> items[i] -> defindex == 5000)
{
$total_metal++;
}
if ($schema-> result -> items[i] -> defindex == 5001)
{
$total_metal+= 3;
}
if ($schema-> result -> items[i] -> defindex == 5002)
{
$total_metal+= 9;
}
}
if that doesn't work (because you can't access length for some reason) you can also do this:
$i = 0;
while($schema -> result -> items[i]){
//do stuff
$i++;
}