Skip to content

Instantly share code, notes, and snippets.

View celyes's full-sized avatar
🎯
Focusing

Ilyes Chouia celyes

🎯
Focusing
View GitHub Profile
@celyes
celyes / uber-challenge.php
Last active November 6, 2020 21:26
Uber challenge solved in PHP
<?php
function solve($arr): Iterator
{
foreach($arr as $k => $v){
$x = $arr;
unset($x[$k]);
yield array_product($x); // use generator for better memory usage
}
}
@celyes
celyes / Hex-to-RGB.php
Last active May 27, 2020 18:42
RGB to Hex converter in PHP
<?php
function rgb(int $r, int $g, int $b): string {
return vsprintf('#%02X%02X%02X', array_map(function ($v) { return min(max($v, 0), 255); }, [$r, $g, $b]));
}
// echo rgb(255,255,255) == #FFFFFF
@celyes
celyes / Tor.php
Last active September 4, 2022 16:26
Send php requests via Tor
<?php
namespace Celyes\Proxy;
final class Tor
{
private $curl;
private $url;
private $address;
@celyes
celyes / program.cs
Created June 18, 2019 18:17
My very first C# program
using System;
namespace test
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Welcome to the program";
Console.Write("Value of X : ");
@celyes
celyes / designs.js
Created June 18, 2019 17:31
UDACITY Pixel Art Maker - Lab 2
// Select color input
// Select size input
// When size is submitted by the user, call makeGrid()
(() => {
let inputWidth = document.querySelector('#inputWidth'),
inputHeight = document.querySelector('#inputHeight'),
colorPicker = document.querySelector('#colorPicker'),
pixelCanvas = document.querySelector('#pixelCanvas');
// Code by : Ilyes Chouia
const caesarDecrypt = (cipher, shift) => {
let output = "";
for(let i = 0; i < cipher.length; i++) {
// الحصول على رمز لوحة المفاتيح لكل حرف من النص
let cipherCode = cipher.charCodeAt(i);
if(cipherCode >= 97 && cipherCode <= 122) {
// Code by : Ilyes Chouia
const caesarShift = (text) => {
// الحروف مقسمة على مصفوفة ليتم البحث فيها
let alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
let output;
// التحقق ما إذا كانت الاحرف الاستهلالية كبيرة
text === text.toUpperCase() ? isUpperCase = true : isUpperCase = false;
// التحقق ما إذا كان النص مكتوب بأحرف استهلالية فتم قلبه أو إبقاءه كما هو
text === text.toUpperCase() ? text = text.toLowerCase(): text;
// Code by : Ilyes Chouia
const caesar = (text, shift) => {
// التحقق من أن الأحرف كبيرة أو لا
text === text.toUpperCase() ? isUpperCase = true : isUpperCase = false;
// تحويل الحروف الكبيرة إلى حروف صغيرة إن وجدت
text === text.toUpperCase() ? text = text.toLowerCase(): text = text;
@celyes
celyes / upload.class.php
Last active April 13, 2019 18:36
Single file upload class
<?php
class Upload{
private $name;
private $tmp_name;
private $size;
private $type;
private $ext;
private $allowed;
@celyes
celyes / recursive.py
Created March 20, 2018 21:45
Example of recusrion in python
def recursive(n):
if n == 0:
return 0
elif n == 1:
return 1
else :
return n * recursive(n-1)