Fist time using Hugo and I'm trying to create a Nav Bar. Does anyone have the answer as to why this wouldn't be working? - syntax

This is my first time using Hugo. I am following a video tutorial. A few things are going on here:
I am unsure why my code isn't colored like the guys in the video.
There is no auto syntax going on whatsoever.
baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = "PaperMod"
menu:
main:
- identifier: Breakfast
name: Breakfast
url: /Breakfast/
weight: 10
This is all in my config.toml file.

Related

Error retrieving image from URL with SpreadsheetApp.newCellImage() builder

My application is trying to insert images to google drive sheet using google app script.
It works fine...
but it hang up intermittently with the response error from google script:
Exception: Error retrieving image from URL or bad URL:
https://drive.google.com/uc?id=1uvjg9_ZZg2sI5RYbPMEn6xXJhhnwuFyq&export=download.
The code is :
var fpm_mon_image = file_from_folder(id_folder_images , image_AR ) ; // get "image_AR" from folder
var url_mon_image = fpm_mon_image.getDownloadUrl() ;
var image = SpreadsheetApp.newCellImage().setSourceUrl(url_mon_image).setAltTextTitle(titre).toBuilder().build() ;
Utilities.sleep(1000); // for testing ...
SpreadsheetApp.flush();
Utilities.sleep(1000);
var rangeIma= fpm_sp.getRange(scal_li_SP +1, 2) ;
rangeIma.setValue(image).setVerticalAlignment('bottom') ; // stop here with error above
It works fine 5, 10 times then it hang up 2, 3, 5 times and then works fine again.... (I start loosing my hairs ;-))
I tried :
var srcfile = DriveApp.getFileById(id_mon_image);
srcfile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var image = fpm_sp.insertImage(srcfile.getBlob(), my_col , my_row);
but the image in not inserted in a cell...
Could you help please ?
Many thanks.
Unfortunately, I cannot replicate your situation of Exception: Error retrieving image from URL or bad URL:. So, although I'm not sure about your actual situation, how about the following modification?
Modified script:
Before you use this script, please enable Drive API at Advanced Google services.
var fileId = "###"; // Please set the file ID of your image.
var url = Drive.Files.get(fileId).thumbnailLink.replace(/\=s.+/, "=s512");
var title = "sample title";
var image = SpreadsheetApp.newCellImage().setSourceUrl(url).setAltTextTitle(title).build();
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange("A1").setValue(image);
When this script is run, a thumbnail link is retrieved from the image file using Drive API. And, the image size of the image is changed. And, the image is put to the cell "A1" of the active sheet.
In this case, if the issue of image size occurs, this issue can be removed. And, if the issue of sharing the file occurs, this issue can be also removed. By this, I thought that your issue might be able to be removed.

Can't get CoreSpotlight to work properly on the Mac... sample code anyone?

Can someone point me to some sample code for using CoreSpotlight on the Mac? I can’t find a single sample code example (for mac, plenty of iOS ones out there). I have already successfully implemented CS on our iOS app.
Using code similar to what I used for iOS, I’m getting it to index the content, but it’s very minimal: it gives me the generic app icon for the content (rather than the custom thumbnail image I specify) and has no description, etc (on the Spotlight pane, the entire right side is blank).
Also, it's unclear to me what code I need to add to AppDelegate to handle the click on the spotlight data. I used `func application(_ application: NSApplication, continue userActivity: NSUserActivity, restorationHandler:) on iOS but this doesn't seem to get called on the Mac.
Here's the code I'm using to index the content:
attributeSet.title = content.name
attributeSet.contentDescription = content.description
if let image = image {
let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil)!
let bitmapRep = NSBitmapImageRep(cgImage: cgImage)
attributeSet.thumbnailData = bitmapRep.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:])!
}
let item = CSSearchableItem(uniqueIdentifier:content.uuid, domainIdentifier: "com.my.app.bundle.id", attributeSet: attributeSet)
searchableIndex?.indexSearchableItems([item]) { error in
if let error = error {
NSLog("CoreSpotlight Indexing error: \(error.localizedDescription)")
}
}
And this is an example of what I get in Spotlight:
A bit of sample code would clear this right up, Methinks.
Thanks in advance.

