Skip to content

Instantly share code, notes, and snippets.

View nicaralava's full-sized avatar

Jean Nica Ralava nicaralava

View GitHub Profile
@nicaralava
nicaralava / squareArrayValue.php
Last active August 15, 2018 18:51
Compute the square of only the positive integers (fractions are not integers) in the array (PHP)
<?php
declare(strict_types=1);
$realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
print_r(
$valeur = array_map(
function($n):int{
return $n*$n;
},array_filter($realNumberArray,function($v):bool{
return is_int($v) && $v >= 0;
}
@nicaralava
nicaralava / squareArrayValue.js
Created August 15, 2018 18:23
Compute the square of only the positive integers (fractions are not integers) in the array (JS ES6)
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
const squaredIntegers = arr;
const getIntpositiveValue = squaredIntegers.filter(val => {
return Number.isInteger(val) && val >= 0;
});
const getSquareValue = getIntpositiveValue.map(intVal => {
return intVal* intVal;
});
@nicaralava
nicaralava / while.html
Created August 13, 2018 13:30
Sass: Apply a Style Until a Condition is Met with @while
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style type='text/sass'>
$x : 1;
@while $x < 11 {
.text-#{$x} {font-size: 5px * $x;}
$x : $x + 1;
}
@nicaralava
nicaralava / each.html
Created August 13, 2018 12:03
Sass: Use @each to Map Over Items in a List
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style type='text/sass'>
$colors: (blue, black, red);
@each $color in $colors {
.#{$color}-bg {
background-color: $color;
}
@nicaralava
nicaralava / for.html
Created August 13, 2018 11:47
Sass: Use @for to Create a Sass Loop
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style type='text/sass'>
@for $j from 1 to 6{
.text-#{$j} {font-size:10px*$j;}
}
</style>
</head>
@nicaralava
nicaralava / gulpfile.js
Created July 8, 2018 17:19
gulp-for-beginners
var gulp = require('gulp');
var sass = require('gulp-sass');
var concatTest = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var cleanCSS = require('gulp-clean-css');
var scssSource = './source/sass/*.scss';
var scssDest = './dist/css';
var jsSource = './source/js/*.js';
var jsDest = './dist/js';
@nicaralava
nicaralava / CodeVsZombies.php
Last active April 29, 2018 19:17
codingame/puzzle/CodeVsZombies
<?php
while (TRUE)
{
fscanf(STDIN, "%d %d",
$x,
$y
);
fscanf(STDIN, "%d",
$humanCount
);
@nicaralava
nicaralava / FizzBuzz.php
Last active April 13, 2018 17:10
codingame/puzzle/FizzBuzz
<?php
declare(strict_types = 1);
function isFizz(int $value): bool {
return ((($value % 3) == 0) && (($value % 5) != 0));
}
function isBuzz(int $value): bool {
return ((($value % 5) == 0) && (($value % 3) != 0));
}
@nicaralava
nicaralava / mars-lander-episode-1.php
Created April 12, 2018 17:05
codingame/puzzle/mars-lander-episode-1
<?php
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
fscanf(STDIN, "%d",
$surfaceN // the number of points used to draw the surface of Mars.
);
for ($i = 0; $i < $surfaceN; $i++)
@nicaralava
nicaralava / power-of-thor-episode-1.php
Created April 12, 2018 03:49
puzzle/power-of-thor-episode-1
<?php
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
* ---
* Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
**/
fscanf(STDIN, "%d %d %d %d",
$lightX, // the X position of the light of power