IT |
ITmedia 総合記事一覧 |
[ITmedia PC USER] Fire TVやタブレット、Echoシリーズがお得! Amazonが「タイムセール祭り」を4月26日まで開催 |
https://www.itmedia.co.jp/pcuser/articles/2204/24/news032.html
|
amazon |
2022-04-24 14:30:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Blenderで虹を作る |
https://qiita.com/SaitoTsutomu/items/4ff1e6c1bb9a34a8128b
|
blender |
2022-04-24 14:57:14 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
フリースタイル用の音楽自動生成[AIビートメイカー] |
https://qiita.com/Ringa_hyj/items/10143f291ca05d8f98b2
|
音楽 |
2022-04-24 14:50:42 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Error の cause オプションによってエラーの再 throw 時にスタックトレースが失われるのを防ぐ【ES2022】 |
https://qiita.com/yamadashy/items/8f7455fb4d900853b60b
|
tryconstuserawaitfet |
2022-04-24 14:26:47 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Angularの学習環境を構築する |
https://qiita.com/829yasubee/items/ec1e87d4aa1ec231a60d
|
angular |
2022-04-24 14:12:56 |
Git |
Gitタグが付けられた新着投稿 - Qiita |
Gitを使ってデータを外付けHDDで管理及び持ち運びメモ【MAC/Win10】 |
https://qiita.com/idler/items/8836c75655d048be2910
|
bitbucket |
2022-04-24 14:45:41 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
minitestでE2Eテストをする |
https://qiita.com/suruseas/items/91177806910fb756a9f9
|
dockercompose |
2022-04-24 14:22:56 |
海外TECH |
DEV Community |
7 More Killer One-Liners in JavaScript |
https://dev.to/ruppysuppy/7-more-killer-one-liners-in-javascript-2gf8
|
More Killer One Liners in JavaScriptThis is a continuation of the previous list of javascript one liners If you haven t checked out the article you are highly encouraged to accomplish so Let s crack on with the new list Sleep FunctionJavaScript has NO built in sleep function to wait for a given duration before continuing the execution flow of the code Luckily generating a function for this purpose is straightforwardconst sleep ms gt new Promise resolve gt setTimeout resolve ms Go Back to the Previous PageNeed to send the user back to the page they came from history object to the rescue const navigateBack gt history back Orconst navigateBack gt history go Compare ObjectsJavascript behaves in mysterious ways when comparing objects Comparing objects with the operator checks only the reference of the objects so the following code always returns false const obj a b const obj a b obj obj falseTo solve this very issue you can create a deep comparison function const isEqual a b gt JSON stringify a JSON stringify b examplesisEqual a b a b trueisEqual a b a b false works with arrays tooisEqual trueisEqual false Generate Random idNeed multiple unique identifiers but not looking to add the uuid package Try out this simple utility function const uuid gt e e e e e replace g c gt c crypto getRandomValues new UintArray amp gt gt c toString NOTE The function is a one liner but spread across multiple lines for readability Get Selected TextWant to have access to the text user selects window just has a method to help you out const getSelectedText gt window getSelection toString Check if an Element is FocusedYou can effortlessly check if an element is currently focused without setting up the focus amp blur listener const hasFocus element gt element document activeElement Count by the Properties of an Array of ObjectsNeed to count the number of items in an array that match a particular property Using reduce on arrays can achieve the task with ease const countElementsByProp arr prop gt arr reduce prev curr gt prev curr prop prev curr prop prev examplecountElementsByProp manufacturer audi model q year manufacturer audi model rs year manufacturer ford model mustang year manufacturer ford model explorer year manufacturer bmw model x year manufacturer audi ford bmw NOTE This too is a one liner but spread across multiple lines for readability That s all folks Research says writing down your goals on pen amp paper makes you to more likely to achieve them Check out these notebooks and journals to make the journey of achieving your dreams easier Thanks for readingNeed a Top Rated Front End Development Freelancer to chop away your development woes Contact me on UpworkWant to see what I am working on Check out my Personal Website and GitHubWant to connect Reach out to me on LinkedInI am a freelancer who will start off as a Digital Nomad in mid Want to catch the journey Follow me on InstagramFollow my blogs for Weekly new Tidbits on DevFAQThese are a few commonly asked questions I get So I hope this FAQ section solves your issues I am a beginner how should I learn Front End Web Dev Look into the following articles Front End Development RoadmapFront End Project Ideas |
2022-04-24 05:33:47 |
海外TECH |
DEV Community |
Introduction to Regex |
https://dev.to/yohanesss/introduction-to-regex-1pmj
|
Introduction to RegexHave you ever created a password and there we were asked to use capital letters numbers and symbols And if so how could we do it Are we gonna split the input string and then check for each character if all the criteria is matched Let s see the implementation below for validating password function validatePassword input list of special character let specialChars amp lt gt const validLength input length gt true false let validCapital false let validNumber false let validSpecialChar false const isSpecialCharacter char gt specialChars includes char const isCapitalcase char gt char toUpperCase char const isNumber char gt includes parseInt char const input input split input forEach input gt if isNumber input validNumber true if isSpecialCharacter input validSpecialChar true if isNumber input amp amp isSpecialCharacter input amp amp isCapitalcase input validCapital true if validLength amp amp validCapital amp amp validNumber amp amp validSpecialChar return true else console log error creating password return false It s complex right Lo and behold the power of regexfunction validatePasswordRegex input return d a z A Z test input Our code will become so much clearer in an instant and in so mysterious way Worry not I will give you an introduction about regex in this article Regex stands for Regular Expression and it is basically an easy way to define a pattern of text Regex is often used for input validation or text identification At first glance Regex is like a gibberish text However for those who know how to use it it will be one of powerful tools in their disposal I have listed some commonly used tokens in Regex to help us TokensRepresent dAny Digit DAny Non digit character Any Character Period abc Only a b or c abc Not a b nor c a z Characters a to z Numbers to wAny Alphanumeric character WAny Non alphanumeric character m m Repetitions m n m to n Repetitions Zero or more repetitions One or more repetitions Optional character sAny Whitespace SAny Non whitespace character … Starts and ends … Capture Group a bc Capture Sub group Capture all abc def Matches abc or defFirst thing to note when we are using regex everything is a character and we are writing patterns to match a specific sequence pattern alphabet abc abc test abcd match abc test abc match abc test abcde match Look at the example above abc is our pattern we are done our first regex It s as simple as the common letters on each line number test bgh match test const number match test match We can see which is number is also treated as character in regex dot test asd a match test skip test s match dot operator in regex is also known as a wildcard because it can match any character However in the example above we can use to actually specify the dot to be in our pattern brackets asdf FfR oot test Foot match FfR oot test Root match FfR oot test foot match FfR oot test Moot skip While the metacharacter is pretty powerful to match all the character we need to somehow add a boundary to match to specific characters We could do that by using brackets notation In our example we use FfR as our pattern therefore only F f or R letter will be match and nothing else inverse within brackets FfR oot test Moot match FfR oot test Boot match FfR oot test Foot skip We also could use an inverse within brackets to excluding specific characters if there is any character in our test that are same as the characters inside our brackets it will be not match Character ranges A D c h b e test Ade match A D c h b e test Dfd match A D c h b e test Erd skip We can specify a range of sequential characters by using the dash within brackets to indicate a character range We could specify a digit or even with inverse notation a f Notice that a z lowercase and A Z uppercase are different so make sure we put it both if we want all the alphabets to be match A Za z this pattern is equivalent for w which stands for match for any alphanumeric characters And W can be used to specify non alphanumeric characters Curly brace repetitions hel o test helllo match hel o test hello skip hel o test hellllllo match hel o test hello skip We can speficy a number of repetitions for a character we want to match by using a b where a is a minimal number of repetitions and b is maximum number of repetitions If b is not specified then the repetitions must be exactly same as a In our example we specify hel o which means l character must be repeated times to be match otherwise it will be not match hel o means l character must be repeated between until to be match Plus and star quantifier o l m test ooolllmm match o l m test ooomm match o l m test mmm skip o l m test mmm match How can we match the character to be at least or more character that it follows Meet the plus quantifier There are also star quantifier which can be used to represents either or more of the character that it follows Question Mark optional d files is found test file is found match d files is found test files is found match d files is found test No files is found skip In the example above we could give our pattern more flexibility by specify an optional character using question mark into our patterns In our example we using to specifying wheter our statement is singular or plural file found singular and files is found plural and both is matching Whitespaces white s space test white space match white s space test white space match white s space test whitespace skip white S space test whites space skip white S space test whites space match Do you know that space tab newline carriage return form feed and vertical tab characters are called whitespace characters We could use s to specify a whitespace in our pattern There are also S with capital S to specify non whitespace character e g alphanumeric and special characters Hat and dollar sign Start End Start your day with orange test Start your day with an orange match Start your day with test Start your day with an apple match with orange test Finish your day with an orange match Start your day with test Start your day with an orange skip Start your day with orange test Start your day with an orange skip So far we are matching the text regardless the position of the character whether it is on start middle or near the end of the text How could we make a boundaries to search the text that must be start in and end with In that case we use hat and to match a pattern In our example above Start your day with orange we see that the pattern that didn t start with is can be match regardless of whitespace or even incorrect sentence it is also same with the pattern that didn t end with One last note inversion is different than start with Matching Group js basic txt match js txt capture js basic js intermediate txt match js txt capture js intermediate js xls match js txt capture null python txt match js txt capture null Is it possible to extract data from our matching text so we can use that ️Yes it is We can do that by defining groups of characters and capturing them using the parantheses In our example above we write a simple pattern that captures everything from the start of js until the extension txt Matching Nested Group BaldwinAve match d w capture BaldwinAve and BaldwinAve FairwayDr match d w capture FairwayDr and FairwayDr We also could do a match a nested group by using inside another In our example above we are do a match for a street number the outer group is able to capture full address And the inner group we are able to capture the street name Using quantifier inside our group match x match d x d capture and x match d x d capture and In the example above using regex we can get the value of width and height of screen resolution Note that we are using two group match in our pattern d is used to catch all the number Conditional using pipe Apple Orange Pineapple is my favorite fruit test Appleis my favorite fruit match Apple Orange Pineapple is my favorite fruit test Pineappleis my favorite fruit match Apple Orange Pineapple is my favorite fruit test Strawberryis my favorite fruit skip We also can specify a conditioning in our regex pattern by using pipe In this example we try to match whether our favorite fruit is either Apple Orange or Pineapple Other than that will be no match Congrats for making this far You are now know the basic of regex Let s see our first regex in this article for validating password Let s glance it once more function validatePasswordRegex input return d a z A Z test input Are you able to know what this regex do now If you are able to read it congrats Let s walkthrough together Our validatePasswordRegex has condition for validating a password d is used to match whether there is a number in our input a z is used to match if there is a lowercase character in our input A Z is used to match if there is an uppercase character in our input it used to make sure if there are minimal character in our input I hope this article could help you in your journey of learning regex You could try regexr if you want messing around with it Thank you for reading and good luck |
2022-04-24 05:26:27 |
海外TECH |
DEV Community |
PostgreSQL 14: TLS Connection |
https://dev.to/nabbisen/postgresql-14-tls-connection-184l
|
PostgreSQL TLS Connection SummaryTo use PostgreSQL as external database servers it s better to use TLS SSL connection This post shows how to generate certificates configure servers and verify them There are just steps Prepare for server certificatesGenerate self signed certificates Optional Generate CA signed certificates for clients to verifyEdit server config filespostgresql conf Edit options listen address sslpg hba conf Add hostssl definitionVerify in a client machineUse psql with sslmode EnvironmentOpenBSD PostgreSQL ReferenceOfficial docs on ssl tcp current Tutorial Prepare for server certificates Generate self signed certificatesCreate server certificates in the PostgreSQL data directory as postgresql user doas su postgresql whoami postgresql cd var postgresql dataCreate a self signed certificate with openssl command line tool Of course days below can be modified which means it will be valid within days almost years ksh DB HOST DOMAIN openssl req new x days nodes text out server crt keyout server key subj CN DB HOST DOMAIN The output was Generating a bit RSA private key writing new private key to server key You will see ls l server rw r r postgresql postgresql Apr server crt rw r r postgresql postgresql Apr server keyModify permission of the key chmod server keyStay in var postgresql data as postgresql Optional Generate CA signed certificates for clients to verifyIf you don t hesitate to edit etc ssl openssl cnf to use v ca extensions it is able to create a server certificate whose identity can be validated by clients It creates root and intermediate certificates The detail about editing is in the official docs create a certificate signing request CSR and a public private key file openssl req new nodes text out root csr keyout root key subj CN ROOT CA DOMAIN chmod root key create a root certificate authority openssl x req in root csr text days extfile etc ssl openssl cnf extensions v ca signkey root key out root crt might be end with Error Loading extension section v ca create a server certificate signed by the new root certificate authority openssl req new nodes text out server csr keyout server key subj CN DB HOST DOMAIN chmod server key openssl x req in server csr text days CA root crt CAkey root key CAcreateserial out server crtHere you might meet Error Loading extension section v ca In this case try to modify etc ssl openssl cnf following this post ls root server root crt root csr root key root srl server crt server csr server key Edit server config filesYou are in var postgresql data as postgres Right whoami postgresql pwd var postgresql dataEdit postgresql conf nvim postgresql confso as to enable requests from remote clients and also ssl connection listen addresses localhost listen addresses port port DB PORT optional for security ssl off ssl on ssl cert file server crt ssl ca file ssl crl file ssl key file server key Besides when you use not self signed certificates and have root crt ssl ca file must be filled Next edit pg hba conf nvim pg hba confto add a line on hostssl to the bottom so as to allow ssl connection from clients hostssl all all mdAs of you don t have to set clientcert to when you use self signed certificates It is one of auth options which can be set to verify ca or verify full when you have valid client certificates gt In and smaller it can be set to defalut then no verify Besides when something fails on the way var postgresql logfile is surely useful to get the detail Let s come back to your user end of behavior as postgresql exitRestart the database server doas rcctl restart postgresqlDone Verify in a client machineIn a client machine use psql with sslmode require psql sslmode require host DB HOST port DB PORT user DB USER dbname DB NAME Password for user Enter db user s password psql SSL connection protocol TLSv cipher TLS AES GCM SHA bits compression off Type help for help postgres Here TLS connection based on protocol TLSv etc is acquired |
2022-04-24 05:04:51 |
海外ニュース |
Japan Times latest articles |
Is Russia as isolated as Ukraine’s allies hope? |
https://www.japantimes.co.jp/news/2022/04/24/world/how-isolated-is-russia/
|
powers |
2022-04-24 14:34:12 |
海外ニュース |
Japan Times latest articles |
Has Tyson Fury exited the ring for the last time? |
https://www.japantimes.co.jp/sports/2022/04/24/more-sports/boxing-2/tyson-fury-tko-dillian-whyte/
|
london |
2022-04-24 14:33:16 |
ニュース |
BBC News - Home |
Tyson Fury v Dillian Whyte: Gypsy King retains WBC title at Wembley and vows to retire |
https://www.bbc.co.uk/sport/boxing/61188235?at_medium=RSS&at_campaign=KARANGA
|
Tyson Fury v Dillian Whyte Gypsy King retains WBC title at Wembley and vows to retireWBC champion Tyson Fury produces a stunning one punch stoppage in the sixth round to beat fellow Briton Dillian Whyte and then insists he will retire |
2022-04-24 05:48:08 |
ニュース |
BBC News - Home |
Missing Japanese boat: Search for survivors after distress signal |
https://www.bbc.co.uk/news/world-asia-61205761?at_medium=RSS&at_campaign=KARANGA
|
heritage |
2022-04-24 05:46:52 |
北海道 |
北海道新聞 |
知床の海上や岩場で9人発見 8人は意識不明 観光船事故、捜索続く |
https://www.hokkaido-np.co.jp/article/673443/
|
意識不明 |
2022-04-24 14:31:38 |
コメント
コメントを投稿