-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.xml
353 lines (233 loc) · 55.1 KB
/
feed.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.1.0">Jekyll</generator><link href="http://0.0.0.0:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://0.0.0.0:4000/" rel="alternate" type="text/html" /><updated>2020-06-06T14:38:01-05:00</updated><id>http://0.0.0.0:4000/feed.xml</id><title type="html">[ Pob’s corner ]</title><subtitle>Another tech blog</subtitle><entry><title type="html">Legacy : a great mentorship for dev !</title><link href="http://0.0.0.0:4000/legacy-a-great-mentorship/" rel="alternate" type="text/html" title="Legacy : a great mentorship for dev !" /><published>2020-05-18T00:00:00-05:00</published><updated>2020-05-18T00:00:00-05:00</updated><id>http://0.0.0.0:4000/legacy-a-great-mentorship</id><content type="html" xml:base="http://0.0.0.0:4000/legacy-a-great-mentorship/"><p class="intro"><span class="dropcap">T</span>oday I want to talk about a topic that is present in a developer's life : legacy.</p>
<p>This word means a lot of things in the IT world, and can be translated or interpreted in such many different ways. So here I will push my point of view as a developer, this is not a regular definition of legacy. The fact is, after experience, I don’t understand why during all my studies, no one talked or teached about this, because it concern more than 50% of my career.</p>
<p><img src="/assets/img/legacy.jpg" alt="Legacy : don't blame it" /></p>
<p>I want to talk about <code class="language-plaintext highlighter-rouge">human legacy</code> when nobody don’t know how this feature works because “<em>it was developed a long time ago by a guy who left the company</em>”. And of course about <code class="language-plaintext highlighter-rouge">technical legacy</code> : a language, technology, framework that is out of date or just dead, source code with no structuring or design strategy, no documentation, no tests. Legacy is everywhere, in each project or system, there is a part of legacy. You can’t fight this, but you have to deal with it !</p>
<h2 id="dont-judge-too-fast-">Don’t judge too fast ….</h2>
<p>Behind the scene maybe there are some people that in a particular context did this “<em>strange</em>” thing. When I was younger I pushed back these projects and judged first on the situation. “<em>Why they did that like it ?</em>” or “<em>How the !/=-$ is possible ?!</em>”. But this was not the good way. Don’t lose your time. When you think about that just look at a situation where you had to “<em>do it fast</em>”, “<em>do it now</em>” or just “<em>it has to works, we will QA later</em>”. Have a look at particular context of this situation, why you didn’t do the best thing. There are reasons for that : insufficient time (deadlines ?), applicant never understood how a software works, your are new to the project, there is a lack of documentation, tools are out of date, you never worked with this language, or maybe you’re just more experienced right now than the young developer who worked on the project (<em>maybe it was a trainee or just junior</em>) in the past ? Maybe it was not a developer at all …</p>
<h2 id="nobody-is-perfect">Nobody is perfect</h2>
<p><strong>We all do mistakes</strong> ! Yes even if you are a <code class="language-plaintext highlighter-rouge">100x engineer</code>, you do mistakes. Because we become stronger and stronger learning during all our career. We start younger and become senior. There is a difference between a developer alone and a developer in a team. Sometimes a “POC” become a project but you didn’t know at first, and you leave. The developer behind you will start with a “legacy” (<em>don’t tell me that all of your POCs are healthy ^^</em>).</p>
<h2 id="analyse-and-secure">Analyse and secure</h2>
<p>First of all : analyse situation. Which <code class="language-plaintext highlighter-rouge">environments</code> are available ? We got production, is there any staging environment ? Can we simply re-start project in <code class="language-plaintext highlighter-rouge">local</code> ? Is there any <code class="language-plaintext highlighter-rouge">CI/CD</code> process to put code in production ? Are there any <code class="language-plaintext highlighter-rouge">tests</code> that I can rely on ? Is code on <code class="language-plaintext highlighter-rouge">git</code> or <code class="language-plaintext highlighter-rouge">svn</code> plateform ? Do you get <code class="language-plaintext highlighter-rouge">access</code> to servers or tools or <code class="language-plaintext highlighter-rouge">APIs</code> ? Can we found <code class="language-plaintext highlighter-rouge">logs</code> somewhere ? Is there any <code class="language-plaintext highlighter-rouge">backlog</code> ?</p>
<p>And secure it as possible. Sometimes you won’t get enough time to do all these shortcomings. You will have to choose and vote which one is needed. If project must go to live, <strong>GIT</strong> is the first thing we use to settle.</p>
<p><strong>Tests</strong> just come next : how can we secure our refactoring without killing something ? Create tests, start as simple you can. A little but brillant guy always learned me : “<strong>1 test &gt; 0 test</strong>”. Sometimes you won’t have suffisant skill to put tests in this from scratch project you don’t know. Have you ever heard and tried <code class="language-plaintext highlighter-rouge">Golden Master Testing</code> ? This is so nice.</p>
<h2 id="read-and-learn">Read and learn</h2>
<p>So when you get this project the first thing to do is something that you will do during all of your time : <strong>READ</strong>. Read code and <strong>LEARN</strong>. A developer will spend most of his time to read code, not to write code. One more thing that only experience has taught me : start small ! One small upgrade is better than no upgrade. Extract some parts away and test them. And repeat. So read, learn about the code, the context, you will find solutions and achieve to better things. Sometimes maybe, your search and work will conclude to a new project, or to kill a project. But this is at least, <strong>an upgrade of the project</strong>. Decide about kill or upgrade is not easy and it depends a lot on how much you want to invest on it, and which things we talked about during analyze (<em>environments, CI/CD, tests, versioning, accesses, logs, backlog, etc.</em>) we can push.</p>
<h2 id="legacy--the-best-coworker-to-learn">Legacy : the best coworker to learn</h2>
<p>You have to practice a lot to deal with it, this is exactly the same as automated tests : you have use them every day at work, but it was a little part during all your studies (<em>if you get lucky to get some courses on this</em>). Sometimes you will compare yourself as an archaeologist or genealogist, and yes it can be exciting to interfere in a project that you do not know. At the end you will be proud of your work and you will have grown ! The fact is that this work of search, analyze, read, act is very formative and will bring you new visions for next projects.</p>
<p>I hope that these lines will help you to fight some deamons with legacy in the future.</p>
<p><em><small>Originally published at <a href="https://dev.to/pobb/legacy-a-great-mentorship-for-dev-3688" target="_blank">Dev.to</a>.</small></em></p></content><author><name></name></author><summary type="html">Today I want to talk about a topic that is present in a developer's life : legacy.</summary></entry><entry><title type="html">Create rails app using docker in 5 steps</title><link href="http://0.0.0.0:4000/create-new-rails-app-using-docker/" rel="alternate" type="text/html" title="Create rails app using docker in 5 steps" /><published>2020-05-03T00:00:00-05:00</published><updated>2020-05-03T00:00:00-05:00</updated><id>http://0.0.0.0:4000/create-new-rails-app-using-docker</id><content type="html" xml:base="http://0.0.0.0:4000/create-new-rails-app-using-docker/"><p class="intro"><span class="dropcap">I</span>f you want to create a new Rails application using docker, and keep it simple, these lines will help you.</p>
<p>Why docker ? Why no rvm or rbenv ? In the past I used to work with rvm, helping me to manage multiple ruby / rails projects. I move to docker recently not to deploy an app to this beautiful cloud (<em>choose one you want</em>), but to create a developer environment. This is not the first purpose of docker, but it help a lot.</p>
<p>I don’t need to install all of my ruby versions on my computer, not all postgresql / mysql / mariadb versions of all projects I work on, not all dependencies etc. that can conflicts between them. I can choose which unix to use (<em>it depend on images</em>) and get closer to production env. Docker is faster on Linux, i’m on Mac, it’s a little bit slower but it’s fine.</p>
<p>So let’s create a new rails app using docker, and keep it really simple. We will take an example for a standard rails 6 app using a postgresql database.</p>
<h2 id="prerequisites">Prerequisites</h2>
<ul>
<li>Docker</li>
<li>Docker-compose</li>
<li>Internet connection (<em>download docker’s images take time ..</em>)</li>
</ul>
<h2 id="5-steps">5 steps</h2>
<ol>
<li>Clone this project (<em>it contains 3 files</em>) : <a href="https://github.com/Pobb/docker-rails" target="_blank">https://github.com/Pobb/docker-rails</a></li>
<li>docker-compose build</li>
<li>docker-compose run web rails new . –force –no-deps –database=postgresql –no-documentation</li>
<li>Edit config/database.yml and add :
<ul>
<li>host: db</li>
<li>username: “postgres”</li>
<li>password: “postgres”</li>
</ul>
</li>
<li>docker-compose up</li>
</ol>
<p>Visit <code class="language-plaintext highlighter-rouge">http://localhost:4000</code> and you are done !</p>
<h2 id="some-explanations">Some explanations</h2>
<p><strong>docker-compose build</strong> will create docker image on your computer using our <code class="language-plaintext highlighter-rouge">Dockerfile</code>. As you can see our Dockerfile is really simple. First we use official ruby image from docker hub . Next we just install some dev tools. Biggest part concern <strong>yarn</strong> : we use <code class="language-plaintext highlighter-rouge">Rails 6</code> in our example, needing webpack etc. We have to setup Yarn. Next we install rails using <code class="language-plaintext highlighter-rouge">gem install</code>command.</p>
<p><strong>Create our rails app :</strong> in our docker-compose file we can see that we declare a <code class="language-plaintext highlighter-rouge">web</code> service. We will use image we just builded and launch our classical rails new command. We mention <strong>rails new .</strong> to create app in our current folder.</p>
<p><strong>Edit config/database :</strong> In our docker-compose file we can see that our <code class="language-plaintext highlighter-rouge">db</code>service use postgres’s image. Here we want something really simple. By default, username and password are set to “postgres”. So mention it in your <code class="language-plaintext highlighter-rouge">database.yml</code> file. Host is <strong>db</strong> : just mention it like it without quotes. It’s our <code class="language-plaintext highlighter-rouge">db</code> service name we choose in docker-compose file.</p>
<h2 id="some-tips">Some tips</h2>
<ul>
<li>We use volontary latest ruby version in our example (<em>first line of Dockerfile</em>), but I suggest you to fix your ruby version using appropriate docker image. You will find it on docker-hub website.</li>
<li>As for ruby, I suggest you to precise rails version when you “gem install rails”</li>
<li>You can create a docker folder and move our 3 files in (<em>careful to change path in Dockerfile and docker-compose.yml</em>)</li>
<li>I suggest you to use ENV variable to put your user and password into database.yml file.</li>
</ul>
<p><em><small>Sources <a href="https://github.com/Pobb/docker-rails" target="_blank">Github project</a></small></em></p></content><author><name></name></author><summary type="html">If you want to create a new Rails application using docker, and keep it simple, these lines will help you.</summary></entry><entry><title type="html">Rails : How to preview Office files ?</title><link href="http://0.0.0.0:4000/rails-preview-office-file/" rel="alternate" type="text/html" title="Rails : How to preview Office files ?" /><published>2020-04-14T00:00:00-05:00</published><updated>2020-04-14T00:00:00-05:00</updated><id>http://0.0.0.0:4000/rails-preview-office-file</id><content type="html" xml:base="http://0.0.0.0:4000/rails-preview-office-file/"><p class="intro"><span class="dropcap">W</span>e use to work with CSV or PDF files when we talk about web apps. CSV are easy to use and edit after exportation (we can also easily create them), PDF are easy to read and and pretty much a standard. But when we have to deal with `.docx`, `.xslx` or similar formats, things get complicated. </p>
<h2 id="preview-a-file">Preview a file</h2>
<p>In your app, you have certainly used a preview for images or PDFs files. But how will you do in case of an emails app that must show preview of all attachments or another DMS app that must preview files with exotic extensions (<em>docx, pptx, xslx, odt, ods, odp etc.</em>) ?</p>
<p><strong>Convert them to PDF</strong> and you are done !</p>
<h2 id="libre-office-to-the-rescue">Libre office to the rescue</h2>
<p>To get this tool, just install libreoffice on your server using :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>apt-get install libreoffice -qq
</code></pre></div></div>
<p>A little look to the doc and you can see two options we will use :</p>
<p><code class="language-plaintext highlighter-rouge">--convert-to</code> : allow us to convert a file from our extension to pdf
<code class="language-plaintext highlighter-rouge">--headless</code> : it ignore GUI environment</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>libreoffice --headless --convert-to pdf my_file.docx
</code></pre></div></div>
<h2 id="rails--there-is-a-gem-for-that">Rails : there is a gem for that</h2>
<p>In a rails app, just add a gem on your Gemfile :</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Gemfile</span>
<span class="n">gem</span> <span class="s1">'libreconv'</span>
<span class="c1"># In your ruby file module or class</span>
<span class="no">Libreconv</span><span class="p">.</span><span class="nf">convert</span><span class="p">(</span><span class="s2">"</span><span class="si">#{</span><span class="no">Rails</span><span class="p">.</span><span class="nf">root</span><span class="si">}</span><span class="s2">/public/files/my_file.docx"</span><span class="p">,</span> <span class="s2">"</span><span class="si">#{</span><span class="no">Rails</span><span class="p">.</span><span class="nf">root</span><span class="si">}</span><span class="s2">/public/files/my_file.pdf"</span><span class="p">)</span>
</code></pre></div></div>
<p>Bundle install, and now you can make a preview of your file using the PDF version on your server. Note that libreoffice’s tool don’t convert only in PDF but can convert a file from extension that it can open and read to a file with extension that he can write. PDF won’t disappoint you ;)</p>
<p><em><small>Originally published at <a href="https://dev.to/pobb/rails-how-to-preview-office-files-11go" target="_blank">Dev.to</a>.</small></em></p></content><author><name></name></author><summary type="html">We use to work with CSV or PDF files when we talk about web apps. CSV are easy to use and edit after exportation (we can also easily create them), PDF are easy to read and and pretty much a standard. But when we have to deal with `.docx`, `.xslx` or similar formats, things get complicated.</summary></entry><entry><title type="html">Docket : connect to your docker’s container easily !</title><link href="http://0.0.0.0:4000/docket-connect-container/" rel="alternate" type="text/html" title="Docket : connect to your docker's container easily !" /><published>2020-03-05T00:00:00-06:00</published><updated>2020-03-05T00:00:00-06:00</updated><id>http://0.0.0.0:4000/docket-connect-container</id><content type="html" xml:base="http://0.0.0.0:4000/docket-connect-container/"><p class="intro"><span class="dropcap">I</span>'ll introduce you today a tool helping you to connect to docker containers quickly and easily using CLI.</p>
<p>The current docker way you already know is simple. If you want to connect to one of your running containers, you have to execute “<strong>docker ps</strong>” command, listing all your (<em>running</em>) containers informations.</p>
<p>Next you have to execute “<strong>docker exec -it my_container bash</strong>” command. This will connect you in your container to a bash session.</p>
<p>Every time I use the “docker ps” command, I get a long and large table. Unreadable if your terminal is not with 6px font-size .. On my terminal it looks like this :</p>
<p><img src="https://i.imgur.com/Dkc2VgY.png" alt="docker ps command" /></p>
<p>Not really easy to read. But because I hate loose my time and love to find funny’s solutions, I tried to develop a script that automatically get all containers available in “docker ps” command, only displaying “name” in a list option. I just have to select the right one with my keyboard, and it give me the good bash session, that’s all !</p>
<h2 id="docket--docker-in-your-pocket-">Docket : docker in your pocket !</h2>
<p>That’s why Docket is born : in a few lines of bash or ruby (<em>maybe one day it will be available in python too</em>), job is done !</p>
<p><img src="http://g.recordit.co/vN2zEXCrgw.gif" alt="Recordit GIF" /></p>
<p>All of my mates that saw it on my computer just asked to use it, so maybe it will be useful to you too! Go on the <a href="https://github.com/Pobb/docket">GitHub project</a> for setup instructions. You just have to download script (bash or ruby, as you want), and execute it. For more comfortable use, you can create an alias.</p>
<p><em><small>Originally published at <a href="https://dev.to/pobb/docket-connect-to-your-docker-s-container-easily-10gc" target="_blank">Dev.to</a>.</small></em></p></content><author><name></name></author><summary type="html">I'll introduce you today a tool helping you to connect to docker containers quickly and easily using CLI.</summary></entry><entry><title type="html">Invisible Captcha : how to avoid spam in Rails</title><link href="http://0.0.0.0:4000/gem-invisible-captcha/" rel="alternate" type="text/html" title="Invisible Captcha : how to avoid spam in Rails" /><published>2020-03-01T00:00:00-06:00</published><updated>2020-03-01T00:00:00-06:00</updated><id>http://0.0.0.0:4000/gem-invisible-captcha</id><content type="html" xml:base="http://0.0.0.0:4000/gem-invisible-captcha/"><p class="intro"><span class="dropcap">I</span>f you got a public website and you got a form that can be edited from users (like a contact form for example), you will get spammed every day. How to deal with it ?</p>
<p>Spambots become stronger day after day. When we dev a new form we have to deal with security to avoir injections, but sometimes we have to avoid with spam. Imagine you got a website with a contact form, how will you do to stop spambots ?</p>
<p>There are man ways to do it, you can try to :</p>
<ul>
<li>Ask a question to the user (example : Give me result for 4+4)</li>
<li>Use a captcha (like google captcha)</li>
<li>Disallow links in content form</li>
<li>Use a blacklist of words or adresses extension</li>
</ul>
<p>But all of these are not really good because of user experience (you stop the user in his way to complete the form asking a question or filling a captcha), or just because it’s hard to deal with a blacklist.</p>
<h4 id="honeypot-to-the-rescue-">Honeypot to the rescue !</h4>
<p>Another approach is to use the honeypot principle : add in your form an input that won’t be visible by the user, will have to stay empty, but bots will complete it. This is the simple first way, but it’s not suffisant.</p>
<p>Bots test your website and to check if they complete your form, they are waiting for the response. So you have to catch them before submit (to block usual action), and give them a “200 response OK”.</p>
<h4 id="invisible-captchas-gem">Invisible-captcha’s gem</h4>
<p>In a Rails project, there is a gem to do it : <a href="https://github.com/markets/invisible_captcha" target="_blank">invisible-captcha</a> :</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="c1">#Gemfile</span>
<span class="n">gem</span> <span class="s1">'invisible_captcha'</span>
<span class="c1">#app/controller/contact_controller.rb</span>
<span class="k">class</span> <span class="nc">ContactController</span> <span class="o">&lt;</span> <span class="no">ApplicationController</span>
<span class="n">invisible_captcha</span> <span class="ss">only: </span><span class="p">[</span><span class="ss">:create</span><span class="p">]</span>
<span class="k">def</span> <span class="nf">create</span>
<span class="c1"># check params</span>
<span class="no">Notification</span><span class="p">.</span><span class="nf">my_contact_form</span><span class="p">(</span><span class="n">params</span><span class="p">).</span><span class="nf">deliver</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1">#app/views/contact/index.html.erb</span>
<span class="o">&lt;</span><span class="sx">%= form_tag(envoyer_message_contact_index_path) do %&gt;
&lt;%=</span> <span class="n">invisible_captcha</span> <span class="sx">%&gt;
&lt;%= text_field_tag "name", nil, placeholder: "Name", required: true %&gt;</span>
<span class="o">&lt;</span><span class="sx">%= text_field_tag "email", nil, placeholder: "Email", required: true %&gt;
#(...)
&lt;% end %&gt;</span></code></pre></figure>
<p>You can choose to params this honeypot’s gem with many options, like custom the name of the field, choose what do to with callback etc.</p>
<p><em><small>Github <a href="https://github.com/markets/invisible_captcha" target="_blank">invisible-captcha</a></small></em></p></content><author><name></name></author><summary type="html">If you got a public website and you got a form that can be edited from users (like a contact form for example), you will get spammed every day. How to deal with it ?</summary></entry><entry><title type="html">Draw.io : un outil pour réaliser des organigrammes et des diagrammes</title><link href="http://0.0.0.0:4000/draw-io-copie/" rel="alternate" type="text/html" title="Draw.io : un outil pour réaliser des organigrammes et des diagrammes" /><published>2017-01-09T00:00:00-06:00</published><updated>2017-01-09T00:00:00-06:00</updated><id>http://0.0.0.0:4000/draw-io%20copie</id><content type="html" xml:base="http://0.0.0.0:4000/draw-io-copie/"><p class="intro"><span class="dropcap">P</span>our réaliser un schéma, un organigramme ou un diagramme, qu’il soit conséquent ou très petit, c’est parfois compliqué. Quel logiciel vais-je devoir télécharger, comment s’en sert-on, est-ce que le rendu visuel sera facilement exportable et surtout présentable ? "Je veux juste faire une patate et un carré avec une flèche !"</p>
<p>Je cherchais donc un outil pour réaliser des diagrammes ou schémas un peu techniques en vue de pouvoir les “modifier” par la suite mais aussi les “présenter” à d’autres personnes (le tout sans contraintes de paiement ni d’inscription, et pourquoi pas une interface sympa et intuitive).</p>
<h4 id="drawio-à-la-rescousse-">Draw.io à la rescousse !</h4>
<p>En cherchant un peu sur la toile je suis tombé sur Draw.io qui m’a donné pleine satisfaction. Cet outil est disponible en ligne mais il existe également des applications que l’on peut installer dans son navigateur (Chrome). Nous ne l’avons pas testé mais il existe même un plugin WordPress pour intégrer l’outil au wysiwyg du CMS.</p>
<h4 id="une-interface-simple-et-intuitive-online--offline">Une interface simple et intuitive (online &amp; offline)</h4>
<p>L’avantage premier est qu’il n’est pas nécessaire de s’inscrire. Ensuite il est tout à fait possible d’enregistrer son travail et de le modifier par la suite. Vous n’avez plus internet ? Pas de problème, téléchargez l’extension sur Chrome et vous pourrez le manipuler dans un écran comme une véritable application desktop.</p>
<figure>
<img src="/assets/img/post-draw.png" alt="" />
<figcaption>Fig1. - Version online de l’outil Draw.io</figcaption>
</figure>
<p>L’interface propose trois colonnes comme sur de nombreux logiciels de dessins avec au centre votre espace de travail, à gauche les outils mis à votre disposition et à droite des paramètres plus génériques. La prise en main a été rapide, nous ne sommes donc pas perdus ..</p>
<h4 id="une-palette-doutils-complète">Une palette d’outils complète</h4>
<p>La palette d’outils à gauche est assez longue mais il est facile de s’y repérer. Vous pourrez facilement y faire des diagrammes génériques mais aussi plus précis pour représenter de l’UML, des mockups (iOs, Android) ou encore des schémas réseaux. Bref il y a du choix.</p>
<p>Un petit moteur de recherche vous permet même de regrouper l’ensemble des éléments disponibles pour votre recherche.</p>
<h4 id="sauvegarder-et-exporter-son-travail">Sauvegarder et exporter son travail</h4>
<p>La sauvegarde de vos données se fera en XML, cela vous aidera à réouvrir et modifier votre travail par la suite. Il est également possible d’extraire son travail en fichier image, en SVG, en HTML, en PDF.</p>
<p>Pour le mode online, l’outil est compatible avec Google Drive, Dropbox et OneDrive, mais vous pourrez bien évidemment sauvegarder votre travail sur votre ordinateur.</p>
<p><em><small>Originally published at <a href="https://www.sois-net.fr/draw-io-un-outil-pour-realiser-des-organigrammes-et-des-diagrammes/" target="_blank">Sois-net</a>.</small></em></p></content><author><name></name></author><summary type="html">Pour réaliser un schéma, un organigramme ou un diagramme, qu’il soit conséquent ou très petit, c’est parfois compliqué. Quel logiciel vais-je devoir télécharger, comment s’en sert-on, est-ce que le rendu visuel sera facilement exportable et surtout présentable ? "Je veux juste faire une patate et un carré avec une flèche !"</summary></entry><entry><title type="html">A la découverte d’animate.css</title><link href="http://0.0.0.0:4000/animate-css/" rel="alternate" type="text/html" title="A la découverte d’animate.css" /><published>2016-11-29T00:00:00-06:00</published><updated>2016-11-29T00:00:00-06:00</updated><id>http://0.0.0.0:4000/animate-css</id><content type="html" xml:base="http://0.0.0.0:4000/animate-css/"><p class="intro"><span class="dropcap">A</span>ujourd’hui petite présentation d’animate.css, une feuille de style CSS permettant d’animer des éléments de notre DOM, à l’aide des animations CSS3.</p>
<p>Pour avoir un aperçu de ce que cela donne, rendez-vous sur le site officiel : <a href="https://daneden.github.io/animate.css/" target="_blank">animate.css</a>.</p>
<p>Au total on y retrouve plus de 70 animations différentes, il y a donc de quoi faire !</p>
<p>Techniquement il ne s’agit ni plus ni moins que d’une feuille de style CSS (avec des propriétés CSS3) à charger. Ensuite on appelle la classe “animated” sur un élément, puis la classe portant le nom de l’animation désirée.</p>
<figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;h1</span> <span class="na">class=</span><span class="s">"animated bounce"</span><span class="nt">&gt;</span>Example<span class="nt">&lt;/h1&gt;</span></code></pre></figure>
<p>Vous pouvez également jouer avec vos animations en personnalisant la “duration”, le “delay” et l’“iteration” le tout en CSS :</p>
<figure class="highlight"><pre><code class="language-css" data-lang="css"><span class="nf">#yourElement</span> <span class="p">{</span>
<span class="py">-vendor-animation-duration</span><span class="p">:</span> <span class="m">3s</span><span class="p">;</span>
<span class="py">-vendor-animation-delay</span><span class="p">:</span> <span class="m">2s</span><span class="p">;</span>
<span class="py">-vendor-animation-iteration-count</span><span class="p">:</span> <span class="n">infinite</span><span class="p">;</span>
<span class="p">}</span></code></pre></figure>
<p>Pour jouer une animation lors d’un événement, il est tout à fait possible de la déclencher avec un peu de javascript. Il est également possible de détecter en javascript la “fin” d’une animation, très pratique donc pour supprimer notamment les classes que l’on vient d’ajouter pour permettre de ré-exécuter notre animation ensuite.</p>
<p>Ce fichier nous permettra de gagner du temps à réaliser des animations CSS3 basiques que l’on pourra appliquer par exemple sur des formulaires, des slideshows ou pour donner un effet lors de l’affichage d’un contenu au scroll etc. Attention toutefois de ne pas en abuser et d’utiliser les animations à bon escient …</p>
<p><em><small>Originally published at <a href="https://www.sois-net.fr/a-la-decouverte-danimate-css/" target="_blank">Sois-net</a>.</small></em></p></content><author><name></name></author><summary type="html">Aujourd’hui petite présentation d’animate.css, une feuille de style CSS permettant d’animer des éléments de notre DOM, à l’aide des animations CSS3.</summary></entry><entry><title type="html">Rails : bien préparer sa BDD pour stocker des Emoji</title><link href="http://0.0.0.0:4000/rails-bdd-utf8mb4/" rel="alternate" type="text/html" title="Rails : bien préparer sa BDD pour stocker des Emoji" /><published>2016-10-17T00:00:00-05:00</published><updated>2016-10-17T00:00:00-05:00</updated><id>http://0.0.0.0:4000/rails-bdd-utf8mb4</id><content type="html" xml:base="http://0.0.0.0:4000/rails-bdd-utf8mb4/"><p class="intro"><span class="dropcap">D</span>dans cet article début d’approche sur la problématique pour stocker des "Emoji" en BDD</p>
<p>Effectivement on pense que cela ne sert à rien de les utiliser mais le problème avec ces icônes est qu’ils sont disponibles nativement sur la plupart des claviers mobiles désormais, et donc … peuvent se retrouver dans le moteur de n’importe quel formulaire de votre site. Si vous ne gérez pas ce cas particulier, cela peut engendrer des erreurs.</p>
<h4 id="la-fausse-piste-serialize">La fausse piste “serialize”</h4>
<p>Certains optent pour la solution un peu brute et pas forcément de bonne augure de spécifier dans un model que tel champ est à “serializer” (je suis moi aussi un peu tombé dedans ^^)</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">class</span> <span class="nc">MonModel</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
<span class="n">serialize</span> <span class="ss">:mon_champ</span>
<span class="k">end</span></code></pre></figure>
<p>Alors effectivement ça “marche” mais allez jeter un oeil en BDD et cela vous enchantera moins (d’autant plus qu’il sera difficile de requêter sur ce genre de données avec des conditions par exemple).</p>
<p>Serialize sert avant tout à nous aider à sauvegarder des données en tant qu’objet (au passage, en YAML). Passons donc cette alternative.</p>
<h4 id="un-problème-dencodage-avant-tout">Un problème d’encodage avant tout</h4>
<p>Le problème avec les encodages classiques en <strong>utf8</strong> est que ce dernier utilise au maximum 3 octets par caractère. Les Emoji en nécessitent 4 ! Depuis la version MySQL 5.5.3, l’encodage <strong>utf8mb4</strong> permet de manipuler tous les caractères unicodes de 4 octets (comprenant donc nos fameux emojis).</p>
<p>L’avantage est qu’il suffit de configurer notre BDD pour lui dire d’utiliser cet encodage précis. Attention toutefois, il vous faut MySQL &gt;= 5.5.3.</p>
<h4 id="création-et-configuration-de-notre-projet-rails">Création et configuration de notre projet Rails</h4>
<p>Nous allons dans un premier temps créer un projet Rails et le configurer pour mettre par défaut ce nouvel encodage (nous reviendrons dans un autre article sur la manière de procéder pour mettre à jour des colonnes sans perte de données sur un projet existant).</p>
<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="gp">#</span><span class="w"> </span>Necessite rails <span class="o">&gt;=</span> 4 et surtout MySQL <span class="o">&gt;=</span> 5.5.3
<span class="go">rails new mon_projet -d mysql</span></code></pre></figure>
<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="c1"># On modifie notre database.yml</span>
<span class="c1"># ...</span>
<span class="na">adapter</span><span class="pi">:</span> <span class="s">mysql2</span>
<span class="na">encoding</span><span class="pi">:</span> <span class="s">utf8mb4</span>
<span class="na">charset</span><span class="pi">:</span> <span class="s">utf8mb4</span>
<span class="na">collation</span><span class="pi">:</span> <span class="s">utf8mb4_unicode_ci</span>
<span class="c1"># ...</span></code></pre></figure>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="c1"># On créer un fichier dans config/initializers/utf8mb4</span>
<span class="nb">require</span> <span class="s1">'active_record/connection_adapters/abstract_mysql_adapter'</span>
<span class="k">module</span> <span class="nn">ActiveRecord</span>
<span class="k">module</span> <span class="nn">ConnectionAdapters</span>
<span class="k">class</span> <span class="nc">AbstractMysqlAdapter</span>
<span class="no">NATIVE_DATABASE_TYPES</span><span class="p">[</span><span class="ss">:string</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s2">"varchar"</span><span class="p">,</span> <span class="ss">:limit</span> <span class="o">=&gt;</span> <span class="mi">191</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span></code></pre></figure>
<p>Comme vous pouvez le constater, on précise ici une limite de <strong>191</strong> pour nos types “varchar”. Habituellement on est sur du <strong>255</strong>. En utf8 la taille maximum de l’index est de 767 octets, donc on a 767 / 3 octets par caractère = 255 caractères max pour l’utf8 habituel, et pour l’utf8mb4 on obtient 767 / 4 octets par caractère = 191 caractères max.</p>
<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="gp">#</span><span class="w"> </span>On créer notre BDD
<span class="go">rails db:create
rails db:migrate
</span><span class="gp">#</span><span class="w"> </span>On créer un objet de <span class="nb">test</span>
<span class="go">rails generate scaffold articles titre contenu:text</span></code></pre></figure>
<p>Lancez votre projet et rendez-vous sur la page de création d’un article, placez-y un titre et du texte avec un emoji dans chaque champ. Vous n’aurez pas de problème lors de la sauvegarde en BDD</p>
<p><em>Sources : <a href="https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html" target="_blank">Documentation MySQL utf8mb4</a></em></p>
<p><em><small>Originally published at <a href="https://www.sois-net.fr/rails-bien-preparer-sa-bdd-pour-stocker-des-emoji/" target="_blank">Sois-net</a>.</small></em></p></content><author><name></name></author><summary type="html">Ddans cet article début d’approche sur la problématique pour stocker des "Emoji" en BDD</summary></entry><entry><title type="html">Sublime Text : la sélection d’un mot ponctué en un seul clic</title><link href="http://0.0.0.0:4000/sublime-select-mot/" rel="alternate" type="text/html" title="Sublime Text : la sélection d’un mot ponctué en un seul clic" /><published>2016-08-24T00:00:00-05:00</published><updated>2016-08-24T00:00:00-05:00</updated><id>http://0.0.0.0:4000/sublime-select-mot</id><content type="html" xml:base="http://0.0.0.0:4000/sublime-select-mot/"><p class="intro"><span class="dropcap">V</span>oici une petite astuce sur l’éditeur Sublime Text pour sélectionner un mot (une variable, une fonction etc.) en double cliquant dessus même si celui-ci contient une ponctuation. Exemples :</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="c1"># ruby</span>
<span class="n">variable</span><span class="p">.</span><span class="nf">empty?</span></code></pre></figure>
<figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="c">&lt;!-- html --&gt;</span>
<span class="nt">&lt;p</span> <span class="na">class=</span><span class="s">"txt-center"</span><span class="nt">&gt;</span>Hello world !<span class="nt">&lt;/p&gt;</span></code></pre></figure>
<p>Faites le test sur votre Sublime Text, si vous effectuez un double-clic pour sélectionner “empty?” dans le code Ruby, ou pour sélectionner “txt-center” en entier sur le code HTML, seuls “empty” et “txt” le seront.</p>
<p>Il suffit d’ajouter des propriétés au moteur de syntaxe chargé par Sublime Text. Par exemple si j’ouvre un fichier .rb la syntaxe Sublime chargée est “Ruby” etc.</p>
<p>Ouvrez un fichier ruby (.rb) puis aller dans “<strong>Preferences &gt; Settings – More &gt; Syntax Specific – User</strong>” et ajoutez-y le code suivant :</p>
<figure class="highlight"><pre><code class="language-json" data-lang="json"><span class="p">{</span><span class="w">
</span><span class="nl">"word_separators"</span><span class="p">:</span><span class="w"> </span><span class="s2">"./</span><span class="se">\\</span><span class="s2">()</span><span class="se">\"</span><span class="s2">'-:,.;&lt;&gt;~@#$%^&amp;*|+=[]{}`~"</span><span class="w">
</span><span class="p">}</span></code></pre></figure>
<p>Dans le cas de notre exemple avec la classe “txt-center”, ouvrons désormais un fichier html ou html.erb dans Sublime Text puis aller dans “<strong>Preferences &gt; Settings – More &gt; Syntax Specific – User</strong>” et on y ajoute le même code en retirant le “tiret” de l’expression pour qu’elle puisse être matchée :</p>
<figure class="highlight"><pre><code class="language-json" data-lang="json"><span class="p">{</span><span class="w">
</span><span class="nl">"word_separators"</span><span class="p">:</span><span class="w"> </span><span class="s2">"./</span><span class="se">\\</span><span class="s2">()</span><span class="se">\"</span><span class="s2">':,.;&lt;&gt;~@#$%^&amp;*|+=[]{}`~"</span><span class="w">
</span><span class="p">}</span></code></pre></figure>
<p>Et voilà le tour est joué ! Faites et adaptez cette manipulation sur toutes les syntaxes/extensions de fichiers Sublime souhaités.</p>
<p><em><small>Originally published at <a href="https://www.sois-net.fr/sublime-text-la-selection-dun-mot-ponctue-en-un-seul-clic/" target="_blank">Sois-net</a>.</small></em></p></content><author><name></name></author><summary type="html">Voici une petite astuce sur l’éditeur Sublime Text pour sélectionner un mot (une variable, une fonction etc.) en double cliquant dessus même si celui-ci contient une ponctuation. Exemples :</summary></entry><entry><title type="html">Rails : Problème d’index trop long sur une migration ?</title><link href="http://0.0.0.0:4000/rails-migration-nom-long/" rel="alternate" type="text/html" title="Rails : Problème d’index trop long sur une migration ?" /><published>2016-05-04T00:00:00-05:00</published><updated>2016-05-04T00:00:00-05:00</updated><id>http://0.0.0.0:4000/rails-migration-nom-long</id><content type="html" xml:base="http://0.0.0.0:4000/rails-migration-nom-long/"><p class="intro"><span class="dropcap">E</span>n voulant créer une table de liaison entre deux autres dans un projet, nous avons rencontré un problème avec les index. Petit récap :</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">class</span> <span class="nc">CreateCategorieCritereCategorieProduit</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Migration</span>
<span class="k">def</span> <span class="nf">change</span>
<span class="n">create_table</span> <span class="ss">:categorie_criteres_categorie_produits</span><span class="p">,</span> <span class="ss">id: </span><span class="kp">false</span> <span class="k">do</span> <span class="o">|</span><span class="n">t</span><span class="o">|</span>
<span class="n">t</span><span class="p">.</span><span class="nf">belongs_to</span> <span class="ss">:categorie_critere</span>
<span class="n">t</span><span class="p">.</span><span class="nf">belongs_to</span> <span class="ss">:categorie_produit</span>
<span class="k">end</span>
<span class="n">add_index</span> <span class="ss">:categorie_criteres_categorie_produits</span><span class="p">,</span> <span class="ss">:categorie_critere_id</span><span class="s2">"
add_index :categorie_criteres_categorie_produits, :categorie_produit_id"</span>
<span class="k">end</span>
<span class="k">end</span></code></pre></figure>
<p>En faisant un petit rake db:migrate qui va bien, on obtenait ceci :</p>
<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">== CreateCategorieCritereCategorieProduit: migrating =========================
</span><span class="gp">-- create_table(:categorie_criteres_categorie_produits, {:id=&gt;</span><span class="nb">false</span><span class="o">})</span>
<span class="go">rake aborted!
StandardError: An error has occurred, all later migrations canceled:
</span><span class="gp">Index name 'index_categorie_criteres_categorie_produits_on_categorie_critere_id' on table 'categorie_criteres_categorie_produits' is too long;</span><span class="w"> </span>the limit is 64 characters</code></pre></figure>
<p>Le problème vient du fait qu’en voulant respecter la convention Rails sur le bon nomage de notre table de liaison on se retrouve avec un index ayant un nom très long de 68 caractères. Or la limite autorisé par notre BDD est de 64. Pour contrer cela, on peut forcer un nom d’index différent en le précisant à la fin de notre migration comme ci-dessous :</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">class</span> <span class="nc">CreateCategorieCritereCategorieProduit</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Migration</span>
<span class="k">def</span> <span class="nf">change</span>
<span class="n">create_table</span> <span class="ss">:categorie_criteres_categorie_produits</span><span class="p">,</span> <span class="ss">id: </span><span class="kp">false</span> <span class="k">do</span> <span class="o">|</span><span class="n">t</span><span class="o">|</span>
<span class="n">t</span><span class="p">.</span><span class="nf">belongs_to</span> <span class="ss">:categorie_critere</span>
<span class="n">t</span><span class="p">.</span><span class="nf">belongs_to</span> <span class="ss">:categorie_produit</span>
<span class="k">end</span>
<span class="n">add_index</span> <span class="ss">:categorie_criteres_categorie_produits</span><span class="p">,</span> <span class="ss">:categorie_critere_id</span><span class="p">,</span> <span class="ss">name: </span><span class="s2">"cat_crit_id"</span>
<span class="n">add_index</span> <span class="ss">:categorie_criteres_categorie_produits</span><span class="p">,</span> <span class="ss">:categorie_produit_id</span><span class="p">,</span> <span class="ss">name: </span><span class="s2">"cat_prod_id"</span>
<span class="k">end</span>
<span class="k">end</span></code></pre></figure>
<p>Et voilà !</p>
<p><em><small>Originally published at <a href="https://www.sois-net.fr/rails-probleme-dindex-trop-long-sur-une-migration/" target="_blank">Sois-net</a>.</small></em></p></content><author><name></name></author><summary type="html">En voulant créer une table de liaison entre deux autres dans un projet, nous avons rencontré un problème avec les index. Petit récap :</summary></entry></feed>