IT |
ITmedia 総合記事一覧 |
[ITmedia News] ロシア人にウクライナに関する西側情報を送るSquad303の人海プロジェクト 700万件以上送信 |
https://www.itmedia.co.jp/news/articles/2203/13/news035.html
|
itmedia |
2022-03-13 08:31:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Problem 96: 数独 |
https://qiita.com/masa0599/items/523c48de198605687a1c
|
数独はこれをtimesにしてtimesのマスのルールを足したものなので、以下のようなコードになります。 |
2022-03-13 08:52:30 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Rails6でJavaScriptの動的読み込み |
https://qiita.com/jibiking/items/321c8b057305d85a3063
|
RailsでJavaScriptの動的読み込み実現したいことJavaScript内からDB内のデータを動的に読み込みたい開発環境Rails系Ruby系アプリMuscleBeatスマホ専用筋トレ系音ゲーGitHubテーブル例↓結論view内のscriptタグにerbタグを用いて動的に読み込ませたいJSを記載しますたしかにRails系のJavaScriptの記述はappjavascriptpacks以下にするのが通常です。 |
2022-03-13 08:48:27 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Railsでphina.jsの動的読み込み |
https://qiita.com/jibiking/items/61ab0f310976273a1b0f
|
Railsでphinajsの動的読み込み実現したいことバックエンドRailsから保存したDB内のデータを呼び出して、動的にフロントphinajsに入れて、ゲームをプレイできるようにするphinajsとはゲームを簡単に作ることのできるJavaScriptのライブラリ開発環境Rails系Ruby系phinajsCDNアプリMuscleBeatスマホ専用筋トレ系音ゲーGitHubテーブル例↓viewでphinajsの環境構築ゲームプレイ画面を作成するviewにCDNでphinajsを読み込ませます。 |
2022-03-13 08:30:56 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
Rails6でJavaScriptの動的読み込み |
https://qiita.com/jibiking/items/321c8b057305d85a3063
|
RailsでJavaScriptの動的読み込み実現したいことJavaScript内からDB内のデータを動的に読み込みたい開発環境Rails系Ruby系アプリMuscleBeatスマホ専用筋トレ系音ゲーGitHubテーブル例↓結論view内のscriptタグにerbタグを用いて動的に読み込ませたいJSを記載しますたしかにRails系のJavaScriptの記述はappjavascriptpacks以下にするのが通常です。 |
2022-03-13 08:48:27 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
Railsでphina.jsの動的読み込み |
https://qiita.com/jibiking/items/61ab0f310976273a1b0f
|
Railsでphinajsの動的読み込み実現したいことバックエンドRailsから保存したDB内のデータを呼び出して、動的にフロントphinajsに入れて、ゲームをプレイできるようにするphinajsとはゲームを簡単に作ることのできるJavaScriptのライブラリ開発環境Rails系Ruby系phinajsCDNアプリMuscleBeatスマホ専用筋トレ系音ゲーGitHubテーブル例↓viewでphinajsの環境構築ゲームプレイ画面を作成するviewにCDNでphinajsを読み込ませます。 |
2022-03-13 08:30:56 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
運用が楽なQuickSightダッシュボードを作る_5(データセット自動更新編) |
https://qiita.com/a_b_/items/05ec75a1034dbca31cf4
|
これらを省くため、対象のフォルダに変更ファイルの追加、削除があったら、自動でデータセット更新処理を実行する、という仕組みを入れてみました。 |
2022-03-13 08:30:49 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Rails6でJavaScriptの動的読み込み |
https://qiita.com/jibiking/items/321c8b057305d85a3063
|
RailsでJavaScriptの動的読み込み実現したいことJavaScript内からDB内のデータを動的に読み込みたい開発環境Rails系Ruby系アプリMuscleBeatスマホ専用筋トレ系音ゲーGitHubテーブル例↓結論view内のscriptタグにerbタグを用いて動的に読み込ませたいJSを記載しますたしかにRails系のJavaScriptの記述はappjavascriptpacks以下にするのが通常です。 |
2022-03-13 08:48:27 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Railsでphina.jsの動的読み込み |
https://qiita.com/jibiking/items/61ab0f310976273a1b0f
|
Railsでphinajsの動的読み込み実現したいことバックエンドRailsから保存したDB内のデータを呼び出して、動的にフロントphinajsに入れて、ゲームをプレイできるようにするphinajsとはゲームを簡単に作ることのできるJavaScriptのライブラリ開発環境Rails系Ruby系phinajsCDNアプリMuscleBeatスマホ専用筋トレ系音ゲーGitHubテーブル例↓viewでphinajsの環境構築ゲームプレイ画面を作成するviewにCDNでphinajsを読み込ませます。 |
2022-03-13 08:30:56 |
海外TECH |
DEV Community |
JavaScript Constants With Object.freeze() |
https://dev.to/bytebodger/javascript-constants-with-objectfreeze-4beg
|
JavaScript Constants With Object freeze This is a dead simple observation that I wanted to write about because I almost never see this technique used in the wild Nearly every programmer is familiar with the idea of a constant I m not talking about the const keyword in JavaScript I m talking about the all purpose concept of having a variable that is set once and only once because once it s set that variable s value should never change In other words its value should remain constant The most common way to do this with modern JavaScript is like so const SALES TAX ALABAMA const SALES TAX FLORIDA const SALES TAX LOUISIANA Once these variable are instantiated with the const keyword any attempt to reassign them will result in a runtime error And this approach works but it can be a bit bulky In every script where you want to leverage these variables you would need to define them all upfront And that approach would be unwieldy if these variables are used throughout your codebase With modern JavaScript an alternate approach would be to export these values from a single file That approach would look like this constants jsexport const SALES TAX ALABAMA export const SALES TAX FLORIDA export const SALES TAX LOUISIANA This makes our constants universal and far more accessible throughout our app But I would argue that this is still somewhat bulky Because every time we want to use any one of these variables inside another file each variable must be brought into that file with an import I also find this approach clunky because it doesn t always play nice with the autocomplete feature in our IDEs How many times have you been coding when you realize that you need to leverage a constant like the ones shown above But you don t remember off the top of your head exactly how those variables are named So you start typing ALA expecting to see the Alabama Sales Tax rate constant pop up But your IDE provides no help in autocompleting importing the value because there is no constant that begins with ALA So after you make a few more misguided attempts to pull up the value by typing the name from memory you eventually give up and open the constants js file so that you can read through the whole dang file for yourself to see exactly how those variables are named Objects To The Rescue This is why I love using JavaScript objects to create namespace conventions In fact I wrote an entire article about it You can read it here When you save your values as key value pairs inside an object your IDE becomes much more powerful As soon as you type the initial name of the object and then type nearly any modern IDE will helpfully pull up all of the potential keys that exist inside that object This means that you can restructure your constants file to look like this constants jsexport const CONSTANT SALES TAX ALABAMA FLORIDA LOUISIANA This supercharges your IDE s autocompletion feature But it comes with a downside Because in JavaScript an object that s been defined with the const keyword isn t really a constant With the example above the following code will throw a much needed runtime error import CONSTANT from constants CONSTANT Foo It throws a runtime error because CONSTANT is defined with the const keyword and we cannot re assign its value once it s been set However this does not protect the contents of the object from being re assigned So the following code will NOT throw a runtime error import CONSTANT from constants CONSTANT SALES TAX ALABAMA That s really not very helpful is it After all if any coder working in any other part of the codebase can re assign the value of a constant at will then it s really not a constant at all Object freeze To The Rescue This is why I use Object freeze on all of my constants And it s a simple technique that I ve rarely ever seen outside of my own code The revised code looks like this constants jsexport const CONSTANT Object freeze SALES TAX Object freeze ALABAMA FLORIDA LOUISIANA Now if we try to run this code it will throw a runtime error import CONSTANT from constants CONSTANT SALES TAX ALABAMA Granted this is somewhat verbose because you need to use Object freeze on every object even those that are nested inside of another object In the example above if you don t freeze the SALES TAX object you will still be able to reassign its values A Better ApproachI already know that some devs won t like this approach because they won t like having to use Object freeze on every layer of objects in the constants js file And that s fine There s room here for alternative styles But I firmly prefer this method for a couple of simple reasons A Single Constants FileYou needn t use Object freeze if you want to maintain a single constants js file You can just revert to the traditional way of doing things like this constants jsexport const SALES TAX ALABAMA export const SALES TAX FLORIDA export const SALES TAX LOUISIANA But I can tell you from decades of experience that it s not too uncommon to open a universal constants js file that has hundreds of variables defined within it When this happens I often find something like this constants jsexport const SALES TAX ALABAMA export const SALES TAX FLORIDA export const SALES TAX LOUISIANA hundreds upon hundreds of other constants defined in this file export const ALABAMA SALES TAX You see what happened there The file grew to be so large and the naming conventions were so ad hoc that at some point a dev was looking for the Alabama sales tax value didn t find it and then created a second variable with an entirely different naming convention for the same value This leads me to my second point Objects Promote a Taxonomic Naming StructureSure it s possible for a lazy dev to still define the value for the Alabama sales tax rate twice in the same file Even when you re using objects to hold those values in a taxonomic convention But it s much less likely to happen Because when you re perusing the existing values in the constants js file it s much easier to see that there s already an entire section devoted to sales tax rates This means that future devs are much more likely to find the already existing value And if that value doesn t already exist in the file they re much more likely to add the value in the correct taxonomic order This also becomes much more logical when searching through those values with our IDE s autocomplete function As soon as you type CONSTANTS your IDE will show you all of the sub layers under the main CONSTANTS object and it will be much easier to see right away that it already contains a section dedicated to sales tax rates Objects Allow For Variable Key NamesImagine that you already have code that looks like this const state getState shoppingCartId If your naming conventions for constants looks like this constants jsexport const ALABAMA SALES TAX There s then no easy way to dynamically pull up the sales tax rate for state But if your naming convention for constants looks like this constants jsexport const CONSTANT Object freeze SALES TAX Object freeze ALABAMA FLORIDA LOUISIANA Then you can do this import CONSTANTS constants const state getState const salesTaxRate CONSTANT SALES TAX state |
2022-03-12 23:40:40 |
ニュース |
@日本経済新聞 電子版 |
最恵国待遇とは WTO、通商・関税を平等に
#日経きょうのことば
https://t.co/p2l1eeTc9a |
https://twitter.com/nikkei/statuses/1502785322006061061
|
最恵国待遇 |
2022-03-12 23:15:15 |
北海道 |
北海道新聞 |
コンサドーレ、初白星スルリ ラストワンプレーで同点許す |
https://www.hokkaido-np.co.jp/article/656244/
|
目前 |
2022-03-13 08:19:18 |
北海道 |
北海道新聞 |
「楽しい9年間だった」 コンサドーレ野々村会長がラストゲーム |
https://www.hokkaido-np.co.jp/article/656214/
|
野々村芳和 |
2022-03-13 08:19:03 |
北海道 |
北海道新聞 |
IOC、ウクライナ支援2千万円 選手退避や医療で |
https://www.hokkaido-np.co.jp/article/656272/
|
国際オリンピック委員会 |
2022-03-13 08:10:00 |
北海道 |
北海道新聞 |
菊池雄星、ブルージェイズと合意 3年契約、年俸総額42億円 |
https://www.hokkaido-np.co.jp/article/656257/
|
大リーグ |
2022-03-13 08:01:03 |
ビジネス |
東洋経済オンライン |
日本人がしがみつく「東京モデル」の悲しい結末 河合雅司×牧野知弘「人口減少で仕事はどうなる」 | リーダーシップ・教養・資格・スキル | 東洋経済オンライン |
https://toyokeizai.net/articles/-/537226?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
人口減少 |
2022-03-13 09:00:00 |
コメント
コメントを投稿