Skip to content

Instantly share code, notes, and snippets.

View VincentDamour's full-sized avatar

Vincent D'amour VincentDamour

View GitHub Profile
@VincentDamour
VincentDamour / imagemagick.rb
Last active July 28, 2021 22:51 — forked from ngan/imagemagick.rb
ImageMagick 7.0.9-7 Formula
class Imagemagick < Formula
desc "Tools and libraries to manipulate images in many formats"
homepage "https://www.imagemagick.org/"
url "https://dl.bintray.com/homebrew/mirror/ImageMagick-7.0.9-7.tar.xz"
mirror "https://www.imagemagick.org/download/ImageMagick-7.0.9-7.tar.xz"
sha256 "73398cc626ebbb060d0df552b0db75de0c334f9626286284b627a6eb2a66ed19"
head "https://github.com/ImageMagick/ImageMagick.git"
bottle do
sha256 "ee96f35821b25aa1e0ae3c8163b471bb9a41bf353df98cf094321aeadf11bc27" => :catalina
var posts = [
{ id: "1abc", title: "First blog post", content: "..." },
{ id: "2abc", title: "Second blog post", content: "..." },
// plus d'articles
{ id: "34abc", title: "The blog post we want", content: "..." }
// encore plus d'article
];
posts = _.keyBy(posts, "id");
function validateEmail() {
// Valider le courriel ici et afficher un message d'erreur si invalide
}
var emailInput = document.getElementById("email-field");
emailInput.addEventListener("keyup", _.debounce(validateEmail, 500));
var users = [
{ firstName: "John", lastName: "Doe", age: 28, gender: "male" },
{ firstName: "Jane", lastName: "Doe", age: 5, gender: "female" },
{ firstName: "Jim", lastName: "Carrey", age: 54, gender: "male" },
{ firstName: "Kate", lastName: "Winslet", age: 40, gender: "female" }
];
var user = _.find(users, { lastName: "Doe", gender: "male" });
// user -> { firstName: "John", lastName: "Doe", age: 28, gender: "male" }
var sortedArray = [1, 1, 2, 3, 3, 3, 5, 8, 8];
var result = _.sortedUniq(sortedArray);
// -> [1, 2, 3, 5, 8]
var original = { foo: "bar" };
var copy = original;
copy.foo = "new value";
// copy -> { foo: "new value" } Yeah!
// original -> { foo: "new value" } Oops!
var original = { foo: "bar" };
var copy = _.cloneDeep(original);
copy.foo = "new value";
// copy -> { foo: "new value" } Yeah!
var users = [
{ name: "John", age: 30 },
{ name: "Jane", age: 28 },
{ name: "Bill", age: 65 },
{ name: "Emily", age: 17 },
{ name: "Jack", age: 30 }
]
var reducedUsers = _.reduce(users, function (result, user) {
if(user.age >= 18 && user.age <= 59) {
var posts = [
{ id: "1abc", title: "First blog post", content: "..." },
{ id: "2abc", title: "Second blog post", content: "..." },
// more blog posts
{ id: "34abc", title: "The blog post we want", content: "..." }
// even more blog posts
];
posts = _.keyBy(posts, "id");
_.deburr("déjà vu");
// -> deja vu
_.deburr("Juan José");
// -> Juan Jose
var bar = { foo: { key: "foo" } };
_.set(bar, "foo.items[0]", "An item");
// bar => { foo: { key: "foo", items: ["An item"] } }
var name = _.get(bar, "name", "John Doe");
// name => John Doe