投稿時間:2023-01-08 20:22:38 RSSフィード2023-01-08 20:00 分まとめ(26件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita Flaskでルーティング その2 https://qiita.com/tsubotsubo529/items/a99a68e981eb664e3079 flask 2023-01-08 19:56:30
python Pythonタグが付けられた新着投稿 - Qiita 【Python】PandasのDataFrameで、周波数(Hz)から時系列のindexを作る方法(pandas.date_range) https://qiita.com/takuma-1234/items/d11c4482579131e08dac dataframe 2023-01-08 19:51:23
python Pythonタグが付けられた新着投稿 - Qiita AtCoder Beginner Contest 284 A〜C問題をPythonで解いてみました https://qiita.com/yasubei/items/99c4e18063d729af15a1 atcoderbeginnercontestac 2023-01-08 19:49:12
python Pythonタグが付けられた新着投稿 - Qiita Pythonでの音声信号処理 (3) 読み込んだ情報を可視化する その2 https://qiita.com/u1tym/items/b52c466620f65225edf3 tkimportnumpyasnpimportm 2023-01-08 19:07:51
海外TECH DEV Community How to download fancy QR Codes with React https://dev.to/anshsaini/how-to-download-fancy-qr-codes-with-react-b25 How to download fancy QR Codes with ReactGenerating QR codes on the web is easy There are lots of libraries out there who help us do it One of them is qrcode react which we will be using for the purpose of this tutorial Code to download a plain QR CodeWe re rendering a lt canvas gt element in the DOM using QRCodeCanvas supplied by qrcode react We can convert it to a png using JavaScript and then download it as a file QRCodeDownload tsximport React from react import QRCodeCanvas from qrcode react import Button from components Button const QRCodeDownload gt const url const downloadQRCode gt const canvas document querySelector qrcode canvas as HTMLCanvasElement if canvas throw new Error lt canvas gt not found in the DOM const pngUrl canvas toDataURL image png replace image png image octet stream const downloadLink document createElement a downloadLink href pngUrl downloadLink download QR code png document body appendChild downloadLink downloadLink click document body removeChild downloadLink return lt div className p gt lt QRCodeCanvas id qrcode canvas level H size value url gt lt div className my gt lt Button onClick downloadQRCode gt Download QR Code lt Button gt lt div gt lt div gt export default QRCodeDownloadVoilaThe QR Code is now saved in the file system as an image Taking it a step furtherNo one wants to share a QR code on its own Its ugly We want a nice UI surrounding the QR code giving it some context Maybe something like this Let s a create a wrapper component which will handle the styling I m using react jss for styling but of course you can use whatever you want and style your QR Code however you like QRCodeTemplate tsximport React FC PropsWithChildren from react import DEV RAINBOW LOGO from assets qr code dev rainbow png import DEV RAINBOW BG from assets qr code dev rainbow bg png import createUseStyles from react jss import Typography from components Typography const ICON SIZE const useStyles createUseStyles theme gt root backgroundImage url DEV RAINBOW BG maxWidth maxHeight borderRadius px border px solid EFEFF padding theme spacing logo boxShadow px px px px rgb height width borderRadius icon borderRadius width ICON SIZE height ICON SIZE position absolute Need to offset the values due to excavate true in qrcode react top calc ICON SIZE px Need to offset the values due to excavate true in qrcode react left calc ICON SIZE px qrContainer position relative backgroundColor EFEFF borderRadius px margin theme spacing padding theme spacing qrInner backgroundColor white borderRadius px padding referredBy fontStyle normal fontWeight fontSize px lineHeight px letterSpacing em const QRCodeTemplate FC lt PropsWithChildren gt children gt const classes useStyles return lt div className classes root id fancy qr code gt lt img alt logo className classes logo src DEV RAINBOW LOGO gt lt Typography className mt variant title gt To register scan the QR Code lt Typography gt lt div className classes qrContainer gt lt img alt icon className classes icon height ICON SIZE src DEV RAINBOW LOGO width ICON SIZE gt lt div className classes qrInner gt children lt div gt lt div gt lt Typography className classes referredBy variant emphasised gt REFERRED BY lt Typography gt lt Typography variant largeTitle gt Ansh Saini lt Typography gt lt div gt export default QRCodeTemplateWe can now pass our QR Code as children to the QRCodeTemplate lt QRCodeTemplate gt lt QRCodeCanvas Passing image here doesn t render when we convert html to canvas So we handle it manually We are only using this prop for excavate true use case imageSettings src x undefined y undefined height width excavate true level H size value url gt lt QRCodeTemplate gt Earlier we only had a canvas element in the DOM so we could directly convert it to a png But now our DOM includes HTML elements like lt div gt lt img gt etc for styling So we need to parse our DOM as canvas and then convert it into a png There s a libary which helps us do just that htmlcanvas We modify our downloadQRCode function such that first we get snapshot of our DOM as a canvas then we convert that into a png Final code QRCodeTemplate tsximport React from react import htmlcanvas from htmlcanvas import QRCodeCanvas from qrcode react import Button from components Button import QRCodeTemplate from components dashboard QRCodeTemplate const QRCodeDownload gt const url const getCanvas gt const qr document getElementById fancy qr code if qr return return htmlcanvas qr onclone snapshot gt const qrElement snapshot getElementById fancy qr code if qrElement return Make element visible for cloning qrElement style display block const downloadQRCode async gt const canvas await getCanvas if canvas throw new Error lt canvas gt not found in DOM const pngUrl canvas toDataURL image png replace image png image octet stream const downloadLink document createElement a downloadLink href pngUrl downloadLink download QR code png document body appendChild downloadLink downloadLink click document body removeChild downloadLink return lt div className p gt lt QRCodeTemplate gt lt QRCodeCanvas Passing image here doesn t render when we convert html to canvas So we handle it manually We are only using this prop for excavate true use case imageSettings src x undefined y undefined height width excavate true level H size value url gt lt QRCodeTemplate gt lt div className my gt lt Button onClick downloadQRCode gt Download QR Code lt Button gt lt div gt lt div gt export default QRCodeDownload The ResultWe have a beautiful QR code saved as a png And with the power of React we can create as many styles as we want 2023-01-08 10:48:45
海外TECH DEV Community JavaScript null is weird https://dev.to/niza/javascript-null-is-weird-33o9 JavaScript null is weirdJavaScript has a unique way of implementing common programming concepts Some things you assume will work a certain way will definitely give you a result but not the one you were expecting Let s say you read some literature that Null is a data type then you run typeof null then you find out null is not an object but it is of type object let x null console log typeof x logs object also this not object fake object has no propertieslet x null console log x prop TypeError Cannot read property prop of nullAlso consider this in JavaScript null is considered a falsy value which means it will be coerced to false when used in a boolean context This means that when null is compared to using the less than or equal to operator lt the result will be true console log null lt logs false console log null gt logs false console log null logs false console log null logs false console log null lt logs true console log null gt logs true Talking about weird things here is another example NaN is never equal to NaN the best way to test NaN is to use isNaN NaN NaN falseconsole log isNaN NaN trueconsole log isNaN falseconsole log isNaN hello true But bewareconsole log isNaN falseI know you have experienced other weirdness in your JavaScript journey please share it and the reason why you think it exists Do you think there were too many opinions in the development of the language Are there too many people taking advantage of these quirks for them to be changed Let me know your opinion 2023-01-08 10:10:26
ニュース @日本経済新聞 電子版 関西の廃校活用多彩 ドローン教習・水族館・ビール醸造 ▶「データで読む地域再生」特設ページへ https://t.co/L9pxmawmP1 https://t.co/BF3bEaLjNf https://twitter.com/nikkei/statuses/1612031815841386496 地域再生 2023-01-08 10:21:49
ニュース @日本経済新聞 電子版 [社説]食料自給率の向上へ農政の転換を https://t.co/gDtGRqV0tG https://twitter.com/nikkei/statuses/1612026731803860992 食料自給率 2023-01-08 10:01:37
海外ニュース Japan Times latest articles Lone ozeki Takakeisho makes winning start to New Year meet https://www.japantimes.co.jp/sports/2023/01/08/sumo/basho-reports/new-year-basho-day-1-takakeisho/ Lone ozeki Takakeisho makes winning start to New Year meetThe two time Emperor s Cup winner is the highest ranked wrestler contesting the day meet at Ryogoku Kokugikan in the absence of injured lone yokozuna Terunofuji 2023-01-08 19:11:13
ニュース BBC News - Home China reopens borders to tourists after three years of Covid closure https://www.bbc.co.uk/news/world-asia-china-64201776?at_medium=RSS&at_campaign=KARANGA annual 2023-01-08 10:42:54
ニュース BBC News - Home Australia v South Africa: Hosts complete 2-0 series win after drawn third Test in Sydney https://www.bbc.co.uk/sport/cricket/64202551?at_medium=RSS&at_campaign=KARANGA clean 2023-01-08 10:41:30
北海道 北海道新聞 地震の揺れ、実験し体感 釧路・遊学館子ども向けイベント https://www.hokkaido-np.co.jp/article/784814/ 地球科学 2023-01-08 19:40:08
北海道 北海道新聞 森重主将「勢いをつける」 冬季ユニバ出発式で抱負 https://www.hokkaido-np.co.jp/article/784829/ 森重 2023-01-08 19:37:00
北海道 北海道新聞 J1名古屋が新体制を発表 FWユンカー「全力尽くす」 https://www.hokkaido-np.co.jp/article/784808/ 名古屋市内 2023-01-08 19:22:32
北海道 北海道新聞 イラン、高まる仏への反感 週刊紙が最高指導者を風刺 https://www.hokkaido-np.co.jp/article/784786/ 最高指導者 2023-01-08 19:22:32
北海道 北海道新聞 近藤の人的補償は投手 日本ハム稲葉GM https://www.hokkaido-np.co.jp/article/784828/ 人的補償 2023-01-08 19:37:00
北海道 北海道新聞 20歳の門出、次代担う決意 留萌・宗谷管内で式典 https://www.hokkaido-np.co.jp/article/784827/ 宗谷管内 2023-01-08 19:35:00
北海道 北海道新聞 留萌の発展願い鏡開き 新年交礼会に90人 https://www.hokkaido-np.co.jp/article/784826/ 留萌商工会議所 2023-01-08 19:34:00
北海道 北海道新聞 振り袖で20歳祝う避難学生 福岡・太宰府、式典に出席 https://www.hokkaido-np.co.jp/article/784824/ 日本経済 2023-01-08 19:30:00
北海道 北海道新聞 一人大関の貴景勝が好発進 阿炎、若隆景も白星、正代は黒星 https://www.hokkaido-np.co.jp/article/784816/ 両国国技館 2023-01-08 19:15:16
北海道 北海道新聞 二十歳祝い各地で集い 苫小牧1224人、白老に日ハム根本投手 https://www.hokkaido-np.co.jp/article/784822/ 成人の日 2023-01-08 19:24:00
北海道 北海道新聞 胆振管内256人感染 日高管内は15人 新型コロナ https://www.hokkaido-np.co.jp/article/784821/ 医療機関 2023-01-08 19:23:00
北海道 北海道新聞 政府が新設「コロナ宣言」、岐阜県のみ 重症化率低く独自対策目立つ https://www.hokkaido-np.co.jp/article/784819/ 感染拡大 2023-01-08 19:22:00
北海道 北海道新聞 <光る企業>ダイゼン(鷹栖) 経費削減徹底、地方に出店 https://www.hokkaido-np.co.jp/article/784817/ 鷹栖 2023-01-08 19:15:02
北海道 北海道新聞 道北「緩やかに持ち直し」7カ月連続維持 日銀概況12月 https://www.hokkaido-np.co.jp/article/784818/ 道北 2023-01-08 19:15:00
北海道 北海道新聞 道立公園、利用者増に民間ノウハウ 道、新制度を検討 ホテルやカフェ整備促進 https://www.hokkaido-np.co.jp/article/784815/ 道立 2023-01-08 19:11: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件)