Skip to content

Instantly share code, notes, and snippets.

@jahend
jahend / ngFor
Last active June 18, 2019 14:35
[Angular :: Operator] *ngFor #typescript #angular
il est possible de récupérer d'autre informations telles que l'index de l'élément :
index : position de l'élément.
odd : indique si l'élément est à une position impaire.
even : indique si l'élément est à une position paire.
first : indique si l'élément est à la première position.
last : indique si l'élément est à la dernière position.
<ul>
<li *ngFor="let book of bookList; let index = index; let isFirst = first; let isOdd = odd;">
<span>{{ index }}</span>
import 'package:flutter/material.dart';
import './product_manager.dart';
// This method return anything
// void main() {
// runApp(MyApp());
// }
// Sugar syntax only with one statement
void main() => (runApp(MyApp()));
@jahend
jahend / 0_StyleGuide.dart
Last active September 2, 2019 17:40
[Flutter Layout] class, padding, align ...
import 'package:flutter/material.dart';
class AppTheme {
static const TextStyle title_h1 = TextStyle(
fontFamily: "WorkSans",
color: Colors.black,
fontSize: 38,
fontWeight: FontWeight.w600,
letterSpacing: 1.2
@jahend
jahend / Object.py
Last active July 12, 2019 10:08
[Python]
user = { "name": "Ed", "email": "john@yahoo.com",
"age": 20, "purchases": [1, 2, 3, 4]}
user["name"] = "anna
print(user)
for key in user:
print(key)
docker pull [imageName] # Pull an image from a registry
docker run [imageName] # Run containers
docker run -d [imageName] # Detached mode
docker start [containerName] # Start stopped containers
docker ps # List running containers
docker ps -a # List running and stopped containers#
docker stats # List running containers with memory usage
docker stop [containerName] # Stop continers
docker kill [containerName] # Kill Containers
@jahend
jahend / basic.js
Last active October 15, 2019 08:57
[JS :: VanillaJS] - Selecting elements with querySelector and querySelectorAll Listening for events with addEventListener Updating CSS and styles through style property Working with classes through the classList property AJAX requests with fetch Triggering events with dispatchEvent Creating elements with createElement Updating text through the t…
// jQuery, select all instances of .box
$(".box");
// Instead, select the first instance of .box
document.querySelector(".box");
// …or select all instances of .box
document.querySelectorAll(".box");
-------------------------------
@jahend
jahend / app.js
Last active February 11, 2021 11:20
[React :: Custom Hooks :: useFetch] custom hook #react
function useFetch(url, defaultResponse) {
const [data, setData] = useState(defaultResponse);
async function getDataFromAPI() {
try {
const res = await fetch(url);
const data = await res.json();
setData({
isLoading: false,
data
@jahend
jahend / EnumExemple.java
Last active November 25, 2019 09:58
JAVA :: Enum
package com.example.sub.subject
public enum LoggingLevel {
PENDING(1, "1"), PROCESSING(2), PROCESSED(3);
private int i;
private LoggingLevel(int i) {
this.i = i;
}
@jahend
jahend / principes.java
Created November 25, 2019 13:15
JAVA :: Principes
// HERITAGE
L'héritage est un moyen de créer de nouvelles classes à partir de classes déjà existantes afin de réutiliser leurs attributs et leurs comportements.
// ENCAPSULATION
// POLYMORPHISME
@jahend
jahend / basic
Last active February 5, 2020 22:28
[AWS :: S3 Cli command] #aws
// list s3 bucket
aws s3 ls
// list all folders and objects in bucket
aws s3 ls s3://<bucket_name>
// list all folders and object in folder
aws s3 ls s3://<bucket_name>/<folder>
// Dl object to my desktop