Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
[Rails] 複数の小モデルを跨いだor検索 |
https://qiita.com/nosuke_engineer/items/aa9073b572548753987f
|
include |
2022-09-21 21:26:46 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
Rails 7 + ImportmapでFont Awesomeを実装する |
https://qiita.com/gazayas/items/9224b22ce6416a624f33
|
fontawesome |
2022-09-21 21:17:00 |
Git |
Gitタグが付けられた新着投稿 - Qiita |
【Git】特定のコミットまで戻る |
https://qiita.com/SNQ-2001/items/059de738b46d2430678b
|
gitrefl |
2022-09-21 21:30:44 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
[Rails] 複数の小モデルを跨いだor検索 |
https://qiita.com/nosuke_engineer/items/aa9073b572548753987f
|
include |
2022-09-21 21:26:46 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Rails 7 + ImportmapでFont Awesomeを実装する |
https://qiita.com/gazayas/items/9224b22ce6416a624f33
|
fontawesome |
2022-09-21 21:17:00 |
海外TECH |
MakeUseOf |
How to Transfer Apple Music Playlists to Spotify |
https://www.makeuseof.com/how-to-transfer-apple-music-playlists-spotify/
|
spotify |
2022-09-21 12:15:13 |
海外TECH |
DEV Community |
How to use Date-Range in react ? |
https://dev.to/sagarkhadka/how-to-use-date-range-in-react--3h2d
|
How to use Date Range in react Date Range is a npm package that lets us to use and display modern looking calendar window on our website To setup the Date Range following stepsStep First do npm i react date range install the packageStep Import calendar along with its CSS file in the component fileimport Calendar DateRange from react date range import react date range dist styles css main style fileimport react date range dist theme default css theme css fileStep Create a useState for the calendar import React useState from react const date setDate useState startDate new Date endDate new Date Use null if you don t want to have endDate key selection Step We have to also add numbers npm add date fnsStep Add following component with a className to position using CSS Note that props name should be same that we created in step const date setDate useState lt DateRange editableDateInputs true onChange item gt setDate item selection moveRangeOnFirstSelection false ranges date className date gt Step If you want to show the selected date in format import date fns import format from date fns Step To display selected date format date startDate MM dd yyyy to format date endDate MM dd yyy The above method only creates static calendar window If we want to open date range on click then add following code Step Make a useState hook to open and close calendar windowconst openDate setOpenDate useState false Step Wrap date component with openDate amp amp lt DateRange gt and set onClick gt setOpenDate openDate Your final code should look like thisimport React useState from react import DateRange from react date range import react date range dist styles css main style fileimport react date range dist theme default css theme css fileimport format from date fns const Component gt const openDate setOpenDate useState false const date setDate useState startDate new Date endDate new Date key selection return lt div className calendar gt lt span onClick gt setOpenDate openDate gt format date startDate MM dd yyyy to format date endDate MM dd yyy lt span gt openDate amp amp lt DateRange editableDateInputs true onChange item gt setDate item selection moveRangeOnFirstSelection false ranges date className date gt lt div gt export default Header |
2022-09-21 12:14:13 |
海外TECH |
DEV Community |
Tree shaking in Javascript |
https://dev.to/milekag01/tree-shaking-in-javascript-2po4
|
Tree shaking in JavascriptJavaScript is an expensive resource to process It needs to be parsed compiled and then finally executed This makes JavaScript more expensive to process There are techniques to improve JavaScript performance Code splitting is one such technique that helps in improving performance by partitioning JavaScript into chunks and serving those chunks to only the routes of an application that need them Though this technique works it doesn t address a common problem of JavaScript heavy applications which is the inclusion of code that s never been used Tree shaking helps in solving this problem Tree shaking is a method of optimising our code by eliminating any code from the final bundles that isn t actually being used Let s say we have a stringUtils js file with some operations we may want to use in our main script export function capitaliseFirstLetter word return word charAt toUpperCase word slice export function getInitials name if name return name split map n gt n join return export function truncateString string len const truncatedString string substring len return truncatedString In our main script we may only ever import and use the truncateString function import truncateString from stringUtils truncateString sample string After the bundling we will see that all functions from the file are included in the final bundle even though we only imported and used the truncateString function But with tree shaking enabled only what is imported and actually used will make it to the final bundle Although the concept of tree shaking has been around for a while it has only been able to work with Javascript since the introduction of ES style modules This is because tree shaking works iff the modules are static Before going forward let s get some understanding on static and dynamic modules When you use a module as static module you are instantiating and using it for across the application So even though a component might not be using it there is still some performance cost associated with it because anytime we try to access that the namespace of that module will be available Dynamic module imports are very similar to static module imports but the code is loaded only when it is needed instead of being loaded instantly Before the introduction of ES modules we had CommonJS modules which used the require syntax to import the modules These modules are dynamic meaning that we are able to import new modules based on conditions in our code var myDynamicModule if condition myDynamicModule require foo else myDynamicModule require bar The dynamic nature of the CommonJS modules meant that tree shaking couldn t be applied because it would be impossible to determine which modules will be needed before the code actually runs In ES a completely new syntax for modules was introduced which is entirely static Using the import syntax we cannot dynamically import a module We need to define all imports in the global scope outside of any conditions This new syntax allows for effective tree shaking as any code that is used from an import can be determined even before running the code Tree shaking in most of the good code bundlers is pretty good at eliminating as much unused code as possible For example modules that are imported but not used are eliminated Some libraries also suggest to use the submodules for imports instead of the module which prevents the bundling of unused code Here is one such example from vueuse Though tree shaking helps to eliminate the unused code but it doesn t solve the problem of unused code entirely Things to consider while using Tree shaking Tree shaking cannot tell on its own which scripts are side effects so it s important to specify them manually Side effect is a code that performs some action when imported but not necessarily related to any export A very good example of a side effect is polyfill Polyfills typically don t provide an export but rather added to the project as a whole Tree shaking is typically implemented via some code bundler Each code bundler has a different way of enabling tree shaking If you re using webpack you can simply set the mode to production in your webpack config js configuration file This will among other optimisations enables tree shaking module exports mode production To mark any file as side effect we need to add them to our package json file sideEffects src polyfill js Modules that are being used as side effects cannot be tree shaken because they don t have imports and exports But it is not important to be a module to have side effects Take the following code as an example src sideEffect jsexport const foo foo const sideEffectFn text gt fetch api return text export const bar sideEffectFn Hello src index jsimport foo from sideEffect console log foo The bar variable will trigger a side effect as it is initialised Webpack will realise this and will include the side effect code in the bundle even though we aren t using bar at all In this article we covered tree shaking in general example of its usage using Webpack and how to make common patterns tree shakable I hope this article helped all of us understand tree shaking easily To learn more visit the MDN docs Love reading about Javascript Web optimisations Vue js React and Frontend in general Stay tuned for more Wanna connect You can find me on LinkedIn Twitter GitHub |
2022-09-21 12:09:04 |
海外TECH |
DEV Community |
Javascript Proxy: Introduction |
https://dev.to/milekag01/javascript-proxy-introduction-68k
|
Javascript Proxy IntroductionJS is not truly an Object Oriented Programming language Therefore fulfilling requirements such as Enforcing object property value validation during read and write and take action defining a property as private and detecting changes in values can be challenging There are ways of solving the above stated problems such as by using a setter or getter to set default value or throw an error on validation checks However the more convenient way to handle these problems is by using the Proxy object Proxies are one of the hidden gems in Javascript that many developers do not know of The Proxy object is a virtualising interface that allows us to control the behaviour of the object It allows us to define custom behaviour for the basic operations of an object Let s take an example to understand proxy in a better way Let us consider an item as shown below let item id name Stock price We want to sell this item but the condition is that the selling price should not be less than At the same time we want to put a check in place that throws the error if we try to read the value of a property that does not exist Also we want to define id as private property We can easily solve this problem by writing custom logic while performing get set or property lookup JS Proxy object exactly helps here It allows us to add custom behaviour to the fundamental operations on a JS object To create a proxy object we use the Proxy constructor and pass two parameters target and handler in it Defining a Proxy object let proxy new Proxy target handler Target is the object which is virtualised using Proxy and adds custom behaviour to it Here item object is the target Handler is the object in which we define the custom behaviour The handler object container the trap Traps are the methods that gives access to the target object s property to the handler object Traps are optional If trap is not provided target object s default methods are used There are different types of traps such as get set has isExtensible defineProperty etc You can use all of these traps in the handler to define the custom behaviour for target object let item id name Stock price let handler check while setting the value set function obj prop value if prop price if Number isInteger value throw new TypeError Value passed is not a number if value lt obj prop return true obj prop value return true check for no access to id check for property which does not exist get function obj prop if prop id throw new Error Cannot access private property id else return prop in obj obj prop new TypeError prop property does not exist var itemProxy new Proxy item handler Let s understand the code We created a proxy called itemProxy using the Proxy constructor and passed the item and handler to it Using the get trap in the handler we are checking if the property exists in the object or not Also we have enforced id as private property and made it inaccessible Using the set trap in the handler we are checking if the property passed is price if the value being passed to assign is an integer and also we are putting a modifier to assign the value by default if the price is less than console log itemProxy price itemProxy price console log itemProxy price In a similar manner we can define handlers to detect changes to the value of object properties which we will discuss some other time I hope this article helped all of us understand Proxies To learn more visit the MDN docs Love reading about Javascript Web optimisations Vue js React and Frontend in general Stay tuned for more Wanna connect You can find me on LinkedIn Twitter GitHub |
2022-09-21 12:05:49 |
海外TECH |
Engadget |
This is how close LG's Rollable was to being a real phone |
https://www.engadget.com/lg-rollable-hands-on-122505508.html?src=rss
|
This is how close LG x s Rollable was to being a real phoneLG was supposed to release another phone with an unusual form factor after The Wing as an answer to Samsung s foldables At CES the company confirmed that it was working on a phone with a rollable display and that it was going to be available later that year It never got to launch the device before shutting down its mobile business after its newest models which included the Wing failed to gain traction But now a hands on video by Korean tech reviewer 뻘짓연구소 BullsLab shows just how close LG got to launching the phone that would ve simply gone by the name quot Rollable quot While the Wing featured a rotatable display on top of a smaller one underneath the Rollable was designed to have a screen that stretches out until the phone becomes a small tablet In the video you ll see how responsive the device is and how quickly it starts expanding after the YouTuber swipes at the screen with three fingers Whatever s displayed on screen ーeven the animated wallpapers ーautomatically adjusts itself At one point the reviewer places three books beside the phone to show that its motor is strong enough to move the pile as it stretches out In addition to the stretchable main display the phone s back panel also functions as an extra screen that can house a handful of widgets including ones for the camera calendar and music If you fire up the camera app from that extra screen you ll be able to take selfies without powering on the main phone nbsp Based on the device BullsLab reviewed the Rollable would ve launched with a Snapdragon CPU up to GB of RAM and GB of storage Those were top level specs that would ve put the Rollable in the same category as flagships such as the Samsung Galaxy S nbsp Since LG s mobile business no longer exists there s little to no chance for the Rollable to well roll out It s worth noting that Oppo also showed off a rollable phone back in but it was just a prototype and we haven t heard anything about it since then |
2022-09-21 12:25:05 |
海外TECH |
Engadget |
TikTok adds new rules for politicians' accounts ahead of the midterm elections |
https://www.engadget.com/tiktok-politician-accounts-verification-fundraising-120040969.html?src=rss
|
TikTok adds new rules for politicians x accounts ahead of the midterm electionsTikTok is adding new rules for accounts belonging to politicians government officials and political parties ahead of the midterm elections The company says it will require these accounts to go through a “mandatory verification process and will restrict them from accessing advertising and other revenue generating features Up until now verification for politicians and other officials was entirely optional But that s now changing at least in the United States as TikTok gears up for the midterm elections this fall In a blog post the company says the update is meant to help it enforce its rules which bar political advertising of any kind more consistently By verifying their accounts TikTok will be able to block politicians and political parties from accessing the platform s advertising tools or other revenue generating features like tipping Accounts will also be barred from payouts from the company s creator fund and from in app shopping features TikTok says it also plans to add further restrictions that will prevent politicians and political parties from using the platform to solicit campaign contributions or other donations even on outside websites That policy which will take effect “in the coming weeks will bar videos that direct viewers to third party fundraising sites It also means that politicians will not be allowed to post videos asking for donations The new policies are the latest piece of TikTok s strategy to prepare for the midterm elections The company already began rolling out an in app Elections Center to highlight voting resources and details about local races But enforcing its ban on political ads has proved to be challenging for TikTok which has had to contend with undisclosed branded content from creators The new rules don t address that issue specifically but the added restrictions for campaigns and politicians will make it more difficult for candidates and other officials to evade its rules |
2022-09-21 12:00:40 |
海外科学 |
BBC News - Science & Environment |
School uniforms in N America linked to PFAS "forever chemicals" |
https://www.bbc.co.uk/news/science-environment-62982397?at_medium=RSS&at_campaign=KARANGA
|
health |
2022-09-21 12:11:12 |
医療系 |
医療介護 CBnews |
診療科別の医師偏在指標、次期確保計画で見送りへ-厚労省方針、「現時点で困難」 |
https://www.cbnews.jp/news/entry/20220921193511
|
都道府県 |
2022-09-21 21:05:00 |
金融 |
RSS FILE - 日本証券業協会 |
会長記者会見−2022年− |
https://www.jsda.or.jp/about/kaiken/kaiken_2022.html
|
記者会見 |
2022-09-21 13:30:00 |
ニュース |
BBC News - Home |
Business energy prices to be cut by half expected levels |
https://www.bbc.co.uk/news/business-62969427?at_medium=RSS&at_campaign=KARANGA
|
october |
2022-09-21 12:45:26 |
ニュース |
BBC News - Home |
Energy bills: New law will force landlords to pass on £400 rebate |
https://www.bbc.co.uk/news/uk-politics-62978908?at_medium=RSS&at_campaign=KARANGA
|
bills |
2022-09-21 12:14:51 |
ニュース |
BBC News - Home |
Inflation pushes UK debt interest costs to August record |
https://www.bbc.co.uk/news/business-62977832?at_medium=RSS&at_campaign=KARANGA
|
august |
2022-09-21 12:07:02 |
ニュース |
BBC News - Home |
Putin warning: What does Russian military call-up mean for Ukraine? |
https://www.bbc.co.uk/news/world-europe-62981289?at_medium=RSS&at_campaign=KARANGA
|
mobilisation |
2022-09-21 12:09:39 |
ニュース |
BBC News - Home |
England v India: Kate Cross dismisses Shafali Verma with 'beautiful delivery' |
https://www.bbc.co.uk/sport/av/cricket/62984165?at_medium=RSS&at_campaign=KARANGA
|
England v India Kate Cross dismisses Shafali Verma with x beautiful delivery x Watch as England s Kate Cross bowls a beautiful delivery to dismiss India s Shafali Verma for eight runs in the second ODI at The Spitfire Ground in Canterbury |
2022-09-21 12:36:37 |
北海道 |
北海道新聞 |
10増10減など18本程度提出 政府法案、臨時国会 |
https://www.hokkaido-np.co.jp/article/734450/
|
臨時国会 |
2022-09-21 21:27:00 |
北海道 |
北海道新聞 |
国際バカロレア認定校に 札幌のこども園あいの里 道内初 |
https://www.hokkaido-np.co.jp/article/734448/
|
国際バカロレア |
2022-09-21 21:26:00 |
北海道 |
北海道新聞 |
十勝管内90人感染 新型コロナ |
https://www.hokkaido-np.co.jp/article/734446/
|
十勝管内 |
2022-09-21 21:24:00 |
北海道 |
北海道新聞 |
独政府、エネルギー大手を国有化 1兆円注入、ロシア産ガス減で |
https://www.hokkaido-np.co.jp/article/734441/
|
天然ガス |
2022-09-21 21:22:00 |
北海道 |
北海道新聞 |
空知管内149人感染 新型コロナ |
https://www.hokkaido-np.co.jp/article/734440/
|
空知管内 |
2022-09-21 21:22:00 |
北海道 |
北海道新聞 |
「国葬反対」 札幌で市民団体がデモ行進 |
https://www.hokkaido-np.co.jp/article/734437/
|
市民団体 |
2022-09-21 21:20:00 |
北海道 |
北海道新聞 |
東藻琴の小河さん、全国女子相撲へ 中学進学で引退…今夏、土俵に復帰の16歳 |
https://www.hokkaido-np.co.jp/article/734436/
|
北見商科高等専修学校 |
2022-09-21 21:17:00 |
北海道 |
北海道新聞 |
通園バス、安全装置を義務化 置き去り防止で警報ブザー |
https://www.hokkaido-np.co.jp/article/734435/
|
置き去り |
2022-09-21 21:16:00 |
北海道 |
北海道新聞 |
マイナカード低迷なら交付金ゼロ 自治体に「全国平均以上」要求 |
https://www.hokkaido-np.co.jp/article/734434/
|
要求 |
2022-09-21 21:16:00 |
北海道 |
北海道新聞 |
宮城沿岸のクチバシカジカは固有種 北大水産実験所長ら発表 函館の撮影者名を学名に |
https://www.hokkaido-np.co.jp/article/734425/
|
臼尻 |
2022-09-21 21:12:00 |
北海道 |
北海道新聞 |
バングラ邦人殺害、4被告に死刑 高裁判決、1人は無罪 |
https://www.hokkaido-np.co.jp/article/734421/
|
高裁 |
2022-09-21 21:05:00 |
IT |
週刊アスキー |
最新作『Grim Guardians: Demon Purge』が試遊できた「インティ・クリエイツ」ブース【TGS2022】 |
https://weekly.ascii.jp/elem/000/004/106/4106275/
|
grimguardiansdemonpurge |
2022-09-21 21:15:00 |
海外TECH |
reddit |
This subreddit can be toxic if you are not American |
https://www.reddit.com/r/japanlife/comments/xk3076/this_subreddit_can_be_toxic_if_you_are_not/
|
This subreddit can be toxic if you are not AmericanI have lived in Japan for several years but I only started mingling with expat groups and Reddit more recently due to COVID lockdowns I am British of Indian ancestry I find that a lot of the complaints are due to cultural differences between the US and Japan but this subreddit seems to take the view that the American cultural practices are superior and often the complaints can apply against other countries as well For example The gaijin seat is more to do with presentation in my opinion I have rarely been subject to the gaijin seat in the past and it is basically non existent now I often come across other foreigners white asian indian who complain about this stuff and even I think that they look weird in the UK it is often drilled into you that presentation is important If a lot of these gaijin cared more about appearance then I think they would suffer from the gaijin seat less This would be a normal viewpoint in much of Britain but I think it is considered unusual from an American perspective Similarly a lot of the complaints about social etiquette and socialising seem to be cultural differences as well It s common in both London and Paris to not invite friends over to your home because a lot of people live in quot bedtowns quot or tiny apartments where you sleep only If you have lived in London then Tokyo would not be quot emotionally cold quot for you and you would know how to navigate the social scene I also think that different cultures have different ideas of what a friend is so people have different expectations of when a person becomes a friend I personally find that socialising is normal in Japan and that making friends to no different to places like the UK Being polite and being very indirect are normal aspects of British culture as well so I find the social culture of Japanese really quot normal quot and these aspects of Japanese culture that people on this subreddit complain about actually helps me to socialise better And on a similar line of thought on Korea and Osaka people who say that Koreans are easier to make friends with forget that a lot of Koreans want to live overseas and similarly there is a small bar club area right in the centre of Osaka where Japanese people who like America will hang out these people are no different to the quot gaijin hunter quot Japanese and I think it is more a sign of Americans who who have never had to deal with multiple cultures In the UK the ethnic minorities will integrate with the white people like a melting pot so everyone is used to making good friends across severe cultural differences so an Indian may have Whites and Asians as best friends whereas in America there seems to be more racial and cultural segregation judging from my conversations with American expats Basically the point is that this subreddit can often attack quot negatives quot about Japan which are just cultural differences and these cultural differences can apply to other cultures as well I find that this subreddit is a vicious cycle of anti Japan sentiment I think it might be harder for Americans to integrate and make friends in Japan but that does not mean that Japanese culture is wrong submitted by u Significant Side to r japanlife link comments |
2022-09-21 12:03:19 |
コメント
コメントを投稿