python |
Pythonタグが付けられた新着投稿 - Qiita |
Blenderで自動ベイク |
https://qiita.com/SaitoTsutomu/items/f95fcc7b58f22b872bcf
|
Blenderではいろいろベイクできますが、ディヒューズとラフネスとノーマルだけ対象にしています。 |
2022-03-12 22:51:27 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
N進数の開平法を使った多倍長整数の平方根(拡張モジュール) |
https://qiita.com/ikiuo/items/df52cc9176483fe30ef4
|
N進数の開平法を使った多倍長整数の平方根拡張モジュールPythonCAPIのPyLongObject型用平方根拡張モジュールPythonでの多倍長整数int型CではPyLongObject型の平方根を整数の範囲で求めます。 |
2022-03-12 22:14:06 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
pytest を使ってみる【Python】 |
https://qiita.com/yyyyy__78/items/59507d041458829fb39a
|
testsamplepyimportpytestテストしたい関数defaddabreturnabフィクスチャpytestfixturedefdecorate前処理printテストを始めますテスト実行yield後処理printテストを終わりますprintテスト成功パターンdeftestexpecteddecorateprintテストやってますassertaddテスト失敗パターンdeftestunexpecteddecorateprintテストやってますassertaddコマンドでテストを実行してみましょう。 |
2022-03-12 22:05:44 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
【Python】pytest-mockでユニットテストをモック化する |
https://qiita.com/Jazuma/items/830d6778d932c1c87481
|
モックを利用すべき場面テストの準備にコストがかかる例データinsertが必要な処理サーバ上のファイルを利用する処理外部APIを呼び出す処理もちろん、データアクセスやファイル処理そのものを行うメソッドのテストは実際にDBやファイルを実行しなければなりません。 |
2022-03-12 22:01:42 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
JavaScript JSON.stringify() JSON.parse() |
https://qiita.com/iwasaki-hub/items/c376824723146ee5fd70
|
|
2022-03-12 22:58:48 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
リポジトリ管理しているAmplifyアプリの複製 |
https://qiita.com/ta983kata/items/156ac1698c5090bb901c
|
前提既存のソースコードは、GitLabでリポジトリを管理しているそのリポジトリ内にAmplifyの設定ファイル等amplifyフォルダ内が格納されているAmplifyのホスティング方法としては、「SCloudFront」でamplifycliを利用して公開フロントエンドのフレームワークはreact挙動を確認したかっただけなので、backendは特に追加なし概要GitLabの既存プロジェクトAをコピーして、新規プロジェクトBを作成するGitLabAコピーgtGitLabB既存プロジェクトAのAmplifyは残したまま、新規プロジェクトBを公開したいAmplifyAコピーgtAmplifyBGitLabAに紐づくのはAmplifyAとなっているGitLabBに紐づくのはAmplifyBとしたい障壁・不安要素としては、既存プロジェクトのamplifyフォルダがどうなるのか実際の作業に移ります。 |
2022-03-12 22:44:04 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
VScodeでerbファイルをEmmet有効にする際に気づいたこと |
https://qiita.com/YUhash/items/66777518384501fe57a3
|
VScodeでerbファイルをEmmet有効にする際に気づいたことVScodeのEmmet補完の設定erbファイルでもEmmetを有効にするには、VScodeのsettingにあるEmmetincludeLanguagesを設定します。 |
2022-03-12 22:14:05 |
海外TECH |
MakeUseOf |
Why Users Are Annoyed at DuckDuckGo's Stance on Disinformation |
https://www.makeuseof.com/why-duckduckgo-users-are-annoyed/
|
Why Users Are Annoyed at DuckDuckGo x s Stance on DisinformationWhile DuckDuckGo is trying its best to keep disinformation at a minimum in its search results most of the users are unhappy at the stance |
2022-03-12 13:35:34 |
海外TECH |
MakeUseOf |
How to Enable Dark Mode in Gmail |
https://www.makeuseof.com/gmail-enable-dark-mode/
|
gmail |
2022-03-12 13:30:13 |
海外TECH |
DEV Community |
DevRel job roles: Content Creator vs Content |
https://dev.to/booleanhunter/devrel-job-roles-content-creator-vs-content-45n7
|
DevRel job roles Content Creator vs ContentDeveloper Relations is a niche field in software engineering It is an umbrella term for a lot of activities that are geared towards building relationships with developers I ve been in this field for almost years and one of the most significant activities as part of my work is to create content mostly in the form of technical deep dives But to say that I m a content writer or technical writer seems like an understatement and I feel like I might be under selling myself There are several more activities that I or anyone else in this field could be involved in Here are some examples in no particular order Before even beginning to create content one would need to do a lot of research and planning what they create and how they ll execute it in the first place Sometimes the content might be talking about tech but isn t necessarily a coding tutorial For example if my organization is into Retail I would need to write articles like What challenges do online retailers face when trying to scale up That again involves research and acquiring industry knowledge For the actual content it s not always text based Often someone who s doing the writing also might be involved in creating infographics and even explore other formats like videos Working with Director of Talent for coming up with creative job ads for hiring developers Working with the Head of Marketing to decide on factors like SEO and the right platforms to publish the content on So if a person working in DevRel does the above activities and need to describe themselves in short what should they call themselves Would Content Creator make more sense or Content Developer Or are there are other titles that would work better What do you think Let s discuss in the comments below I d love to know your thoughts |
2022-03-12 13:37:22 |
海外TECH |
DEV Community |
Como lembrar mais facilmente dos comandos Linux |
https://dev.to/gustavokuhl/como-lembrar-mais-facilmente-dos-comandos-linux-3g64
|
Como lembrar mais facilmente dos comandos LinuxMinha dica para quem estácomeçando no mundo Linux e estátendo dificuldade em lembrar dos comandos de CLI comand line interface Pense no comando como se ele fosse a ação que ela representa Por exemplo o comando ls la éutilizando para listar todos os arquivos em um diretório utilizando a forma longa Lista éList em inglês e o comando ls usa as letras l e s de List Isso também se aplica às flags dos comando como l a ou la como muitos utilizam Essas são flags do comando ls em que o a significa all ou todos em português E l épara usar o formato de lista longa long Traduzindo o comando ls la ou ls l a Eu estou pedindo para o computador me listar todos os arquivos em um diretório utilizando o formato de lista longa Essa técnica também pode ser utilizada para comandos dentro do Vim que sei que éo maior terror da galera Por exemplo se eu quiser sair quit de um arquivo eu uso o comando quit e se eu quiser escrever write minhas alterações no arquivo eu uso o comando write Para facilitar ainda posso escrever as alterações no arquivo e sair dele ao mesmo tempo juntando os comandos em wq |
2022-03-12 13:33:39 |
海外TECH |
DEV Community |
How to develop the plugin deal with i18n in Figma Plugin? |
https://dev.to/kurokky/how-to-develop-the-plugin-deal-with-i18n-in-figma-plugin-295
|
How to develop the plugin deal with in in Figma Plugin Hi guys Where are you live L A Ottawa Melbourne Am I I m live in Tokyo As many of you know it s very difficult to handle internationalization In particular units of currency and inches centimeters are very tricky I have traveled to U S and Cebu Hanoi HongKong several times and every time I arrive in a country and see the expiration date on yogurt at the airport kiosk my head crashes And If I were to move from Seattle to Vancouver it would be unbelievable to me as a Japanese person that the notation would be different even though we are in the same English speaking country Actually it s not Of course in the current web world there are in libraries in Javascript and other server side languages so there is nothing wrong with converting from unixtime to your local time Yes within the web world This is determined based on the value of the browser s window navigator language but unfortunately no function or variable to obtain such an environment variable was found in the API of Figma Design s Plugin But it is engineers who confront such problems isn t it In this article I will write about my own solution Retrieve from UI screen I ve written in conclusion but this is the way to do it Of course a few tips are necessary so please read to the end if you can Figma Plugin can be developed in two types with or without UI screen What You want to make a plugin with no UI that supports internationalization I was the same way So this title The Figma plug in UI has a mode in which the UI is not displayed Oh you who think that because I am Japanese my English is even weirder than it originally was look at the sample below figma showUI html width height title figma ui hide Yes this is HIDE mode Let s make the sample a little more clear When internationalizing an alert Normally it is recommended to use Figma notify instead of Alert in Javascript when warning users in Figma However as mentioned above Figma API does not have a way to obtain user language information so internationalization is supported by using hide mode and combining it with HTML on the UI side Append ui ui html to manifest json name AlertSample id XXXXXXXXXXXXXXXX api main code js ui ui html editorType figma Add function to call ui html from code js This is a file that runs in the background function showAlert message figma showUI html width height title figma ui hide figma ui postMessage type alert message message main Figma notify Hi showAlert en Hi es Hola main ui html as shown below lt script gt onmessage event gt if event data pluginMessage type alert let massage event data pluginMessage message en if window navigator language es massage event data pluginMessage message ja alert massage lt script gt It s easy But this still has bugs The plugin does not disappear when the alert is closed Adding figma closePlugin to code js will exit without an alert so this is also not cool Then what should I do OK Go back to code js and close it again Final Codefunction showAlert message figma showUI html width height title figma ui hide figma ui postMessage type alert message message main Figma notify Hi showAlert en Hi es Hola main figma ui onmessage msg gt if msg kind exit figma closePlugin return lt script gt onmessage event gt if event data pluginMessage type alert let massage event data pluginMessage message en if window navigator language ja massage event data pluginMessage message ja alert massage parent postMessage pluginMessage kind exit type return lt script gt Yes this way we could easily support internationalization The sample code is in Javascript and does not use the in library but this method should make it easy to support multilingualization using json files which are often used It is the same as using TypeScript In addition to the alert I can easily use things like window confirm which does not exist in the Figma API to receive language as an argument from ui html and process each language separately Sum upI hope that the world will soon become a peaceful place where people can travel a lot |
2022-03-12 13:29:40 |
海外TECH |
DEV Community |
VS Code Keyboard Shortcuts | Or How To Become Even More Productive |
https://dev.to/danielbellmas/vs-code-keyboard-shortcuts-or-how-to-become-even-more-productive-46ik
|
VS Code Keyboard Shortcuts Or How To Become Even More ProductiveHi Everyone This article presents my favorite and most used keybindings and how you can customize your own So open your vs code and follow along First thing is to use the shortcut ⌘K ⌘S keep the command key pressed Here we can look for all the actions vscode has made for us and we can change existing key bindings or search for new ones After that press this button at the top right corner Or you can open this editor by going to the menu under Code gt Preferences gt Keyboard Shortcuts File gt Preferences gt Keyboard Shortcuts on Windows Here we can see the JSON file where our custom keybinding will be declared Every keybinding has to have a key and a command keys key the keys we combinecommand the action we can also add a when key that will specify when we want to execute the action Below you ll see my keybindings that I use all the time Refresh the vscode window key cmd r command workbench action reloadWindow when editorTextFocus Transform the current selection to uppercase key ctrl u command editor action transformToUppercase Calculate the current selection key ctrl m command editor emmet action evaluateMathExpression when editorHasSelection Create a new folder key ctrl n command explorer newFolder Create a new file key ctrl f command explorer newFile Extension shortcut Add a log of the current selection key shift cmd l command turboConsoleLog displayLogMessage Add an empty log statement key shift cmd l command editor action insertSnippet when editorTextFocus amp amp editorHasSelection args snippet console log You can notice that I m using the turboConsoleLog extension for logging my variables but I also wanted that the same shortcut will also output an empty console log There you have it Hope you enjoyed For more detailed information on shortcuts in general visit visual studio keybindingsI ll soon post about how to add custom snippets so be sure to like and follow Stay Tooned |
2022-03-12 13:22:59 |
海外TECH |
DEV Community |
Simple ‘Mixin’ Alternative To Standard CSS Grids |
https://dev.to/austin642/simple-mixin-alternative-to-standard-css-grids-3m4l
|
Simple Mixin Alternative To Standard CSS GridsUsing CSS grid to generate layouts in a design provides developers with value and makes things a lot easier for developers but there are still some problems or downsides of using the CSS grid systems The main reason designers and web developers use CSS grid systems is to make the generation of layouts easier and faster But the question is “can the generation of layouts be made easier and faster and still overcome these problems Fortunately for us the answer is “Yes all thanks to CSS preprocessors such as LESS and SASS SCSS that can work with CSS variables and perform calculations and output CSS via mixins OutlineHow CSS Grid System WorksSome Downsides Of Using CSS GridsHigh amounts of unused codeRestrictions on layoutset number of overall columnsNon semantic markupRestrictions on nestingAn Alternative SolutionTackling The Classic LayoutEasy px to em rem conversion Row mixin Cols mixinAdding Padding And MarginsAdding paddingAdding wrapping paddingAdding column guttersNesting And Increasing Layout ComplexityConclusion How CSS Grid Systems WorkA grid system is usually made up of a specific number of columns normally or columns and the ability to set an element like the div or class element to a width of X columns Using CSS grid systems to create layouts on a website can be really easy and of course there are many values you can get from using CSS grid systems but there are also downsides to using the CSS grid system You should not think that using the CSS grid is bad because it isn t But as a tool you will be using consistently in your codes you should be able to know the pros and cons to determine if it is right for a specific project Some Downsides Of Using CSS GridsSome of the downsides of using CSS Grids include High amounts of unused codeGrid classes could be anywhere from to lines of code but even in a simple design most of the codes may never be used Restrictions on layoutGrids are already calculated they tend to have set widths that are difficult to change e g column widths gutter widths The design becomes restricted to working only those widths Set number of overall columnsAlready calculated grid classes normally uses or columns Let s say you wanted a different number of columns well that won t be possible Non Semantic markupThe use of grid classes tends to bring about the placement of numerous non semantic class names all through a document such as a “row or “column Restrictions on nestingMost times grid systems can only have columns that are nested inside inside one another This restricts the complexity and flexibility of layout generation An Alternative Solution Mixins are available in both LESS and SASS SCSS Mixins are reusable packages of rules that outputs different CSS depending on the information that is passed through them for processing If you are not yet familiar with the understanding of what preprocessors are and how they work with mixins and variables you can read about it from Before we get started you should know that there are already some existing libraries of LESS and SASS mixins that are already solving the problems if CSS grids but we are going to be taking a different approach Note I am going to be writing these mixins in LESS because it is harder to make LESS perform sophisticated operations than SASS so it is easier for SASS users to adapt LESS mixins Tackling The Classic LayoutLet s create a layout via LESS mixins keeping the amount of CSS required to a minimum with no pixel values and maintaining a semantic markup Let s look at the HTML below lt DOCTYPE html gt lt html lang en gt lt head gt lt meta charset UTF gt lt title gt Classic Layout lt title gt lt script type text javascript src js modernizr js gt lt script gt lt link rel stylesheet href css normalize css gt lt link rel stylesheet href css classiclayout css gt lt head gt lt body gt lt header gt lt header gt lt main gt lt article gt lt article gt lt aside gt lt aside gt lt main gt lt footer gt lt footer gt lt body gt lt html gt If you notice there are no classes used here only semantic HTML tags I am going to be adding the following LESS code using mixins and variables header main footer Row background color ccc min height toRems article Cols min height toRems background color ddd aside Cols min height toRems background color eee it will then generate the following lines of CSS header main footer max width rem width margin auto background color ccc min height rem header before main before footer before header after main after footer after content display table header after main after footer after clear both article width float left min height rem background color ddd aside width float left min height rem background color eee Check out the result on your browser you will see a nice layout Let s check out the LESS mixins and variables that were used to create the layout you will be seeing in your browser Variables for em rem use base px set to the most common base px size used in browsers should generally be left at default toRems base px rem allows you to set values as the default px size to target which is then converted into scalable rem values toEms base px em same as above but with em values Grid mixins default width toRems default colspan default total cols Row width default width max width width width margin auto clear at the end of container amp before amp after content display table amp after clear both Cols colspan default colspan total cols default total cols width colspan total cols float left Now let s check out each elements one by one as you can see above Easy px to em rem conversion Variables for em rem use base px set to the most common base px size used in browsers should generally be left at default toRems base px rem allows you to set values as the default px size to target which is then converted into scalable rem values toEms base px em same as above but with em valuesThe variables that are in the top section of the code set us up for easily scalable em or rem values all through the stylesheet instead of a px value However when we use these values it allows us to conceptualize our design in pixels For example we do not want the header main or footer elements to be wider than px so instead of specifying px as the max width we have to covert that px to rems by multiplying it with the toREms variable for example toRems The output value will be rem which means that if a browser or user sets the default font size to something different from the default size of px then the entire site will scale proportionally You can also do the same to generate em values instead of using the toEms variables Row mixin default width toRems Row width default width max width width width margin auto clear at the end of container amp before amp after content display table amp after clear both As you can see the first mixin being used is the Row mixin Instead of using the “ container classes you can call this mixin wherever you want an element to be centered with a maximum width For our classic layout we call this mixin on the header main and footer elements The mixin sets a max width with a width of This will give us basic responsiveness by making the element automatically adjust to fill the available space when the viewport gets smaller than the max width value It also sets the margin to auto making the elements to be automatically centered Lastly it adds the pseudo elements before and after and also uses them to automatically clear at the end of an element This is required so that when adding columns inside the element their float settings will be cleared The mixin accepts one parameter a width value Row width default width The value now gets passed to the max width property max width width If the mixin has a width parameter passed e g Row rem the value will then be applied to the max width property However if the mixin is called without passing a parameter i e Row then the default value will be used That default value is stored in the default width variable which is set where you see default width toRems All this means that the default maximum width of any element this mixin is used on will be px converted into rem Using this mixin allows you to set any element to be centered at your default max width or any other max width you may want to apply What this means is that you can change the width of the entire site by changing the value of the default width variable Let s say for example default width toRems Cols mixin default colspan default total cols Cols colspan default colspan total cols default total cols width colspan total cols float left Because we are not using fixed pixels all our column widths will have to be percentage based because we want our layout to remain completely flexible To calculate these percentages we use cols mixin According to the values you put into the mixin a simple formula is used to determine the percentage width value that should be applied to the element The element s float value is set to left so that columns will sit side by side remember that we automatically clear floats that are applied to the columns via the Row mixin The cols mixin allows you to specify how many columns wide you want your element to be the same thing you could if you were using the standard CSS grid system This is normally done by passing a colspan parameter through the mixin or you can set the default for the mixin via the default colspan variable But unlike most CSS grid systems you have complete control over how many total that value is relative to rather than having access to only or columns You can set the total columns by passing a total cols parameter through the mixin or you can just the mixin default via the default total cols variable Sounds cool right In the earlier example of a “classic layout which I gave above using CSS grid the content area was set to out of available columns while the sidebar was set to out of columns Well we do not need all columns and we do not need to break the layout into twelve all we need is quarters because we are trying to set the content area to width and the sidebar to of the width So all we have to do now is set the value of the default total cols to a variable of For example default total cols Then we are going to use the mixins as we did in our “classic layout above The mixins assume that you want your columns to have a possibility of total columns So for us to set our article element to width you can do this article Cols then if you want to set the sidebar to width you can do this aside Cols Let s say you want to use a different number of total columns we can do this by passing different values through the cols mixin This will allow us to change the widths of the article and aside elements to any we want Example article Cols sets this element to span of a total columns min height toRems background color ddd aside Cols sets this element to span of a total columns min height toRems background color eee Awesome right Adding Padding And MarginsWhen you begin adding content inside your container you definitely would want to have the ability to control the spacing around it There are ways you can control your spacing and the best to use depends on what you are trying to achieve with the specific design you are trying to create Adding PaddingOne of the easiest ways you can control your spacing is by using the simple addition of padding parameters to both Row and Cols mixins We are going to adjust our mixin code as shown below default padding Row width default width padding default padding max width width width margin auto padding padding clear at the end of container amp before amp after content display table amp after clear both Cols colspan default colspan total cols default total cols padding default padding width colspan total cols float left padding padding We can now add padding to our header article aside and footer elements Note we are also going to be setting the default box sizing property all through the design to border box so padding does not get included in any browser calculation of the width of elements box sizing border box moz box sizing border box header footer Row padding toRems background color ccc min height toRems main Row background color ccc article Cols colspan padding toRems toRems min height toRems background color ddd aside Cols colspan padding toRems toRems min height toRems background color eee This will give us padding around each of our pieces of content as shown below Adding Wrapper MarginsIn some cases the spacing that is intended to be added to a design is on the outside of an element instead of the inside for example when you want a site s background to show through between the elements For this to happen we have to make further additions to bot the Row and Cols mixins To get started let s allow spacing to be added above and below the elements that have our Row mixin applied to them This can be done by simply replacing the existing margin property value with a variable that can be sent as a parameter all through the mixin default row margin auto Row width default width padding default padding margin default row margin max width width width margin margin padding padding clear at the end of container amp before amp after content display table amp after clear both As you can see the default value for the row margin is still set to auto therefore if no parameter is passed the mixin will still center the element automatically If we pass an margin value through the mixin header footer Row padding toRems margin toRems auto background color ccc min height toRems …we are going to be able to add vertical spacing as see below Also if you do not want your element to center anymore all you have to do is pass a margin value of auto to left align an element or you can do auto to right align Adding Column Gutters One of the common features of CSS grid systems is its ability to add gutters between the columns i e margins that apply between each columns but not to the outside of the outermost columns Once again we can add this functionality with some additions to the Cols mixin default gutter Cols colspan default colspan total cols default total cols padding default padding gutter default gutter edge false total gutter total cols gutter spanned gutters colspan gutter width colspan total gutter total cols spanned gutters float left padding padding IfEdge edge gutter IfEdge edge gutter when edge false margin right gutter IfEdge edge gutter when edge true margin right Now the mixin does two extra things First it checks for a value via the new gutter parameter and goes on to factor it into the width calculation for the column Note the gutter value should be a number used as a percentage value For example for a gutter Secondly it goes on to check the new edge variable to see is set to true or false If it is set to false the value of the guttter parameter is added to the right margin as a percentage IF it is set to true the right margin is set to This will allow you to specify where a column is at the edge of your layout and therefore should not have an applied gutter In the example I will be showing you below I will be showing you the effect of this change on the mixin I have added two extra article element to our HTML Also I have adjusted the LESS for the article and aside elements as shown below article Cols colspan padding toRems toRems gutter include a gutter of min height toRems background color ddd aside Cols colspan padding toRems toRems gutter include a gutter of edge true this is the column on the edge so don t set a right margin min height toRems background color eee the result is this To allow for control over vertical margins on columns all we have to do is include some additional parameters in the mixin as shown below default margin top default margin bottom Cols colspan default colspan total cols default total cols padding default padding gutter default gutter edge false margin top default margin top margin bottom default margin bottom total gutter total cols gutter spanned gutters colspan gutter width colspan total gutter total cols spanned gutters float left padding padding IfEdge edge gutter margin top margin bottom IfEdge edge gutter margin top margin bottom when edge false margin margin top gutter margin bottom IfEdge edge gutter margin top margin bottom when edge true margin margin top margin bottom The top and bottom margin settings can now be included when we use the Cols mixin as shown below article Cols colspan padding toRems toRems gutter margin top toRems margin bottom toRems min height toRems background color ddd aside Cols colspan padding toRems toRems gutter edge true margin top toRems margin bottom toRems min height toRems background color eee …this would add vertical margins to the columns as shown in the example below Nesting And Increasing Layout ComplexityTo add another level of complexity to our example layout we have to increase the number of article elements to and place them inside a section element wrapper then we can apply our mixins to create the layout in the example below I have made changes to the HTML to get the layout above as you can see below lt DOCTYPE html gt lt html lang en gt lt head gt lt meta charset UTF gt lt title gt Classic Layout lt title gt lt script type text javascript src js modernizr js gt lt script gt lt link rel stylesheet href css normalize css gt lt link rel stylesheet href css classiclayout css gt lt head gt lt body gt lt header gt lt h gt Site Title lt h gt lt header gt lt main gt lt section gt lt h gt Latest Articles lt h gt lt article gt lt h gt Article Title lt h gt lt p gt lt p gt lt article gt lt article gt lt h gt Article Title lt h gt lt p gt lt p gt lt article gt lt article gt lt h gt Article Title lt h gt lt p gt lt p gt lt article gt lt article gt lt h gt Article Title lt h gt lt p gt lt p gt lt article gt lt article gt lt h gt Article Title lt h gt lt p gt lt p gt lt article gt lt article gt lt h gt Article Title lt h gt lt p gt lt p gt lt article gt lt section gt lt aside gt lt p gt lt p gt lt aside gt lt main gt lt footer gt lt p gt Example Footer lt p gt lt footer gt lt body gt lt html gt We are also going to change the LESS code we are using to control the layouts as shown below header footer Row padding toRems margin toRems auto background color ccc min height toRems main Row section Cols colspan padding toRems toRems gutter background color ddd aside Cols colspan padding toRems toRems gutter edge true min height toRems background color eee article Cols colspan total cols padding toRems toRems toRems margin bottom toRems gutter background color eee amp nth of type n margin right As you can see above the section element has been set to take up columns of the default of total columns Next to the section is the aside element which is set to column of The section element acts as a wrapper for the article Since the article elements are now nested they can have all the new column width applied to them and they will now each take up a percentage of their parent element s interior Therefore each is set to column out of with a gutter of All third article is identified by using the nth of type n selector and set to have no right margin gutter ConclusionWe have gone through so many details in this article on how the Row and Cols mixins work so that you can have an understanding for you to be able to make further additions and modifications if you want The result of all we have covered is actually a simple and easy to use layout system By using just two mixins you can now create highly complex but scalable and flexible layouts without restrictions You can also use any total number of columns you feel like width of gutters and you can nest your grids as much as needed etc |
2022-03-12 13:22:05 |
海外TECH |
DEV Community |
👉Hand-picked Public APIs For Your Next Project(s). 🎁 |
https://dev.to/jareer/hand-picked-public-apis-for-your-next-projects-f0p
|
Hand picked Public APIs For Your Next Project s Bookmark This Post I ll Be Adding New Stuff I ve been working with APIs for a decent amount of time And I know what it feels like working with APIs that are free and provide you with a lot of accurate data Here are some APIs you might like AnimalsDog CEO is a website that gives you random Images of dogs Random D is just like Dog CEO but shows random duck Images AnimeAnimeChan is first on this list due to it s flexible docs and UI With help of AnimeChan you can find anime quotes generate random qoutes or get list of all the animes Really simple clean and fast easy to use API AnimeFacts is an another anime API that promises a database of anime facts Waifu im is an API with an archive of images Really Good and well explained Docs its a good Please keep in mind this API contains NSFW content Comes with SFW toggle aswell Art amp DesignEmojiHub an average API related specificly to emojis this contains generating random emojis emojis by groups etc Docs are on their github Next is Colormind API This is one of those projects i wish i found earlier This API helps you generate color schemes IconHorse is a simple tool to extract the favicon of any website sounds useful but that s all it does xColors another API to generate colors but with with a wider choice of actions You can generate hex code by color name amp translate color codes BooksWizard World API has almost all the data regarding Harry Potter universe |
2022-03-12 13:18:29 |
海外TECH |
DEV Community |
Adding Custom Attributes to Trix's toolbar |
https://dev.to/rockwell/adding-custom-attributes-to-trixs-toolbar-21pl
|
Adding Custom Attributes to Trix x s toolbarWe will be adding a color picker that allows to change the text color of a selection A color picker that allows to change the background color And Bold and Italic versions with custom UI elements instead of Tri x default toolbar TerminologiesEditor The Trix editor Document The Trix document Piece A substring of a text in the Document see above Attribute a transformation to apply on the selectionActivate attribute apply attributeDeactivate attribute remove attributeTrix editor is a rich text editor i e a glorified lt input gt tag that allows to add styles to the text written inside of it Think of typing applications such as Google Docs MS Word etc I really liked the simplicity that Trix provides out of the box and it s Document model And of course it has seamless integration with Ruby on Rails Here is a very abstract way of how Trix is designed In this post we will work with second the lt trix editor gt editor Every text passed through the trix editor will be converted into a Piece class Which represents a piece of text in the Document Trix comes with a beautiful toolbar that allows to most of the things you want But sometimes you need to adjust the styles to match the design that your team has given you Or you need to have some type of Custom action that needs to act and change a Piece of the Document Then you would need to do some manual configuration although Trix makes it really easy to add another action you ll see In this post We will add a custom toolbar that allows to change the text color and background color of a selection In future posts we will add the ability to change the text size of a selection After creating the project and installing the libraries we end up with thisFirst things first Let s hide the default trix toolbar Open up app assets stylesheets application css trix toolbar display none and add our custom toolbar It looks like this initially To offer a color picker We use a color picker package and encapsulate the logic into a color picker controller Stimulus Controller The color picker controller looks like thisimport Controller from hotwired stimulus export default class extends Controller static targets picker connect this colorPicker new window iro ColorPicker this pickerTarget width color this defaultValue layout component iro ui Box options boxHeight component iro ui Slider options sliderType hue this colorPicker on input change color gt this dispatch change detail color hexString It sets up an Iro instance that will dispatch a change event whenever the color was changed via the mousewheel The real thing happens inside the trix controller To add a custom attribute to trix you need to register the attribute in Trix s configuration Luckily it s a simple task doing so Trix config textAttributes foregroundColor styleProperty color inheritable Trix config textAttributes backgroundColor styleProperty background color inheritable We access the Trix config textAttributes object which contains all of the already provided action s attributes in Trix s toolbar then set the backgroundColor and foregroundColor The styleProperty needs to correspond to a valid CSS property This tells trix that this transformation will apply this css property on the selection To activate the text or background attribute we listen to the color picker change event emitted by color picker controller eventually it reaches this method changeColor e this colorValue e detail if this backgroundColorTarget contains e target this trixEditor activateAttribute backgroundColor e detail else this trixEditor activateAttribute foregroundColor e detail Because we have two different color pickers that will change the text color and background color we need to know which one has emitted the event Simply checking which one of the targets contains the event will suffice If it s the background then we activate the attribute and pass the value for the attribute for Trix to apply this trixEditor activateAttribute backgroundColor e detail It s just like calling a method i e the attribute and passing an argument i e the e detail Only Trix does that behind the scene we only need to call activateAttribute method Same is true for text color we simply have to tell Trix to apply the correct attribute foregroundColor and apply the color on the selection Eventually we end up with thisYou can clone the repository hereThank you for reading and Happy Coding ResourcesTrix s websiteTrix s Repositorytldraw for drawing Tailwind CSSiro jsTailwind CSS Stimulus Components |
2022-03-12 13:14:07 |
海外TECH |
DEV Community |
HTTP Hello World server for testing purposes (part 1) |
https://dev.to/guionardo/http-hello-world-server-for-testing-purposes-part-1-387h
|
HTTP Hello World server for testing purposes part HTTP Hello World server for testing purposesPost created at I needed a http server small minimalistic just for proxy testing There are many options to do this but I wanted to create my own solution A basic golang project with only native components generating a docker image with MB Just K I S S The repository for this project is in github com guionardo http helloworldAll what we need to do to use this tool is run a docker command docker run rm p guionardo http helloworld latest |
2022-03-12 13:08:21 |
海外TECH |
CodeProject Latest Articles |
An introduction to ASP.NET Core MVC through an example (Part 2) |
https://www.codeproject.com/Articles/5327314/An-introduction-to-ASP-NET-Core-MVC-through-an-e-2
|
part |
2022-03-12 13:58:00 |
海外ニュース |
Japan Times latest articles |
Fighting rages outside Kyiv as Russia says it could target Western arms convoys |
https://www.japantimes.co.jp/news/2022/03/12/world/ukraine-russia-kyiv-assault/
|
Fighting rages outside Kyiv as Russia says it could target Western arms convoysPresident Volodymyr Zelenskyy said Ukraine was at a strategic turning point in the war as Russian forces appeared to be regrouping for a possible assault |
2022-03-12 22:22:37 |
ニュース |
BBC News - Home |
Roman Abramovich: Premier League disqualifies Chelsea owner as director of club |
https://www.bbc.co.uk/sport/football/60720343?at_medium=RSS&at_campaign=KARANGA
|
Roman Abramovich Premier League disqualifies Chelsea owner as director of clubThe Premier League disqualifies Chelsea owner Roman Abramovich as a director of the club after the oligarch was sanctioned by the UK government |
2022-03-12 13:36:45 |
ニュース |
BBC News - Home |
Ukraine war: Evacuations 'extremely difficult' amid shelling |
https://www.bbc.co.uk/news/world-europe-60721323?at_medium=RSS&at_campaign=KARANGA
|
attack |
2022-03-12 13:39:57 |
ニュース |
BBC News - Home |
Ben Nevis climbing victim was father-to-be |
https://www.bbc.co.uk/news/uk-northern-ireland-60719333?at_medium=RSS&at_campaign=KARANGA
|
family |
2022-03-12 13:38:12 |
ニュース |
BBC News - Home |
Reading 1-3 Manchester United: Red Devils strengthen top-three hopes in WSL |
https://www.bbc.co.uk/sport/football/60628373?at_medium=RSS&at_campaign=KARANGA
|
Reading Manchester United Red Devils strengthen top three hopes in WSLManchester United move within six points of Women s Super League leaders Arsenal and strengthen their top three hopes with a win at Reading |
2022-03-12 13:28:41 |
北海道 |
北海道新聞 |
安否不明者、16府県が公表 災害時、家族同意なしで |
https://www.hokkaido-np.co.jp/article/656230/
|
都道府県 |
2022-03-12 22:06:41 |
北海道 |
北海道新聞 |
ロシア戦勝曲の変更相次ぐ びわ湖ホール音楽祭など |
https://www.hokkaido-np.co.jp/article/656236/
|
滋賀県立芸術劇場びわ湖ホール |
2022-03-12 22:21:00 |
北海道 |
北海道新聞 |
台湾・蔡総統「自衛の決意を」 予備役部隊の訓練視察 |
https://www.hokkaido-np.co.jp/article/656235/
|
部隊 |
2022-03-12 22:12:00 |
コメント
コメントを投稿