python |
Pythonタグが付けられた新着投稿 - Qiita |
Tkinterのボタン配置方法いろいろ(pack,grid,place) |
https://qiita.com/hiratake_0108/items/210d78e8a9f912bfd2cb
|
packgridplace |
2022-07-17 22:33:21 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Reactアプリを作って、v17にダウングレードし、レンタルサーバーにデプロイするまで |
https://qiita.com/rahydyn/items/eaa13a7fd79176b96a75
|
npmstartnodejs |
2022-07-17 22:56:01 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
AWS Hands-on for Beginners 〜Serverless 編〜 #2 |
https://qiita.com/gazami_shougun/items/1dd50dbcfb9f0dde97e2
|
onforbeginnersserverless |
2022-07-17 22:21:52 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Dockerコンテナのネットワーク確認〜作成〜所属〜削除 |
https://qiita.com/anlair/items/63ee4b19ae5c609aa92f
|
etworklsnetworkidnamedriv |
2022-07-17 22:07:42 |
golang |
Goタグが付けられた新着投稿 - Qiita |
【#32 エンジニア転職学習】Go WebApplications http/template |
https://qiita.com/Chika110/items/5e651722ce6008da1e1e
|
applicationshttptemplate |
2022-07-17 22:09:41 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Rails】メガ級の大量データをseedで入れたいとき |
https://qiita.com/koki_73/items/638be3ac9bf82c87ceaa
|
rails |
2022-07-17 22:40:04 |
海外TECH |
MakeUseOf |
First Layer Woes? Here Are 5 3D Printing Surfaces to the Rescue |
https://www.makeuseof.com/3d-printing-surfaces-explained/
|
First Layer Woes Here Are D Printing Surfaces to the RescueSolving first layer adhesion issues isn t just restricted to bed leveling We explain how to choose the right build surface for your specific needs |
2022-07-17 13:30:14 |
海外TECH |
DEV Community |
How To Use The Linux Command Line |
https://dev.to/sankalpswami1122/how-to-use-the-linux-command-line-khl
|
How To Use The Linux Command LineThis is a fairly straightforward article that I wrote so that I can refer to it when I need something in the future I tried to cover the fundamentals as well as some incredibly magical things that will give every new Linux user the feeling that they have superpowers at their fingertips In this article we will start with the most basic Linux commands and progress to understanding how everything works in Linux terminals until learning about some super cool stuff like the pipe command including the tee and xargs commands amp at the same time you will also learn about various commands and utilities that we will use while we are practicing the same and at last we will use some very handy Linux utilities to enhance the productivity so without further ado let s get started Common Commands in LinuxLets start with the most basic bash commands starting with the echo command The echo command prints the strings passed as arguments This is mostly used in shell scripts to print the status out to the terminal Basic Syntax echo option string Now if you re lazy like me and want to open a calendar in a GUI simply use the cal command which will print a simple calendar in the terminal itself Basic Syntax cal month year cal cal This will print the Dec calendar The Date command is mostly used to print the date to the terminal and and to set the system date Using date command it is possible to print date in different formats and also to calculate dates Basic Syntax date OPTION FORMAT date prints day of the week day of the month month year time and timezone Sunday June PM ISTIf you wish to reuse one of the commands from your terminal session without having to retype the full command you may use the history command which will output all of the commands from that terminal session SYNTAX historyIf you wish to rerun one of these commands just input the command line number preceded by an mark Data StreamsNow that we are familiar with the basics of the command line let s learn how everything in the Linux command line functions so that we can optimise the various utilities and boost our productivity Let s study Linux command line data streams There are different Data Streams in Linux as follows Standard Input abbreviated as stdinStandard Output abbreviated as stdoutStandard Error abbreviated as stderrStandard Input consists solely of the commands you enter into the terminal to perform out particular operations Standard output is the output that prints from your commands on your terminal screen and Standard Error is the message that outputs errors from your commands on your terminal Here the ls command is the Standard Input for the terminal and the list of directories printed on the screen is the Standard Output Because these are data streams we can send them somewhere other than your terminal just like we can write them to a file These data streams also have number designations as follows Standard InputStandard OutputStandard ErrorWe can write the output of these commands to different files using redirection operators Redirection operators in linux are as follows Input Redirection lt Output Redirection gt Output Redirection appends gt gt Error Redirection gt Error Redirection appends gt gt Lets try redirection operators by redirecting some of the outputs in action Lets use the ping command to check the connectivity between the local machine and the server Now I m getting the output on the same screen lets redirect the output of the following command to output txt file ping c google com gt output txtAnd now you ll see that nothing prints on your terminal screen after running this command This is because you redirected the output to the output txt file using gt redirection operator Now lets check if the redirection process executed successfully or not by using the cat command to print the contents of output txt file You ll see that the output txt file now just contains the standard output of the ping command with youtube com as the destination rather than google com This is because the gt redirection operator truncates the standard output to the files when writing but the gt gt redirection operator appends the data to the same file Try with appending the data using the ping command and gt gt redirection operator with different destinations redirecting to the same output txt file And as shown in the above image rather of clearing and writing to the output txt file the data is appended to it this time Now try the following ping command but with an invalid destination so that we generate an error from the command ping c google m gt gt output txtNow lets redirect the error message using error redirection operator gt gt to the errors txt file using the following command and then print the contents of it using the cat command ping c google m gt gt output txt gt gt errors txtAnd as you can see the error message was successfully redirected to the errors txt file Did you know that In Linux everything literally everything is considered a file and terminals are no exception Because terminals are considered files you may redirect the output of one command from one terminal screen to another hahah All you have to do is open two different terminals on your machine and identify the file names of your two different terminals using the tty command You will now use the following command to redirect the standard output from your dev pts terminal to your dev pts terminal echo Hello from dev pts gt gt dev pts As you can see we were able to successfully redirect the standard output from one terminal to the other And I know you feel like a superhero now having super power in your hands ahaha Now let s talk about another utility that can help you increase your efficiency with terminals This is the Linux Pipe Command which allows you to combine two or more commands such that the output of one command becomes the input to the next The syntax is straightforward simply insert a vertical symbol between the two commands SYNTAX command command command command NLet s say you want to know how many configs you re using in one of your projects Instead of opening the file and counting one by one you ll use the pipe command with the word count utility to count the number of lines in that specific file To read the number of lines in a file use the cat command to display the file contents and the wc command to print the number of lines and connect them using the pipe command cat config dev env wc l prints If you wish to use the ping command but are only interested in the results you may use the ping command with few options and the tail command to simply display the result summary of the ping process To do the same thing use the following command ping google com Ac tail The Ac options are the same as the ones we used with the ping command the A option speeds up the procedure the c option specifies the number of packets to stop after and the pipe command feeds the output of the ping command to the tail command which outputs the last specified lines of output which in this case is The following is the output of the preceding command Tee CommandAssume you want to store the results of the same ping command to one file while also saving each packet s information to another and here is where the Tee command comes in handy You have to use the Tee command with the pipe command to execute different operations on the same standard output of these commands Syntax tee options files Now use the following command to store the ping command result to the results txt file and the packet details to the packets txt file ping google com Ac tee packets txt tail gt gt results txtThe tee packets txt command will redirect the output of the ping command to the packets txt file while also filtering the packets information using tail and storing the statistics to the results txt file Xargs CommandNow that you have heavily used pipes and redirections with your ping command and if you want to get rid of all the files on your machine you can either use the rm rf command to delete files by typing each and every file name in your terminal or you can simply use the xargs utility which allows you to treat the stdout of one command as an argument to the next Assuming that all of your files are in a single directory all you have to do is print the files in that directory using the ls command and then use the pipe command with xargs to pass the output to the following command to remove all of the files which is rm rf ls xargs rm rfAs you can see we had different files earlier and we removed all of them with just one command using the xargs utility which passes the output of one command as arguments to the following command You may alternatively make a new file called filesToBeDeleted txt and enter the names of all the files you wish to remove and then use the cat and rm rf commands along with the pipe and xargs commands to do the same cat filesToBeDeleted txt xargs rm rf AliasesImagine you re working with Docker and while printing all the containers your output screen is only as clear as my future hardly understandable lol And you start googling stuff to format the output and as usual Google comes through with a custom command for formatting the output of Docker containers that looks like this docker ps a format ID t ID nNAME t Names nImage t Image nPORTS t Ports nCOMMAND t Command nCREATED t CreatedAt nSTATUS t Status n And now thanks to this custom command your output screen is clearly separated and very easy to understand After a few days you begin working on some other docker project and find yourself in need of the custom formatting command again which results in the distraction of repeatedly Google everything for the same command every now and again and this is when Linux Alias comes in handy Alias allows you to build a shortcut for such daunting long commands so that you don t have to Google them all the time Aliases are classified into two types temporary and permanent Temporary Aliases can be used throughout the same session but once the terminal is closed the alias cannot be used in another session Creating Temporary Aliases is quite straightforward the syntax is as follows SYNTAX alias lt name gt lt someDauntingCommand gt The command should be in quotes and there should be no white spaces between alias name sign and command Open your terminal and run the following command to create an alias for the custom docker format command alias dockerformat docker ps a format ID t ID nNAME t Names nImage t Image nPORTS t Ports nCOMMAND t Command nCREATED t CreatedAt nSTATUS t Status n And now all you have to do is just use your shortcut command or the alias you created right now that is dockerformat in your terminal and wait for the magicAs previously mentioned temporary aliases are only effective as long as you do not close the terminal window and it is around this point where you can explore permanent aliases You must use the same syntax as for temporary aliases when creating permanent aliases but you must save it to a file Let s create a permanent alias for your same docker containers custom formatting command Create a new file named bash aliases in your home directory If you want you can actually add these aliases into the same bashrc file but for keeping things tidy and seperate we will be using bash aliases file To create a file use the following command nano bash aliases nano is a simple terminal based text editor Now in the bash aliases file add your aliases using the same command that we used to create the temporary alias alias dockerformat docker ps a format ID t ID nNAME t Names nImage t Image nPORTS t Ports nCOMMAND t Command nCREATED t CreatedAt nSTATUS t Status n When you ve finished adding your alias to the file hit Ctrl O and then Enter key to save it then Ctrl X to exit the nano text editor and return to the terminal Now use the following command to tell your terminal to look for custom commands in your freshly created bash aliases file source bash aliasesAaah that s it you ve successfully added the permanent alias to your machine Test it out by using your newly added permanent alias Alias Story Time The great deal of Dumbfuckery I did Please make sure that you are not overriding any shell builtin command with your own alias command or else your terminal will always believe that you are attempting to use your alias rather than the original builtin command I found the shutdown P now command incredibly handy for every time I needed to turn off my machine just once a month but yes but typing the entire command was not very easier so I made an alias for the shutdown command and named it sh So after a month or so when I wanted to switch my terminal from bash to shell the built in command for doing so is yeah of course sh and every time I used sh my machine used to shut down abruptly and I wasted my entire day identifying why that was happening for no reason and then after hours of googling my mind asked me to check aliases and I was like huhhhhh Please do not override any built in command in order to save yourself hours of utterly pointless googling DMs are open here |
2022-07-17 13:36:20 |
海外TECH |
DEV Community |
Remove Commas from String Python |
https://dev.to/kodwings/remove-commas-from-string-python-57p4
|
Remove Commas from String Python IntroductionIn this article we will learn to remove commas from strings using the python program We will create a program using different methods and using different functions Table of contentsUsing replace functionRemove n number of comma from the strings using replace functionUsing regex functionConclusion Remove commas using replace functionWe will use replace the function to remove all commas from the string What is replace function replace is an in built function in python where replace function is used to replace any characters from the given strings or is used to replace all occurrences of a substring from another substring So using replace function we replace commas with blank this can give strings that have no commas Inputstring I a m A nk urOutputI am AnkurExplanationFirst we will take the input of strings from the user using the input in built function input function takes a string as an input in python Now we will create a new variable named new string in this variable we will use replace function replace function takes two parameters the first parameter contains substrings that we want to remove from the strings and another parameter contains another substring for replacing the first parameter in strings Lastly we will print the new string Program take input of string from userstring input Enter strings to remove commas use replace functionnew string string replace print new stringprint new string OutputEnter strings to remove commas I a m A nk urI am Ankur Remove n number of commas from the given strings using the remove functionIf we have to remove a specific number of commas from a given string then we also do that using replace in built function of python replace function is also used to remove a specific number of substrings from a given string in python programming So replace function takes parameters the first parameter contains substrings that we want to remove from the strings and the second parameter contains another substring for replacing the first parameter in strings and the last parameter is options used to remove a specific number of substrings from the given strings Removes n commas from the stringsExplanationFirst we will take the input of strings and n from the user using the input in built function of python n is the number of commas that we have to remove from the strings Now we will create a new variable named new string in this variable we will use replace function replace function takes parameters the first parameter contains substrings that we want to remove from the strings and the second parameter contains another substring for replacing the first parameter in strings and the last parameter is options used to remove a specific number of substrings from the given strings Lastly print the new string Program take input of string from user and n string input Enter strings to remove commas n int input How many commas do you want to remove from the string use replace functionnew string string replace n print new stringprint new string OutputEnter strings to remove commas I a m An kurHow many commas do you want to remove from the string I am An kur How do remove the first comma from the strings We will remove the first comma from the string using replace function So replace function takes parameters the first parameter contains substrings that we want to remove from the strings and the second parameter contains another substring for replacing the first parameter in strings and the last parameter is options used to remove a specific number of substrings from the given strings ExplanationFirst we will take the input of strings from the user using the input in built function of python Now we will create a new variable named new string in this variable we will use replace function replace function takes parameters the first parameter contains substrings that we want to remove from the strings and the second parameter contains another substring for replacing the first parameter in strings and the last parameter is options used to remove a specific number of substrings from the given strings Lastly print the new string Program take input of string from user string input Enter strings to remove commas use replace functionnew string string replace print new stringprint new string OutputEnter strings to remove commas I a m AnkurI am Ankur Remove commas using the regex packageWe will use the regex package to remove all commas from the strings in the python program regex or re is a python package that contains a sub function which helps us to remove commas from the given strings re sub function helps to replace commas with blank ExplanationFirst we will import the re package using import Then we will take the input of the string using the input in built function The input function used to take strings input from the user Then we will create a variable named new string that uses the re sub function to remove all commas re sub function takes arguments the first argument takes substrings that we want to remove from the strings and the second argument takes another substring for replacing the first substring in strings and the last argument takes the name of the string which we want to remove all commas from it Then lastly print the new string Program import re packageimport re take input of string from user string input Enter strings to remove commas use re sub functionnew string re sub string print new stringprint new string OutputEnter strings to remove commas I a m An kurI am AnkurConclusionIn this article we show multiple methods to remove commas from the strings We use two methods for it replace and regex package both methods are easy to implement in the program and we also see how to remove the n number of commas from the strings using replace function in python programming with examples and explanation |
2022-07-17 13:31:32 |
Apple |
AppleInsider - Frontpage News |
Daily deals July 17: $130 Apple TV 4K, $700 off 55-inch LG OLED Smart TV, $27 Netgear router, more |
https://appleinsider.com/articles/22/07/17/daily-deals-july-17-130-apple-tv-4k-700-off-55-inch-lg-oled-smart-tv-27-netgear-router-more?utm_medium=rss
|
Daily deals July Apple TV K off inch LG OLED Smart TV Netgear router moreSunday s best deals include a Razer Huntsman keyboard for a Philips channel sound bar and much more Best deals for July AppleInsider checks online stores daily to uncover discounts and offers on hardware and other products including Apple devices smart TVs accessories and other items The best offers are compiled into our regular list for our readers to use and save money Read more |
2022-07-17 13:46:11 |
Apple |
AppleInsider - Frontpage News |
Crime blotter: Pro wrestlers' Find My iPhone expedition ends predictably |
https://appleinsider.com/articles/22/07/17/crime-blotter-pro-wrestlers-find-my-iphone-expedition-ends-predictably?utm_medium=rss
|
Crime blotter Pro wrestlers x Find My iPhone expedition ends predictablyIn the latest Apple Crime Blotter an arrest is made in a Apple Store theft an iPhone warehouse theft and one state bans filming the police The Apple Store in Greenwich The latest in an occasional AppleInsider series looking at the world of Apple related crime Read more |
2022-07-17 13:18:50 |
ニュース |
@日本経済新聞 電子版 |
将棋・藤井聡太、棋聖戦3連覇 永瀬破り五冠堅持
https://t.co/OZQyHXeUVR |
https://twitter.com/nikkei/statuses/1548661987265359872
|
藤井聡太 |
2022-07-17 13:32:45 |
ニュース |
@日本経済新聞 電子版 |
対中国、空の脅威へ対応急ぐ 宮沢博行・自民国防部会長
https://t.co/xjdQikS0QQ |
https://twitter.com/nikkei/statuses/1548656444547166209
|
自民 |
2022-07-17 13:10:43 |
ニュース |
BBC News - Home |
Hot weather: Amber heat warning in place as country braces for record temperatures |
https://www.bbc.co.uk/news/uk-62195015?at_medium=RSS&at_campaign=KARANGA
|
wales |
2022-07-17 13:22:41 |
ニュース |
BBC News - Home |
Conservative Party leadership: Stop toxic politics, says Penny Mordaunt |
https://www.bbc.co.uk/news/uk-politics-62196547?at_medium=RSS&at_campaign=KARANGA
|
mordaunt |
2022-07-17 13:24:23 |
ニュース |
BBC News - Home |
Greece plane crash: Cargo aircraft was carrying weapons to Bangladesh - minister |
https://www.bbc.co.uk/news/world-europe-62195005?at_medium=RSS&at_campaign=KARANGA
|
crash |
2022-07-17 13:13:24 |
ニュース |
BBC News - Home |
Ryan Jones dementia: Ex-captain legal action against rugby governing bodies |
https://www.bbc.co.uk/news/uk-wales-62197134?at_medium=RSS&at_campaign=KARANGA
|
action |
2022-07-17 13:14:44 |
ニュース |
BBC News - Home |
UK Heatwave: Michael Buble concert organiser to take extra measures |
https://www.bbc.co.uk/news/uk-england-hampshire-62198739?at_medium=RSS&at_campaign=KARANGA
|
buble |
2022-07-17 13:36:07 |
ニュース |
BBC News - Home |
Eddie Jones: England coach in altercations with Australia fans who call him 'traitor' |
https://www.bbc.co.uk/sport/rugby-union/62197806?at_medium=RSS&at_campaign=KARANGA
|
Eddie Jones England coach in altercations with Australia fans who call him x traitor x England coach Eddie Jones was involved in altercations with two Australia fans who called him a traitor after Saturday s win in Sydney |
2022-07-17 13:34:48 |
ニュース |
BBC News - Home |
England v India, third ODI: Livingstone makes hole in fence with huge six |
https://www.bbc.co.uk/sport/av/cricket/62198027?at_medium=RSS&at_campaign=KARANGA
|
England v India third ODI Livingstone makes hole in fence with huge sixLiam Livingstone puts a hole in the fence protecting the building site with a huge six during the third one day international between England and India at Old Trafford |
2022-07-17 13:29:28 |
北海道 |
北海道新聞 |
秩父の坑道で2人死亡、酸欠か SNS仲間、酸素濃度ほぼゼロ |
https://www.hokkaido-np.co.jp/article/706951/
|
埼玉県秩父市中津川 |
2022-07-17 22:24:44 |
北海道 |
北海道新聞 |
札日大高、七回集中打 夏の高校野球南北海道大会 |
https://www.hokkaido-np.co.jp/article/706975/
|
南北海道 |
2022-07-17 22:26:00 |
北海道 |
北海道新聞 |
バスケ、日本はイランに敗れる 男子アジア杯 |
https://www.hokkaido-np.co.jp/article/706973/
|
男子 |
2022-07-17 22:12:00 |
北海道 |
北海道新聞 |
旭大高、旭東が4強 夏の高校野球北北海道大会 |
https://www.hokkaido-np.co.jp/article/706972/
|
北北海道 |
2022-07-17 22:09:56 |
北海道 |
北海道新聞 |
滝川西仕切り直し 五回降雨ノーゲーム 夏の高校野球北北海道大会 |
https://www.hokkaido-np.co.jp/article/706971/
|
仕切り直し |
2022-07-17 22:09:33 |
北海道 |
北海道新聞 |
樽双葉 初勝利ならず 夏の高校野球南北海道大会 |
https://www.hokkaido-np.co.jp/article/706968/
|
全国高校野球選手権 |
2022-07-17 22:09:12 |
北海道 |
北海道新聞 |
利尻島でウイスキー製造 米国人実業家が蒸留所オープン 25年発売へ |
https://www.hokkaido-np.co.jp/article/706950/
|
宗谷管内 |
2022-07-17 22:04:30 |
コメント
コメントを投稿