投稿時間:2021-06-21 02:18:58 RSSフィード2021-06-21 02:00 分まとめ(22件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT 気になる、記になる… 「Windows 11」では将来的にサードパーティ製ウィジェットが利用可能に?? https://taisy0.com/2021/06/21/142121.html windows 2021-06-20 16:02:04
TECH Engadget Japanese おトクなNintendo Switch本体セット販売中|Amazonプライムデー情報 https://japanese.engadget.com/nintendo-switch-163958158.html おトクなNintendoSwitch本体セット販売中Amazonプライムデー情報Amazonプライムデーは月日まで実施中です。 2021-06-20 16:39:58
TECH Engadget Japanese Jackeryの「ポータブル電源1000」が30%オフの9万7860円:Amazonプライムデー https://japanese.engadget.com/jackery-163315716.html amazon 2021-06-20 16:33:15
TECH Engadget Japanese 整備品のiPhone XSが6万1750円、AirPods Proが2万3400円など特価セール中:Amazonプライムデー https://japanese.engadget.com/iphone-162343587.html airpodspro 2021-06-20 16:23:43
TECH Engadget Japanese Fire TV Stick 4Kが43%オフの3980円。映画やテレビ番組を大画面で楽しめる:Amazonプライムデー https://japanese.engadget.com/primeday-fire-tv-stick-4k-161019434.html amazon 2021-06-20 16:10:19
TECH Engadget Japanese Amazonプライムデーで48%OFFの1万2980円、Echo Studio「どこでもハイレゾ」を実践 https://japanese.engadget.com/jp-2019-12-27-echo-studio-160504238.html echostudio 2021-06-20 16:05:04
TECH Engadget Japanese プライムデーで23%OFFのKindle Oasisをレビュー、「唯一の欠点」さえ気にならなければ神機 https://japanese.engadget.com/jp-2019-08-13-kindle-oasis-063035837-160123224.html kindleoasis 2021-06-20 16:01:23
js JavaScriptタグが付けられた新着投稿 - Qiita 【Javascript】配列によく使われる関数ー学習ノート https://qiita.com/redrabbit1104/items/1bf6589377754f100e76 consolelognamesslice HondaMatsuyama代入する引数の値がマイナスだった場合には配列の一番右側からと数えられ、番目から指定した引数のn番目までの値を持つ配列が生成されます。 2021-06-21 01:19:58
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) PHPファイルを整理したい https://teratail.com/questions/345150?rss=all PHPファイルを整理したい前提・実現したいことWordPressでホームページを作っています。 2021-06-21 01:54:26
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) PythonにおけるPearsonの積率相関係数を計算したい https://teratail.com/questions/345149?rss=all PythonにおけるPearsonの積率相関係数を計算したい前提・実現したいこと最近Python等で統計の勉強を始めた大学院生です。 2021-06-21 01:33:24
golang Goタグが付けられた新着投稿 - Qiita Go言語でRSAを実装してみる https://qiita.com/greenteabiscuit/items/7a01bcdd80e6abf1d372 Go言語でRSAを実装してみるGo言語で公開鍵暗号RSAを実装してみました。 2021-06-21 01:16:40
海外TECH DEV Community Do you want more 📈 views / shares on your dev.to articles❓ How I created a "click to tweet" button generator for my posts! https://dev.to/inhuofficial/do-you-want-more-views-shares-on-your-dev-to-articles-how-i-created-a-click-to-tweet-button-for-my-posts-20ng Do you want more views shares on your dev to articlesHow I created a quot click to tweet quot button generator for my posts I was recently thinking about how low my share rate on twitter is for my dev to articles Now it could just be that I write rubbish articles that nobody wants to share but I would hope that isn t the case After some thought I realised that because the share buttons are hidden away people might not get the prompt they need to share to social media and instead just rely on hearts unicorns and comments One thing that a lot of sites use to increase social media sharing is a click to tweet button We can link this to a piece of content that would make a good quote and let people post effortlessly So I set about coming up with a way to make that work on dev to Creating a click to tweet button for dev toFirst thing was first I couldn t use JavaScript on the page so I had to prebuild my click to tweet button in Markdown that results in standard HTML elements The second issue was that I am lazy and don t want to have to copy URLs etc in order to create the button I just want to be able to select some text in my article and have it all done for me The third issue was that I wanted something more than just a boring hyperlink I wanted something that would stand out within my articles Creating the markdownI decided that the best way to achieve my end goal would be a custom image with the link text within it I would then wrap that image in a hyperlink in order to make the button function The url for the hyperlink would be a tweet intent URL more on that in a little bit The markdown to create that is along the lines of create a link link content text image link URL create an image alt text for image image source URL nesting the image within the link Alt Text lt image url gt lt tweet intent url gt So immediately I realised that I need to generate things The image itself with the quote text within itThe alt text it should read Click to tweet this way people who use a screen reader will get the same information so they know what the hyperlink is for The tweet intent URL this is a URL in a certain format that twitter understands so that we pre populate the twitter card for somebody Creating the background imageI fired up illustrator fiddled around for a bit and came up with a nice image to contain my link text By adding a fake button to the bottom and giving it a subtle shadow it meant that it both stood out and drew attention to the fact that an action can be performed Then I just uploaded the image to my server so that I could reference it when I needed it The Alt TextThis was really simple once I had the quote text I just had to build a string that read Click to Tweet the text used in the image I then stored this in a variable for later use The tweet intent URLThis is also straight forward A tweet intent URL is in the format twitter com intent tweet url article url amp text uri encoded tweet textThe only thing I had to remember to do was use encodeURI on the quote text The hard partsAll seems easy so far Now comes the fun part I had to find a way to grab the selected text in the editor create the image on the fly with word wrapping etc find a way of uploading the image to dev to grab the URL of the image and then put that URL into our markdown we designed earlier Now the astute among you may notice something here I am interacting with a page that I do not control Bookmarklets to the rescueLuckily there is an easy cheat for this something called Bookmarklets I wrote about them before in my dev to WYSIWYG article Essentially we host a script on a server we control then create a browser bookmark that inserts that script into a page This can be done by creating a bookmark and giving it a name Editing that bookmark and replacing the URL with the code to load our script If you want to do this yourself with a script of your own here is the code to replace the URL with javascript function document getElementsByTagName head appendChild document createElement script src lt full url of your script gt Math random Just replace the lt full url of your script gt part with the URL of your script Now that we have a way of running a custom script we can tackle some other issues Adding the text to the imageAdding text to the image would be straight forward using lt canvas gt if it wasn t for one thing text wrapping So we have to add a function that calculates where the line breaks should be on any text that is too wide to fit function getLines ctx text maxWidth var words text split var lines var currentLine words for var i i lt words length i var word words i var width ctx measureText currentLine word width if width lt maxWidth currentLine word else lines push currentLine currentLine word lines push currentLine return lines We pass in the d context of the canvas the text we want to add and the maximum width of our text area This then works out where the line breaks should be and returns an array of all the lines for us to add later The important thing about this function is that it will use the current font size set on the canvas so make sure you set that first with ctx font XXpx Font Family Uploading the final image to dev toThis is actually quite simple once you understand how they do it There is a variable window csrfToken that you need to post to the endpoint along with your image data One big gotchya I had here was I was converting the canvas to an image and trying to upload it I kept getting a error This is because that endpoint is expecting an image to be sent via a file input As such it expects our image to have a file name To fix this was simple once I worked out what the problem was we just pass a third parameter to our formData entry let formData new FormData the third parameter allows us to give a name to our imageformData append image image myImage jpg Putting it all togetherAs with any of these experiments of mine it is a whole load of spaghetti I build a bit hack a bit in change a bit take shortcuts etc At the end of the day it gets the job done But hopefully the naming makes it clear enough what is done when If you want any particular part explaining just let me know in the comments function init config var canvas document createElement canvas canvas width canvas height document querySelector main appendChild canvas config config config userName config userName InHuOfficial config backgroundImageURL config backgroundImageURL config quoteText config quoteText Standard Text if you don t select anything config articleURL config articleURL config fontSize config fontSize config fontFamily config fontFamily Century Gothic config lineHeightAdjust config lineHeightAdjust config lineHeight config lineHeight config fontSize config lineHeightAdjust config url config url config textX config textX config textY config textY config textMaxWidth config textMaxWidth config textMaxHeight config textMaxHeight config textMaxCharCount config textMaxCharCount config canvasIdentifier config canvasIdentifier canvas config canvas document querySelector config canvasIdentifier config ctx config canvas getContext d config width config width config canvas width config height config height config canvas height config adjustFontSize config adjustFontSize true config textAreaName article body markdown config textArea document querySelector config textAreaName config grabCurrentURL config grabCurrentURL true return config var c init var image new Image make bg function make bg var selectedText getSelectedText if selectedText length gt c quoteText selectedText var charCount c quoteText length c articleURL length c userName length if charCount gt c textMaxCharCount alert max character count exceeded by charCount c textMaxCharCount characters return c ctx save c ctx clearRect c width c height base image new Image base image crossOrigin base image src c backgroundImageURL base image onload function console log drawing c ctx drawImage base image c width c height draw function calcFontSize quoteText if quoteText length lt return c fontSize if quoteText length lt return c fontSize return c fontSize function draw if c adjustFontSize c fontSize calcFontSize c quoteText c lineHeight c fontSize c lineHeightAdjust if c grabCurrentURL c articleURL window location href replace edit c ctx font c fontSize px c fontFamily var lines getLines c ctx c quoteText c textMaxWidth c linesHeightTotal lines length c lineHeight c ctx fillStyle c ctx textAlign start c ctx font c fontSize px c fontFamily var y c textY c textMaxHeight c linesHeightTotal for a a lt lines length a c ctx fillText lines a c textX y y c lineHeight c ctx restore image crossOrigin c canvas toBlob function img image img uploadImage image jpg function getLines ctx text maxWidth var words text split var lines var currentLine words for var i i lt words length i var word words i var width ctx measureText currentLine word width if width lt maxWidth currentLine word else lines push currentLine currentLine word lines push currentLine return lines function getSelectedText var start c textArea selectionStart var finish c textArea selectionEnd return c textArea value substring start finish function copyToClipboard str var el document createElement textarea el value str el setAttribute readonly el style position absolute el style left px document body appendChild el el select document execCommand copy document body removeChild el function uploadImage let auth token window csrfToken let formData new FormData formData append image image myImage jpg formData append authenticity token auth token fetch method POST body formData then function response return response json then function json if json length c url c url c articleURL c url c url amp text c url c url encodeURI c quoteText c userName var markdown Click to Tweet c quoteText json links c url copyToClipboard markdown alert copied to clipboard catch function err alert something went wrong console log error err If you want to use it yourself the init function can have a load of parameters passed to it to customise the output I would probably suggest you use it for inspiration and write your own version if you want to use it yourself OK so what does an end quote card look like So here it is the final click to tweet button in all its glory Now I just need something for you to tweet Twitter cards now on dev to to help boost your engagement How much extra engagement could your posts get with this simple bookmarklet Ok that is pretty cool how do I get it to work then A few simple steps looks like a lot but they are all reasonably straight forward Create and upload a background image to your domain and note down the path If using apache create a htaccess file in the same folder as your image that has the line Header set Access Control Allow Origin Same principle for other environments Copy the code to a js file Make any changes to the config section that match your needs or create your own config yourConfig and adjust the line the th line to var c init yourConfig Don t forget to change the path to your background image you created config backgroundImageURL and set the config userName to your dev to username as a bear minimum Upload the modified config to your domain and not down the script path Note down the full URL of the file Create a bookmark with a name that makes sense to you don t worry about the page you create it on yet Edit that bookmark and enter the following code replacing the lt full url of your script gt with the path to your modified script javascript function document getElementsByTagName head appendChild document createElement script src lt full url of your script gt Math random Phew all done Now the fun part Actually using the bookmarklet Create your article and get it ready for publishing Publish your article immediately edit it unfortunately the URL changes from drafts so you have to publish then quickly edit Find the text you want to create a quote from select it Click on your bookmarklet An alert will show after a short while if you have done everything correctly saying copied to clipboard place your cursor where you want your click to tweet and paste ConclusionYeah I doubt many people will actually use this bookmarklet but I thought I would give you the option Here is a quick GIF showing it in action once it is set up Go on try it out I converted the following quote into a click to tweet button I sent this tweet via a brand new click to tweet bookmarklet on dev to check out the article and code if your articles could benefit from more shares on twitter Go on press the button share this article 2021-06-20 16:40:53
Apple AppleInsider - Frontpage News Lack of 'creativity and enthusiasm' prevented big tech antitrust law overhaul https://appleinsider.com/articles/21/06/19/lawmakers-werent-creative-or-enthusiastic-enough-to-fix-big-tech-antitrust-laws?utm_medium=rss Lack of x creativity and enthusiasm x prevented big tech antitrust law overhaulThe CEOs of big tech companies like Apple have been allowed to do whatever they want according to Representative David Cicilline in an interview over a series of antitrust bills taking aim at the tech giants In early June a collection of five bills were introduced by U S House lawmakers aimed at introducing changes to antitrust legislation The bills cover a range of topics that have received antitrust attention including affecting how Apple could operate the App Store and even what apps it bundles with iPhones in iOS During an interview for the New York Times Sway podcast Congressman David Cicilline Dem RI outlined the aims of each bill as well as why the U S government is moving to make major changes in antitrust law The bills are set to start being reviewed by late June Read more 2021-06-20 16:18:58
Apple AppleInsider - Frontpage News Best Prime Day 2021 deals on Apple AirPods https://appleinsider.com/articles/21/06/19/best-prime-day-2021-deals-on-apple-airpods?utm_medium=rss Best Prime Day deals on Apple AirPodsPrime Day deals are heating up and Apple AirPods are at some of the season s best prices on Amazon AirPods Prime Day dealsUpdate on June Amazon has matched Target s Day of Deals price on AirPods Pro discounting the wireless earbuds to Read more 2021-06-20 16:21:34
海外TECH Engadget Apple's iPad Air returns to a record low $539 at Amazon https://www.engadget.com/apple-ipad-air-sale-amazon-june-2021-164012510.html?src=rss_b2c amazon 2021-06-20 16:40:12
海外科学 NYT > Science Wondering if the Vaccine Worked? Get the Right Test, at the Right Time https://www.nytimes.com/2021/06/20/health/coronavirus-vaccine-antibody-test.html timescientists 2021-06-20 16:39:37
ニュース BBC News - Home Andy Burnham's anger at Manchester-Scotland travel ban https://www.bbc.co.uk/news/uk-england-manchester-57544665 government 2021-06-20 16:08:59
ニュース BBC News - Home Girl, 13, dies after falling from roof of Largs building https://www.bbc.co.uk/news/uk-scotland-glasgow-west-57546342 largs 2021-06-20 16:45:37
ニュース BBC News - Home Dál Riata Channel: First all-female relay team swim 'perilous' waterway https://www.bbc.co.uk/news/uk-northern-ireland-57543609 female 2021-06-20 16:11:49
ニュース BBC News - Home Queen's: Cameron Norrie loses final to Matteo Berrettini https://www.bbc.co.uk/sport/tennis/57545917 queen 2021-06-20 16:22:16
ニュース BBC News - Home Hartlepool promoted to Football League after beating Torquay on penalties https://www.bbc.co.uk/sport/football/57457835 Hartlepool promoted to Football League after beating Torquay on penaltiesHartlepool United return to the English Football League as they beat Torquay United on penalties despite Gulls goalkeeper Lucas Covolan scoring a stoppage time equaliser 2021-06-20 16:56:50
北海道 北海道新聞 車内に男女4遺体、心中か 神戸、練炭燃えかす残る https://www.hokkaido-np.co.jp/article/557777/ 神戸市北区淡河町野瀬 2021-06-21 01:14:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)