Change An Image On A Website Using Tampermonkey

I want to change an image on a website, so that every time I visit, it shows the image that I want it to show and not the one that it normally shows.
Does anyone have the Tampermonkey code to do this?
Just change the src attribute. For example, say your image has the id "blah":
document.getElementById("blah").src = "http://......"
If you're not just searching by id, you could use something like document.querySelector(.....) instead.
Then put this inside a TamperMonkey script and make sure your code is firing on the correct websites (the #match part of the UserScript section in your script).
The following example is a tampermonkey script that runs on all websites. The script searches for an image of a cat and replaces it with an image of a dog. This script uses jQuery to select the image and modify its value.
// ==UserScript==
// #name Image Replacer
// #version 1.1
// #description Image Replacer
// #require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// #match https://www.pinterest.com/pin/*
// #grant none
// ==/UserScript==
/*globals $*/
var old_url = "https://i.pinimg.com/564x/21/64/6a/21646ad49e3860218f44b456153c7594.jpg"
var new_url = "https://i.pinimg.com/564x/59/9b/bb/599bbb49d7a3bb5546ff4017e9eb76ce.jpg"
$(document).ready(function(){
alert("Hi There!");
$("img[src='"+old_url+"']").attr("src", new_url);
alert("Replaced pictures successfully");
});
You can run this script on this Pinterest Website.

Vaadin Image in a Grid not showing

I'm trying to display a tiny little image (16x16 pixels) in a TreeGrid Column.
treeGrid.addComponentColumn(i -> new Image("file://c:/temp/reddot.png", "alt")).setHeader("Preview");
In my IDE, this file url is underlined, I can click it, it opens the image in my browser. So, the file seems ok and exists.
But somehow, it does not appear in the grid column and the "alt" text doesn't appear either.
Hm. Anyone any idea what's going wrong ? Unfortunatly I don't see any error messages...
thanks,
Thorsten
PS: I'm using Version 13.
You could try to put image under META-INF/resources. Then you could reference image directly by name like this : Image im=new Image("kissa.jpg","Random picture");
Otherwise, you could create a inside and then reference mentioning also folder. In the picture below I have this set-up
And this is the output :
The whole code:
TreeGrid<Person> grid = new TreeGrid<>(Person.class);
grid.setHierarchyColumn("name");
grid.addComponentColumn(e->{
if(e.getName().equals("daughter")) {
Image im=new Image("test/cat.jpg","Random picture");
im.setWidth("200px");
im.setHeight("150px");
return im;}
else {
Image im=new Image("kissa.jpg","Random picture");
im.setWidth("200px");
im.setHeight("150px");
return im;}}).setHeader("Cat");
Person dad = new Person("dad", null);
Person son = new Person("son", dad);
Person daughter = new Person("daughter", dad);
List<Person> all = Arrays.asList(dad, son, daughter);
all.forEach(p -> grid.getTreeData().addItem(p.getParent(), p));
add(grid);
The example of TreeGrid is copied from here: Using new features with the LTS version: case TreeGrid

grayt_autoStartup = true,

According to http://www.webspellchecker.net/samples/grayt-ckeditor-plugin.html
the statement CKEDITOR.config.grayt_autoStartup = true; should activate "GrammarAsYouType (GRAYT) for CKEditor 4+" grammer service on the editor
Their demo code did not even show the spelling button on my local test.
The code from http://sdk.ckeditor.com/samples/spellchecker.html did show the spelling options but not grammer.
Tried to add to the config:"grayt_autoStartup = true," like the "scayt_autoStartup: true," works, but then the entire UI was gone and no spell or grammar check.
Any one has a spelling AND grammar working in a local deployment?
Thanks in advance
You are right - GRAYT for CKEditor can be started like this:
grayt_autoStartup: true
For adding spelling button to CKEditor UI you need the following:
CKEDITOR.config.toolbar = [{
name: 'editing',
items: ['Scayt']
}];
There is no separate button for GRAYT. So you will have button only for SCAYT.
jsfiddle: https://jsfiddle.net/jalners/j4ytgb2v/

Resources