Devenet Devenet

Liens en vrac

Quelques 337 marque-pages glanés pendant ma navigation sur le Web.

47 résultats pour #code×

RSS ATOM

Playing APK Golf

https://fractalwrench.co.uk/posts/playing-apk-golf-how-low-can-an-android-app-go/

Comment passer de 1,5 Mo à 1757 o pour un APK d’une même application Android…

The Joel Test: 12 steps to better code

http://www.joelonsoftware.com/articles/fog0000000043.html

The Joel Test

1. Do you use source control?
2. Can you make a build in one step?
3. Do you make daily builds?
4. Do you have a bug database?
5. Do you fix bugs before writing new code?
6. Do you have an up-to-date schedule?
7. Do you have a spec?
8. Do programmers have quiet working conditions?
9. Do you use the best tools money can buy?
10. Do you have testers?
11. Do new candidates write code during their interview?
12. Do you do hallway usability testing?

An alternative to if/else and switch in JavaScript

http://blog.wax-o.com/2015/05/an-alternative-to-if-else-and-switch-in-javascript/

Comment éviter un switch ou un if/else en JavaScript : avec un tableau.

let values = {
   a: 1,
   b: 2,
};
let foo = values[ bar ] || 3;

est équivalent à

let foo = '';
if ( bar === 'a' )
   foo = 1;
else if ( bar === 'b' )
   foo = 2;
else
   foo = 3;

Detect down/up scrolling in Javascript

http://lehollandaisvolant.net/?mode=links

// Initial state
var scrollPos = 0;
// adding scroll event
window.addEventListener('scroll', function(){ scrolling() });

// the function : compares the new scrolling state with the previous
// (this allows detecting either “up” or “down” scrolling)
// then saves the new in the $previous for the next iteration.

function scrolling() {
if ((document.body.getBoundingClientRect()).top > scrollPos) {
console.log('scrolling DOWN');
} else {
console.log('scrolling UP');
}
scrollPos = (document.body.getBoundingClientRect()).top;
}

Sending a multi-part e-mail with html and plain text

http://bookmarks.ecyseo.net/?rZSKHA

//specify the email address you are sending to, and the email subject
$email = 'email@example.com';
$subject = 'Email Subject';

//create a boundary for the email. This
$boundary = uniqid('np');

//headers - specify your from email address and name here
//and specify the boundary for the email
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: Your Name \r\n";
$headers .= "To: ".$email."\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";

//here is the content body
$message = "This is a MIME encoded message.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";

//Plain text body
$message .= "Hello,\nThis is a text email, the text/plain version.
\n\nRegards,\nYour Name";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";

//Html body
$message .= "
Hello,
This is a text email, the html version.

Regards,
Your Name";
$message .= "\r\n\r\n--" . $boundary . "--";

//invoke the PHP mail function
mail('', $subject, $message, $headers);

PHP: gethostbynamel

https://www.php.net/manual/en/function.gethostbynamel.php

Récupération de la liste d’adresses IP v4 à partir d’un nom de domaine.

Voir aussi :
• gethostbyname() - Get the IPv4 address corresponding to a given Internet host name
• gethostbyaddr() - Get the Internet host name corresponding to a given IP address
• checkdnsrr() - Check DNS records corresponding to a given Internet host name or IP address
• getmxrr() - Get MX records corresponding to a given Internet host name

Note centrer une image dans un bloc

http://lehollandaisvolant.net/?mode=links&id=20150731185744

#container {
   max-height: 100%;
}

#container img {
   /* Keeps image from going outside the screen */
   max-height: 100%;
   max-width: 100%;
   /* Keeps image from beeing distorted */
   height: auto;
   width: auto;
   /* centering horizontally AND vertically */
   /* 50% of container */
   position: relative;
   top: 50%;
   left: 50%;
   /* 50% of image */
   transform: translate(-50%,-50%);
}

Responsive tables in pure CSS

http://lehollandaisvolant.net/?id=20150528170631

Comment transformer un tableau en un tableau responsive lisible sur des petits écrans

@media (max-width: 500px) {
/* table + tbody are blocks */
#mytable, #mytable tbody {
display: block;
width: 100%;
}

/* each row becomes table */
#mytable tr {
display: table;
margin-top: 20px;
width: 100%;
border-spacing: 5px 0;
}

/* each cell becomes a row (of the row that had become a table)  */
#mytable tr td {
display: table-row;
width: 100%;
}
}