Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
cloneNodeで複製された要素の中からクリックされた要素を削除する |
https://teratail.com/questions/347387?rss=all
|
「cloneNodeで複製された要素の中からクリックされた要素を削除する」という処理をしたいのですが、クリックした要素以外の要素も削除されてしまいます。 |
2021-07-03 04:42:59 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
時系列データと非時系列データを共に用いた結果予測 |
https://teratail.com/questions/347386?rss=all
|
Bnbsp同データで、年後の生存確率を予測XをPyTorchもしくはTensorFlowで行いたいと思いますが。 |
2021-07-03 04:23:38 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
さくらのVPS-PHP-DB接続エラー |
https://teratail.com/questions/347385?rss=all
|
さくらのVPSPHPDB接続エラー前提・実現したいことさくらのVPS契約しまして、CentOS環境nbspphpその際、スクリプトLAMPを採用しましてyumによりApache、MySQL、PHPをインストールし、LAMP構成を作成します。 |
2021-07-03 04:17:34 |
海外TECH |
Ars Technica |
Qualcomm plans to design an M1 competitor for PCs—sans ARM |
https://arstechnica.com/?p=1777958
|
cristiano |
2021-07-02 19:05:41 |
海外TECH |
DEV Community |
Soft Deletes in Django |
https://dev.to/bikramjeetsingh/soft-deletes-in-django-a9j
|
Soft Deletes in Django What is Soft Deletion Sometimes you want to delete something from your database without actually deleting it You want to preserve it in case you ever decide to restore it in the future or to use it for some other purpose such as analytics …but it should still appear as if it were actually deleted not show up in unexpected places in your application This is called the soft delete pattern Instead of actually deleting a record from your database which is irreversible you simply mark it as deleted usually in another column in your table Now the challenge remains how to prevent soft deleted records from leaking into your application In this article we will learn how to implement soft deletion in Django by taking the example of a simple note taking app backend Soft Delete ModelWe will start by creating a base SoftDeleteModel that can be inherited by the rest of our models class SoftDeleteModel models Model is deleted models BooleanField default False def soft delete self self is deleted True self save def restore self self is deleted False self save class Meta abstract TrueNote that we have marked this model as abstract True This means that Django will not create a database table for it Now we can create our models as subclasses of SoftDeleteModel to grant them the ability to be soft deleted Let s take the example of a Note model class Note SoftDeleteModel user models ForeignKey User on delete models CASCADE related name notes title models CharField max length content models CharField max length We can query our database filtering by is deleted in order to exclude records that have been soft deleted Note objects filter is deleted False Trying It OutLet s try playing around a bit with the code we ve written so far First open up the Django shell by typing python manage py shell in your terminal Import the models required from django contrib auth models import Userfrom tutorialapp models import NoteSince each note is foreign keyed to a user our first step is to create a User object john User objects create user john lennon thebeatles com johnpassword Now we can create a couple of notes my note Note objects create user john title Strawberry Fields content Strawberry Fields Forever another note Note objects create user john title Here Comes The Sun content It s All Right You are now ready to soft delete and restore notes my note soft delete my note restore You can query for all notes whether they have been soft deleted or not Note objects all You can also filter only for notes that have not been soft deleted Note objects filter is deleted False Soft Delete ManagerWhile our code is functionally correct the disadvantage is that we will have to remember to filter by is deleted False each time we write a query We can improve upon this behaviour by creating a custom model manager to apply the filter automatically behind the scenes If you ve used Django in the past you might be familiar with statements that look like this MyModel objects all The objects part in the statement is the manager Managers act as the bridge between your Django code and the database They control the database operations performed on the tables that they manage Our new custom manager can be defined as class SoftDeleteManager models Manager def get queryset self return super get queryset filter is deleted False We will need to add the new manager to our SoftDeleteModel base class class SoftDeleteModel models Model is deleted models BooleanField default False objects models Manager undeleted objects SoftDeleteManager def soft delete self self is deleted True self save def restore self self is deleted False self save class Meta abstract TrueNote that since we have added a custom manager to our class we are required to explicitly add the default objects manager as well Then we can simply rewrite our query as Note undeleted objects all to get a QuerySet of undeleted notes We can still useNote objects all to get the full list of notes including those that have been soft deleted Handling Foreign Key RelationshipsNow what if you have multiple users and you want to fetch all the notes belonging to a specific user The naive approach is to simply write a query filtering against the user Note objects filter user john is deleted False However a more elegant and readable solution is to make use of the reverse relationships Django provides for this purpose john notes all Try soft deleting some of your notes and running this query Do you notice something unusual about the results We find that the resultant QuerySet contains records that we had soft deleted This is because Django is using the default objects manager to perform the reverse lookup which as you may recall does not filter out soft deleted records How can we force Django to use our custom SoftDeleteManager to perform reverse lookups We can simply replace the default objects manager in our SoftDeleteModel class SoftDeleteModel models Model is deleted models BooleanField default False objects SoftDeleteManager all objects models Manager def soft delete self self is deleted True self save def restore self self is deleted False self save class Meta abstract TrueNow the objects manager will automatically filter out soft deleted objects when querying our database ensuring they never leak into our application under any circumstances If we want to we can still include soft deleted objects in our queries by making use of the all objects manager Note all objects all Storing More InformationWe ve already got a pretty solid soft deletion framework in our Django app but we can make one final improvement Knowing whether a record is soft deleted or not is useful but another piece of information that would be nice to know is when the record was soft deleted For this we can add a new a attribute deleted at to our SoftDeleteModel deleted at models DateTimeField null True default None We can also update our soft delete and restore methods as follows def soft delete self self deleted at timezone now self save def restore self self deleted at None self save For undeleted records the value of deleted at will be null while for soft deleted records it will contain the date and time at which it was deleted The addition of the new deleted at attribute makes our previously created is deleted attribute redundant because we can simply perform a null check on deleted at to find out whether the record is soft deleted or not Our rewritten SoftDeleteModel now looks like this class SoftDeleteModel models Model deleted at models DateTimeField null True default None objects SoftDeleteManager all objects models Manager def soft delete self self deleted at timezone now self save def restore self self deleted at None self save class Meta abstract TrueAnd our rewritten SoftDeleteManager looks like this class SoftDeleteManager models Manager def get queryset self return super get queryset filter deleted at isnull True In addition to our previous capabilities we can now also see the exact date and time at which our record was soft deleted my note deleted at In ConclusionSoft deletion is a powerful software pattern that comes with several advantages including better data preservation and restoration history tracking and faster recovery from failures At the same time it should be used with care Sensitive and personal data including payment related information should always be hard deleted Users should always have the option to have their data permanently deleted if they wish Several jurisdictions around the world have information privacy and data protection laws that include the right to be forgotten such as the European Union s GDPR It might also make sense to periodically delete or archive data that is very old to avoid eating up excess database storage space If you would like to view the complete source code for the example used in this tutorial it is available on GitHub Image by Makalu from Pixabay References and Further ReadingHow to use managers in DjangoWhat Are Soft Deletes and How Are They Implemented Soft Deletion in Django |
2021-07-02 19:13:16 |
Apple |
AppleInsider - Frontpage News |
iHome TimeBoost review: doesn't make waking up any easier |
https://appleinsider.com/articles/21/07/02/ihome-timeboost-review-doesnt-make-waking-up-any-easier?utm_medium=rss
|
iHome TimeBoost review doesn x t make waking up any easierThe iHome TimeBoost combines a bedside alarm clock with a wireless charging pad that adds complexity to both with no discernible benefit to the user The iHome TimeBoost struggles to find relevancy in a tech first worldBedside alarm clock radios have been around for decades and iHome hoped to reimagine the concept with wireless charging and a Bluetooth radio These things combined should create a unified device that s easy to use but the TimeBoost missed the mark Read more |
2021-07-02 19:54:52 |
Apple |
AppleInsider - Frontpage News |
FTC charges Broadcom with illegal chip industry monopolization |
https://appleinsider.com/articles/21/07/02/ftc-charges-broadcom-with-illegal-chip-industry-monopolization?utm_medium=rss
|
FTC charges Broadcom with illegal chip industry monopolizationThe FTC believes that Broadcom has illegally used its market power to force manufacturers into contracts and forbidding buyers of its chips from making deals with other competitors Broadcom charged with illegal monopolizationBroadcom is a known Apple supplier that makes components for the iPhone lineup The company is also known for distributing components for television and broadband internet services Read more |
2021-07-02 19:36:05 |
海外TECH |
Engadget |
Bird pilots electric wheelchair and mobility scooter rentals in New York City |
https://www.engadget.com/bird-scootardound-mobility-pilot-nyc-195551820.html?src=rss
|
Bird pilots electric wheelchair and mobility scooter rentals in New York CityWhile Bird is best known for its electric scooters it recently expanded into the bikeshare market and is now also moving into the accessibility space With help from Scootaround a company that specializes in wheelchair and mobility scooter rentals the startup is piloting a new program It s adding a dedicated interface within its app that allows those with mobility issues to reserve and rent one of three different electric vehicles Rentals can vary between one and days in length and you can decide where you want to pick up your ride and drop it off With each rental Bird will provide an in person tutorial to answer any questions you might have about the EV you re about to rent The company will also have a toll free number customers can call to ask about the entire process One of the vehicles Bird will allow people to drive is the Whill Model Ci pictured above We got a chance to test the first Ci variant back at CES driving it across the Vegas show floor at a brisk five miles per hour The program will come first to New York City with other cities to follow throughout depending on how the pilot pans out |
2021-07-02 19:55:51 |
海外TECH |
Engadget |
iPadOS 15 beta preview: Widgets and Quick Notes make for a new experience |
https://www.engadget.com/apple-ipad-os-15-public-beta-preview-191514417.html?src=rss
|
iPadOS beta preview Widgets and Quick Notes make for a new experienceiPadOS is arriving at a crucial time for the iPad Ever since the well designed and overly powerful iPad Pro arrived people have increasingly asked Apple to make its tablet software as flexible and impressive as its hardware This year s iPadOS update isn t going to satisfy those who want the iPad to work more like a Mac ーit still feels like an iPad for better or worse That said Apple has made a handful of significant changes and a host of smaller ones all of which add up to an experience that makes the iPad more customizable and flexible than before while still retaining and improving upon the basic iPad experience There are a lot of new features to unpack and the just released iPadOS public beta is still a work in progress but here are some of the most significant changes to look forward to when the final software arrives this fall Should you install iPadOS But first a note about that beta status Apple s public betas are generally pretty reliable and that s true here too I ve generally been able to use my inch iPad Pro without any issues but apps occasionally crash and throw me to the Home Screen interacting with notifications doesn t always work and there are various other hiccups here and there Examples my cursor doesn t always move to the search field when I summon it and the last few letters of my messages are sometimes cut off when using the app in Slide Over It s nothing deal breaking but it s noticeable particularly when I use my iPad for multiple hours at a time Unless you re extremely curious I d wait for a few more beta versions to be released before giving it a shot unless you can put it on a back up iPad Widgets and Home Screen updatesWith that out of the way let s dig into the new features The most obvious change in iPadOS is that widgets have come to the Home Screen As with last year s iOS iPad users can now pin widgets anywhere they want You can also select which apps you want to show on the Home Screen and stash the rest in the App Library an auto organized place to find everything you ve installed on your iPad Both widgets and the App Library came to the iPhone last year and it was surprising that they didn t arrive on the iPad until now My quot work quot home screen I m glad Apple did this because it makes your iPad s home screens far more customizable than before something sorely needed on a big screen device It took a little work but I ve now hidden the apps I don t use as much in the App Library and now have five home screens curated for work entertainment games and so forth For example my work screen only has six app shortcuts Drive Docs Sheet Trello Slack and LastPass but the variety of widgets I have installed provides glanceable info and easy access to a lot of tools I have a widget showing recent notes in the “work folder another with Reminders also specifically from my work group an Apple News widget showing the latest tech news and widgets for Google Calendar and Gmail All that plus the apps in my dock make this the prime place to go when I need to get things done Quick NotesThe other new feature that could fundamentally change the iPad experience is Quick Notes As Apple s Craig Federighi said during last month s WWDC keynote Notes are now a “system wide feature Swiping in from the lower right corner summons a new note that floats above whatever apps you re using You can quickly type or write down with the Apple Pencil whatever comes to mind and then swipe the note away when you re done Depending on your settings you can start a new note every time you access Quick Notes or just keep adding to the same one Finally you can swipe between Quick Notes you ve started if you want to get to a specific document At the top of this Quick Note is a button that automatically appears to let you save a link to the page you re visiting The iPad s Slide Over multitasking feature offered an approximation of this experience but Quick Notes is far more flexible For starters you can move a Quick Note anywhere on the screen you want making it feel like a true “window reminiscent of something you would use on Windows or macOS If you re going to jump in and out of the same note frequently you can dismiss it to the side of the iPad screen where a little arrow shows that you can summon it back quickly Apple s Quick Note demos mostly focused on using the Apple Pencil to quickly jot things down but it works just as well with a keyboard When I m doing work it s almost always with the Magic Keyboard attached and being able to quickly summon a persistent document to take notes in regardless of what else I was doing makes the iPad feel significantly more versatile It s a great tool when doing research especially since you can add links to web pages in Safari or destinations in Maps with one tap My only real complaint is that the “swipe in from the bottom right gesture is a little awkward especially when using the iPad docked to a keyboard It s much with the Apple Pencil MultitaskingMultitasking was a major focus at WWDC as well While Apple did make some useful changes here the fundamental iPad multitasking experience is still the same Apps can take up the whole screen or share the display with a second app in Split View There s also the Slide Over area which lets you quickly summon a floating window containing another app Apple has made major improvements to these features over the years but they re the same fundamental multitasking options we ve had since iOS back in The tiny multitasking menu can be handy once you know how to use it If you ve been hoping for a true windowed multitasking experience this isn t it But Apple has made it easier to work with the multitasking features it does offer Now there s a tiny three dot menu at the top of every app you use that lets you move the app between full screen slide over and split view As I compose this sentence I m typing in the Notes app full screen If I want to take Notes into Split View and share the screen with Safari I just tap the multitasking menu and hit the Split View icon This gives me a full view of my Home Screen which then lets me pick anything I want to go alongside Notes Being able to quickly choose from any app on your Home Screen when setting up a multitasking view is a big improvement before you primarily had to use search to find the app you want or drag one of the apps available in your dock The menu also makes it a lot easier to move apps between Split View Slide Over and full screen views Previously you had to be aware of a variety of gestures but a few minutes of playing with the multitasking menu makes the behavior pretty clear SafariThe last major change I ll cover at this early stage is Safari It s one of the most important apps on the iPad and it s gotten a lot better in the last few years But for iPadOS Apple has made what I predict will be a polarizing design decision In an effort to slim down the top menu bar Apple crammed the URL bar and open tabs into one row Essentially a tab and its URL bar are now represented by a single visual cue This means that the location of the URL bar moves If you re looking at the right most tab you have open for instance the URL bar is all the way to the right It definitely takes some time to get used to since most of us are used to it always being right in the center of whatever browser we re using This also makes it harder to see all your tabs besides the “active tab I can currently see eight others The rest are hidden off to the left and right of my active tab To see them you ll have to scroll either direction to find what you re looking for Because my active tab is the one furthest to the right the URL bar in my window is also far to the right In this case my active tab is to the far left and so is the URL bar Apple s menu bar cleanup also means it removed the button that zooms out to show you a preview of every tab you have open I used that constantly so I hate this change And unlike on the Mac you can t customize the Safari menu on the iPad at all Now you either have to use a keyboard shortcut or pull up the new sidebar which contains all the open tabs in a window along with your bookmarks reading list history and links shared in Messages Safari on the iPad already did a great job of hiding the menu bar once you started scrolling through a site so this change feels unnecessary to me I ll be curious to see what kind of feedback Apple gets during the beta because I wager plenty of other people will prefer the old layout Safari s new sidebar holds your tab groups as well as usual items like bookmarks and your reading list There is at least one good thing about the new Safari tab groups They re handled elegantly with a button in the sidebar letting you open either a new “blank group for you to populate or taking all your current tabs and saving them as a group You can swap between groups in the sidebar and access any groups you ve created in any open Safari window you have Groups will also sync across your other devices assuming you ve upgraded to iOS or macOS Monterey Having different tab groups for different tasks has already proven useful to me and I ll probably use them even more as I get used to incorporating them into my workflow More to comeThere are plenty of other significant changes to iPadOS things like the new Focus system and notifications revamp improvements to FaceTime and Messages the new Universal Control system that works between a Mac iPhone andiPad and plenty more You can read about some of these changes in our previews of iOS and macOS Monterey We ll be doing a proper review of all the new software in its final form this fall but in the meantime I m going to keep digging into the future beta releases to see how iPadOS changes between now and its wider release |
2021-07-02 19:15:14 |
海外科学 |
NYT > Science |
Zoo Animals Are Getting Experimental Coronavirus Vaccines |
https://www.nytimes.com/2021/07/02/science/zoo-animals-coronavirus-vaccine.html
|
ferrets |
2021-07-02 19:38:02 |
ニュース |
BBC News - Home |
M4 human remains: Area near Swindon searched |
https://www.bbc.co.uk/news/uk-england-wiltshire-57701912
|
police |
2021-07-02 19:47:55 |
ニュース |
BBC News - Home |
Switzerland 1-1 Spain: Spain beat Switzerland on penalties to reach Euros semis |
https://www.bbc.co.uk/sport/football/51198650
|
switzerland |
2021-07-02 19:11:26 |
ニュース |
BBC News - Home |
Euro 2020: Spain beat 10-man Switzerland on penalties to reach semi-finals |
https://www.bbc.co.uk/sport/av/football/57702674
|
Euro Spain beat man Switzerland on penalties to reach semi finalsWatch highlights as Spain beat Switzerland in a thrilling penalty shootout to advance to the semi finals of Euro facing either Belgium or Italy in Wembley |
2021-07-02 19:31:09 |
ニュース |
BBC News - Home |
Determined Djokovic, outstanding outifts & a proper hot dog - day five best bits |
https://www.bbc.co.uk/sport/av/tennis/57702878
|
Determined Djokovic outstanding outifts amp a proper hot dog day five best bitsWatch some of the best bits from day five at Wimbledon including Nick Kyrgios accidentally hitting a ball at Venus Williams and some well dressed spectators |
2021-07-02 19:12:47 |
ニュース |
BBC News - Home |
I had an Indian-made AstraZeneca vaccine, what do I need to know? |
https://www.bbc.co.uk/news/explainers-57665765
|
ability |
2021-07-02 19:19:19 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
200万円の豪華オプションがあるロールス・ロイスのSUVに新オプションが追加! - 男のオフビジネス |
https://diamond.jp/articles/-/275322
|
世界の王 |
2021-07-03 04:55:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
こんなおじさんは嫌だ!令和時代に若者から敬遠される「NG行動」 - 井の中の宴 武藤弘樹 |
https://diamond.jp/articles/-/275753
|
若い世代 |
2021-07-03 04:45:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
渋沢栄一が泣くぞ!みずほ銀行や東芝の不祥事、世間から見えない「被害者」は従業員 - from AERAdot. |
https://diamond.jp/articles/-/275584
|
fromaeradotnhk |
2021-07-03 04:40:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
「萌えキャラ絵馬」やカラフル御朱印をゲットできる長野と山梨の神社 - 地球の歩き方ニュース&レポート |
https://diamond.jp/articles/-/275324
|
地球の歩き方 |
2021-07-03 04:35:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
魚油サプリメントの「オメガ3」が、うつ病の治療に役立つ!? - ヘルスデーニュース |
https://diamond.jp/articles/-/275685
|
alessandraborsini |
2021-07-03 04:30:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
ひろゆきが「会った瞬間に『頭が悪い』と感じる特徴・ワースト1」 - 1%の努力 |
https://diamond.jp/articles/-/275208
|
youtube |
2021-07-03 04:25:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
ヘルシーな食事でも太るのは「糖質が多い意外な食品」のせい - 医者が教えるダイエット 最強の教科書 |
https://diamond.jp/articles/-/275596
|
思い込み |
2021-07-03 04:20:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
松下式「ダム経営」と 収入ゼロでも生き延びる 「無収入寿命」の非常識な関係 - 売上最小化、利益最大化の法則 |
https://diamond.jp/articles/-/273612
|
|
2021-07-03 04:15:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
「自分が作るものに全く満足できなくても、創作を続けるべきか」への超納得の回答 - 独学大全 |
https://diamond.jp/articles/-/273896
|
読書 |
2021-07-03 04:10:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【出口治明学長】 出口学長! 信長・秀吉・家康の部下なら 誰に仕えますか? まるで人が飛び出してきそうな 「人物相関図」秘話 - 哲学と宗教全史 |
https://diamond.jp/articles/-/273074
|
世界史を背骨に日本人が最も苦手とする「哲学と宗教」の全史を初めて体系的に解説した『哲学と宗教全史』がついに万部を突破。 |
2021-07-03 04:05:00 |
コメント
コメントを投稿