python |
Pythonタグが付けられた新着投稿 - Qiita |
バッチ処理環境の構築(汎用機からの離脱) |
https://qiita.com/segiori/items/7e4ceb9e742c65087f23
|
入力データはUTFからUTFに変換していますUTFベースでデータベースへロードしていますUTFで文字データを扱っていますUnicodeの独自フォントを表示させたかったができなかった。 |
2021-08-10 01:21:23 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
JSで連想配列の配列を並び替える【JavaScript】【Rails】 |
https://qiita.com/NoSuke23/items/a0cfe820aa63ea7ddbc8
|
JSで連想配列の配列を並び替える【JavaScript】【Rails】したいことデータベースから取ってきたデータをフロントJSで任意のカラムで並び変えて表示したいAPIに何回もアクセスしたくないためコードJSexportletsortItemsitemssortTypeordergtreturnitemssortabgtiforderASCreturnasortTypeltbsortTypeelseDESCreturnasortTypegtbsortTypeitemsは連想配列の配列。 |
2021-08-10 01:47:55 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
DOM要素を拡大縮小、移動可能にする【JavaScript】 |
https://qiita.com/NoSuke23/items/54df05a61568246166b4
|
|
2021-08-10 01:21:22 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
v-forディレクティブ内でメソッドを繰り返して呼び出し、その繰り返し処理の結果を繰り返し毎に反映させたい |
https://teratail.com/questions/353527?rss=all
|
firebasenbspstorageから画像をパスをreadしており、ファイル名は自作のapiからimagenameというkeyで返ってきていますその返り値をsrcに反映させ画像を表示したいのですが、うまくやり方が分からないです。 |
2021-08-10 01:46:54 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
WEBフォントが表示されない現象 |
https://teratail.com/questions/353526?rss=all
|
|
2021-08-10 01:46:50 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
【WindowsForm】コンボボックスを別クラスのメソッドで設定したい |
https://teratail.com/questions/353525?rss=all
|
【WindowsForm】コンボボックスを別クラスのメソッドで設定したい前提・実現したいことフォーム内のコンボボックスを別クラスのメソッドで設定したいのですが、メソッド内でComboBoxオブジェクトを生成して、書き換える方法だと中身が表示されません。 |
2021-08-10 01:21:37 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
たった1日で基本が身につく!Docker/kubernetes超入門6章Jenkins関連でつまづいたところのメモ |
https://qiita.com/Sicut_study/items/bc8ec154dbe22c5749d9
|
また、私の環境ではちょくちょくエラーが起きてたのですが、イメージ変更して起きたのかと思いましたが、ネットワークの問題でうまくインストールができなかったりしていたようでした。 |
2021-08-10 01:39:31 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Docker for Windowsは動作が重すぎて使い物にならないは嘘 |
https://qiita.com/nagareboshi/items/75fb86c2a87bf3ef78bc
|
遅いパターンそのWindows側CドライブやDドライブのデータをもとにコンテナを生成する※ファイルの実体がWindows側にあり、そのデータをコンテナと共有している状態そのUbuntuには、mntchogehogeなどといった形でWindowsのデータが自動的にマウントされているので、このUbuntuにマウントされたデータをもとにコンテナを生成する※ファイルの実体がWindows側にあり、そのデータをコンテナと共有している状態WSLとWindowsとではファイルシステムが異なるため、それらを共通に扱おうとするとどうしても遅くなってしまいます。 |
2021-08-10 01:12:18 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
JSで連想配列の配列を並び替える【JavaScript】【Rails】 |
https://qiita.com/NoSuke23/items/a0cfe820aa63ea7ddbc8
|
JSで連想配列の配列を並び替える【JavaScript】【Rails】したいことデータベースから取ってきたデータをフロントJSで任意のカラムで並び変えて表示したいAPIに何回もアクセスしたくないためコードJSexportletsortItemsitemssortTypeordergtreturnitemssortabgtiforderASCreturnasortTypeltbsortTypeelseDESCreturnasortTypegtbsortTypeitemsは連想配列の配列。 |
2021-08-10 01:47:55 |
海外TECH |
DEV Community |
Include HTML-in-HTML: an iteration |
https://dev.to/lionelrowe/include-html-in-html-an-iteration-45ik
|
Include HTML in HTML an iterationInspired by fjones s comment on this article Include HTML Inside of HTML Just Like React Components Suhail Kakar・Aug ・ min read html javascript webdev programming FJones • Aug •Edited on Aug This strikes me as a very interesting use case for webcomponents over the rather crude method in htmlinclude js It also seems like this would hit quite a lot of CSP problems E g I suspect you would struggle to load any script tags or external resources from the included file Sounds like a challenge Here are the design goals Simple front end only HTML API to include HTML fragments inside other HTML documents similar to htmlinclude jsNo HTML boilerplate required in the included HTML fragments For example lt div gt lt div gt is fine ーdoesn t need to be lt DOCTYPE html gt lt html lang en gt lt head gt lt title gt title lt title gt lt head gt lt body gt lt div gt lt div gt lt body gt lt html gt Renders multiple child fragments with no problem For example lt div gt lt div gt lt div gt lt div gt works just as well as lt div gt lt div gt lt div gt lt div gt lt div gt lt div gt doesOnce rendered the include html component is no longer present in the DOMAllows including cross origin content as long as CORS headers set correctly on the resourceRuns script tags on same origin content unless sanitize attribute is setDoesn t run script tags or anything else dangerous from cross origin contentWithout further ado here s the implementation isSameOriginWe use this function to check that the included content is from the same origin If not it ll definitely need sanitization as we don t want rd parties to be able to inject scripts param string src const isSameOrigin src gt new URL src window location origin origin window location originBy providing a nd parameter base to the URL constructor we resolve the src relative to the current origin Then we check if the origin of the two is the same For example new URL bar html resolves to of which the origin is still so the result will be truenew URL resolves to The base parameter in this case is ignored as the src is already fully qualified The origin is different from so the result will be false safeHtmlThis is the function we use to sanitize the HTML if required param sanitize boolean const safeHtml sanitize gt param string html html gt const sanitized sanitize false DOMPurify sanitize html html return Object assign sanitized html sanitized We use DOMPurify a widely used and battle tested solution for HTML sanitization Using Object assign on a string gives a String object with the additional properties added By adding an html property we could directly use the result with React s dangerouslySetInnerHTML if we wanted but we can still assign it directly to an element s innerHTML as it s still a string sort of const s safeHtml abc ⇒String abc html abc s abc IncludeHtml Web ComponentHere s the web component itself class IncludeHtml extends HTMLElement async connectedCallback const forceSanitize Boolean this attributes sanitize const src this attributes src value if this innerHTML trim this textContent Loading const res await fetch src const html safeHtml sanitize isSameOrigin src forceSanitize await res text const range document createRange make rendering of fragment context aware range selectNodeContents this parentElement this replaceWith range createContextualFragment html customElements define include html IncludeHtml Using range createContextualFragment means we can create a HTML fragment that will also execute any script tags present upon rendering assuming we haven t sanitized them away yet range selectNodeContents means that the rendering will work as expected in a way that s aware of surrounding context For example trying to insert a tr outside of a table will render nothing but it will work as expected within a table By using this replaceWith we immediately remove the Web Component from the DOM as the content is rendered which is similar to what you d expect from a back end templating framework UsageFinally here are some examples of the component in use lt nav gt lt include html src includes nav html gt lt include html gt lt nav gt lt main gt lt Including from rd party source works if CORS headers set properly on the source gt lt include html src paragraphs amp words gt lt include html gt lt main gt lt footer gt lt include html sanitize src includes footer html gt lt include html gt lt footer gt lt script src dist purify min js gt lt script gt lt script src js html in html js gt lt script gt You can see the rendered output and try it out yourself in this live CodeSandbox demo Thanks for reading What improvements would you make to the API or features |
2021-08-09 16:28:36 |
海外TECH |
DEV Community |
Data Structure Series: Linked List |
https://dev.to/chuckchoiboi/data-structure-series-linked-list-3eb2
|
Data Structure Series Linked List Table of ContentsIntroductionWhat is a Linked List Implementation in JavaScriptHelper MethodsBig OHelpful Resources Introduction We use forks to eat pasta spoons to eat soup and chopsticks to eat dumplings Each silverwares have its advantages disadvantages hence working better than the other for the food that it interacts well with Just like that different data structures are better suited and perform better than the others based on the situations use cases They each have their pros and cons Understanding these pros and cons can help you be a better programmer as it will allow you to choose an appropriate data structure s based on the circumstances goals you have and it helps to drastically improve the performance of the algorithm being applied I will be putting these blog series together on well known programming data structures in JavaScript and link them all in one blog post in the future Feel free to leave a comment if you have any questions What is a Linked List A Linked List is a collection of data in a sequence with each of the data referencing its next node or previous node if it is a Doubly Linked List from its head to the tail A Linked List is a type of data that is represented in a sequential collection Each piece of data in that collection is called the node which references its adjacent node in the sequence The first node of a linked list is called the head and the last node is called the tail There are two types of linked lists Singly Linked List and Doubly Linked List As the names suggest Singly Linked Lists nodes are linked in only single direction so each nodes references its next node On the other hand Doubly Linked Lists nodes reference both its previous and the next node In summary a Linked List is a collection of data in a sequence with each of the data referencing its next node or previous node if it is a Doubly Linked List from its head to the tail It sounds a bit similar to a built in data structure Array doesn t it The difference is that Arrays store each data in a consecutive manner in the memory meaning that the elements are stored next to each other And each elements is indexed based on the position and each element is directly accessible using those indices Meanwhile Linked Lists store each data anywhere in the memory but the nodes reference their next and previous node So in order to access a specific node in a Linked List you need to traverse the list sequentially from its head or tail to the other end until you get to the node you are looking for Because of these differences there are things that linked lists can do better than arrays and vice versa Arrays can search fasterAs we discussed Arrays support random access so we can access any elements in the n th index very quickly while Linked Lists support sequential access so we have to start from the head or tail to the n th node or value of the node we are looking for thus taking longer time to search an element Linked Lists can insert delete fasterIn order to insert or delete an element in the beginning or middle of an Array you have to shift all of the elements on the right since its consecutive index positions will change So inserting and deleting an element in an array can be costly unless you are inserting or removing the last element of the array since there s no elements after the last element With Linked Lists inserting deleting the first and the last element takes constant time since we just have to update the head tail Inserting deleting an element in the middle can take linear time as well though since you d have to find the position to insert delete by traversing the list one element at a time However there s no need to update all the elements that come afterwards you just have to rearrange its adjacent nodes Implementation in JavaScript Singly Linked List each node references its NEXT nodeclass Node constructor value this value value this next null class SinglyLinkedList constructor this head null this tail null this length let SLL new SinglyLinkedList let firstNode new Node let secondNode new Node let thirdNode new Node set the first new node as the SLL s headSLL head firstNode SLL length second as its nextfirstNode next secondNode SLL length the third as the second s next while also setting it as a tail since it s the last one secondNode next SLL tail thirdNode SLL length This SLL will look something like this gt gt Doubly Linked List each node references both its NEXT and PREVIOUS nodeclass Node constructor value this value value this next null this prev null class DoublyLinkedList constructor this head null this tail null this length let DLL new DoublyLinkedList let firstNode new Node let secondnode new Node let thirdNode new Node set the first new node as the DLL s headDLL head firstNode DLL length second as its next and head as its prevfirstNode next secondNode secondNode prev firstNode DLL length the third as the second s next while also setting it as a tail since it s the last one secondNode next DLL tail thirdNode thirdNode prev secondNode DLL length This SLL will look something like this lt gt lt gt We will set up a Node class which accepts a value and set it to its value with its next property and prev if Doubly Linked List initialized to null Linked List class will be a sequential collection of these nodes which will have its head and tail We will want to keep track of the list s length and increment decrement it every time a new node is added or removed Since Singly Linked Lists s nodes only reference the next node and Doubly Linked Lists nodes reference both their next and previous nodes Singly Linked Lists are simpler but less powerful than Doubly Linked Lists If you were to implement a helper method to pop the last element of the list it s easier to do that with Doubly Linked Lists as you simply have to remove the tail of the list and set the new tail to be the previous node of the tail being removed On the other hand we can access the tail of the list but will have to traverse the entire list and remember the previous node until you hit the tail so you can remove the tail and set the remembered previous node to be the new tail The main drawback of using Doubly Linked List vs Singly Linked List is that Doubly Linked List takes up more space than the Singly Linked List since you have to set each nodes next and previous node But in return it opens up more doors to make your data and its algorithms efficient With that being said here are couple helper methods to utilize Linked Lists better However we will only focus on Doubly Linked Lists for this blog post Helper Methods Doubly Linked List only push accepts a value as an argument appends a new node with the value passed at the end of the listpush value let newNode new Node value if this head this head this tail newNode else this tail next newNode newNode prev this tail this tail newNode this length return this Pseudo code Create a new node with the value passed to the functionIf the head property is null set the head and tail to be the newly created nodeIf the head is not null set the next property on the tail to be that nodeSet the prev property on the newly created node to be the tailSet the tail to be the newly created nodeIncrement the lengthReturn the Linked Listpop removes the last node tail of the listpop if this head return undefined let removedNode this tail if this length this head this tail null else this tail removedNode prev this tail next null removedNode prev null this length return removedNode Pseudo code If there is no head return undefinedStore the current tail in a variable to return laterIf the length is set the head or tail to be nullUpdate the tail to be the previous NodeSet the new tail s next to nullDecrement the lengthReturn the node removedunshift accepts a value as an argument prepends a new node with the value passed at the beginning of the listunshift value let newNode new Node value if this length this head newNode this tail this head else this head prev newNode newNode next this head this head newNode this length return this Pseudo code Create a new node with the value passed to the functionIf the length is set the head and tail to be the new nodeOtherwiseSet the prev property on the head to be the new nodeSet the next property on the new node to be the head propertyUpdate the head to be the new nodeIncrement the lengthReturn the Linked Listshift removes the first node head of the listshift if this length return undefined let oldHead this head if this length this head null this tail null else this head oldHead next this head prev null oldHead next null this length return oldHead Pseudo code If length is return undefinedStore the current head property in a variableIf the length is one set the head and tail to be nullUpdate the head to be the next of the old headSet the head s prev property to nullSet the old head s next to nullDecrement the lengthReturn old headget accepts an index as an argument returns the node at the index passedget idx if idx lt idx gt this length return null let count current if idx lt this length count current this head while count idx current current next count return current else count this length count this tail while count idx current current prev count return current Pseudo code If the index is less than or greater or equal to the length return nullIf the index is less than or equal to half the length of the listLoop through the list starting from the head and loop towards the middleReturn the node once it is foundIf the index is greater than half the length of the listLoop through the list starting from the tail and loop towards the middleReturn the node once it is foundset accepts an index and value as arguments finds the node at the index and updates the node s value to the value passed returns false if the node is not found true if the value is updatedset idx value let foundNode this get idx if foundNode return false foundNode value value return true Pseudo code Create a variable which is the result of the get method at the index passed to the functionIf the get method does not return a valid node return falseSet the value of the node found from get method to the value passed to the functionreturn true Big O Space Complexity O n Space complexity of this data structure is linear as the size of the list increase so does the spacePush Pop and Shift Unshift O Time ComplexityIt will take constant time to add remove the node at the head and tail of a Linked List since we just have to add a new node to the either end and update the newly added node as its head tail or its previous next element as head or tail if the node is being removed Get Set and Insert Delete O n Time ComplexityIn order for us to find an element in a Linked List we will need to traverse the list to find the index or value of the index Due to this nature of the Linked List modifying the node in the middle of the list will take linear time the time complexity changes based on the list size Although Insert Delete methods are not listed in the helper method above you get the idea that we will have to traverse the list to find an index of the list to insert delete the element Helpful Resources Online Course Udemy Course Check out this Udemy course named JavaScript Algorithms and Data Structures Masterclass It is created by Colt Steele and I referenced his code for the data structure implementation part of this blog post Personally I didn t know where to start with algorithms and data structures especially coming from a non tech background This course is very well structured for beginners to build a foundation on these topics Visual Animation VisuAlgo Data structures can be difficult to comprehend for some people just by looking at the code text The instructor in the course above uses a website named VisuAlgo that has visual representation of algorithms and data structures through animation Data Structure Cheat Sheet Interview Cake Also here s a really well summarized cheat sheet visualizations on data structures |
2021-08-09 16:15:48 |
海外TECH |
DEV Community |
15 Magical JavaScript Tips for Every Web Developer |
https://dev.to/dawgswqe/15-magical-javascript-tips-for-every-web-developer-1kp4
|
Magical JavaScript Tips for Every Web DeveloperIn this article we will discuss the useful JavaScript tips for every web developer to save their valuable and precious time I am always ready to learn although I do not always like being taughtーWinston ChurchillTip Flatten the array of the arrayThis tip will help you to flatten a deeply nested array of arrays by using Infinity in flat var array flatten array of arrayarray flat Infinity output Tip Easy Exchange VariablesYou probably swap the two variables using a third variable temp But this tip will show you a new way to exchange variables using destructuring example var a var b a b b a console log a b Read More Magical JavaScript Tips for Every Web Developer |
2021-08-09 16:14:41 |
海外TECH |
DEV Community |
React SaaS Boilerplate Template for JavaScript developers |
https://dev.to/ixartz/react-saas-boilerplate-template-for-javascript-developers-33p9
|
React SaaS Boilerplate Template for JavaScript developersAs you might know building a SaaS is extremely difficult Like many developers I ve underestimated the complexity of building a SaaS product and overestimated my programming skill In this article I want to share the technology stack I used to build my React Boilerplate and I reuse it for all my SaaS applications It helps me to reduce my setup and programming time by React for frontendFully built in React with TypeScript and styled with Tailwind CSS it makes the code more modular and makes the UI components reusable I use NextJS framework to build my React application in static mode SSG At build time all the application is pre rendered Perfect for SEO and cheap hosting NextJS also provides more features Checkout their website for more informationI also recommend using two dependencies for the frontend react hook form for form management in React and AWS amplify it connects the React frontend to the backend hosted in the AWS cloud Serverless BackendAs an indie maker it s extremely time consuming to manage and provision a backend I choose serverless to host my backend by making my life easier when my SaaS goes public I don t need to worry about scaling and server management I use Serverless framework to build the serverless backend Compatible with major cloud providers I choose to deploy on AWS in one command With Serverless framework I can also test locally on my computer before pushing to production AWS Cloud InfrastructureServerless framework is extremely easy to use but sometimes it quite limiting To go further in cloud infrastructure I use AWS CDK By using AWS CDK I can define my cloud resources in code It makes the infrastructure easy to customize share and reuse Good news You can use your most loved programming language In my case I use TypeScript and write my infrastructure stack entirely in TypeScript compatible with your IDE and your version control like Git Nextless js Next JS SaaS starterIt took me several months months to build my first SaaS products I definitively think this time can be reduced by Building a React SaaS application should only take one month for its first version As an indie maker you shouldn t lose time with boring configuration and setup With Nextless js React SaaS Boilerplate you can focus on what makes your SaaS unique You can now launch faster your application and quickly get user feedback Find more information on the tech stack at Nextless js SaaS BoilerplateStay tuned I ll publish more tutorials and articles about building SaaS products |
2021-08-09 16:14:21 |
海外TECH |
Engadget |
'Hellblade: Senua's Sacrifice' gets a surprise Xbox Series X/S patch |
https://www.engadget.com/hellblade-senuas-sacrifice-xbox-series-xs-ray-tracing-4k-162024800.html?src=rss
|
x Hellblade Senua x s Sacrifice x gets a surprise Xbox Series X S patchNinja Theory has released an Xbox Series X S optimization patch for Hellblade Senua s Sacrifice three years after the action adventure game arrived on Xbox One Along with enhanced visuals you can take advantage of DirectX ray tracing on your next playthrough A PC update is also in the works but there are no current plans for a PlayStation performance patch The performance mode supports a dynamic resolution of up to p with a maximum framerate of on Xbox Series X and full HD at frames per second on Xbox Series S The resolution mode offers up to K dynamic visuals on Series X at fps and up to p at fps on Series S The enriched mode enables ray tracing on both consoles at fps with a dynamic resolution of up to K on Series X and full HD on Series S Ninja Theory says it has updated details materials and particles and there s now a chapter select option Which mode will you be playing For more information check out pic twitter com rRocGBwBDーNinja Theory NinjaTheory August The patch arrives ahead of Senua s Saga Hellblade II which will be exclusive to Xbox and PC The original game debuted on PC and PlayStation in before hitting Xbox One the following March Microsoft added Ninja Theory to the Xbox Game Studios portfolio in There s no confirmed release window for the sequel as yet Microsoft is promising updates on some Xbox Game Studios titles during its Gamescom event later this month so perhaps we ll find out more details then |
2021-08-09 16:20:24 |
ニュース |
BBC News - Home |
Greensill: David Cameron 'made $10m' before company’s collapse |
https://www.bbc.co.uk/news/uk-58149765
|
cameron |
2021-08-09 16:14:24 |
ニュース |
BBC News - Home |
Test and Trace boss Dido Harding to step down from NHS role |
https://www.bbc.co.uk/news/health-58151615
|
johnson |
2021-08-09 16:29:39 |
ニュース |
BBC News - Home |
Anger at overflowing Covid test drop boxes |
https://www.bbc.co.uk/news/business-58149951
|
anger |
2021-08-09 16:57:06 |
ニュース |
BBC News - Home |
Covid-19: Joy for Scottish clubbers and Sheeran and Jagger join India fundraiser |
https://www.bbc.co.uk/news/uk-58150116
|
coronavirus |
2021-08-09 16:38:33 |
ニュース |
BBC News - Home |
London's Tower Bridge stuck open after technical failure |
https://www.bbc.co.uk/news/uk-england-london-58149716
|
failure |
2021-08-09 16:16:31 |
ニュース |
BBC News - Home |
Lukashenko: 'You can choke on your sanctions in the UK' |
https://www.bbc.co.uk/news/world-europe-58150328
|
economic |
2021-08-09 16:52:10 |
ニュース |
BBC News - Home |
British Sea Power: Indie band drop the word British from their name |
https://www.bbc.co.uk/news/entertainment-arts-58150537
|
crass |
2021-08-09 16:16:02 |
ニュース |
BBC News - Home |
Verma hits 76 off 42 balls as Phoenix break records and avoid early exit by beating Fire |
https://www.bbc.co.uk/sport/cricket/58151422
|
Verma hits off balls as Phoenix break records and avoid early exit by beating FireIndia s teenage superstar Shafali Verma crunches the fastest half century in the women s Hundred as Birmingham Phoenix keep their slim hopes alive with an empathic victory over Welsh Fire |
2021-08-09 16:56:29 |
ニュース |
BBC News - Home |
Covid-19 in the UK: How many coronavirus cases are there in my area? |
https://www.bbc.co.uk/news/uk-51768274
|
cases |
2021-08-09 16:23:35 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
中国・新疆からの輸入中止要求、米企業への圧力高まる - WSJ発 |
https://diamond.jp/articles/-/279093
|
輸入 |
2021-08-10 01:09:00 |
北海道 |
北海道新聞 |
首相、原爆式典に1分遅刻 長崎平和公園、被爆者批判 |
https://www.hokkaido-np.co.jp/article/576608/
|
原爆犠牲者 |
2021-08-10 01:02:12 |
コメント
コメントを投稿