Skip to content

Instantly share code, notes, and snippets.

View newtomsoft's full-sized avatar
🏠
Working from home

Thomas Vuille newtomsoft

🏠
Working from home
View GitHub Profile
@newtomsoft
newtomsoft / fuckjs_refacto.txt
Created March 14, 2025 20:52
fuckjs refacto
[][(![]+[])[+!+[]]+(!![]+[])[+[]]][([][(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(+(!+[]+!+[]+!+[]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([]+[])[([][(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])
@newtomsoft
newtomsoft / minInArray.cs
Created March 8, 2022 15:30
min difference between 2 integer in array
var nombers = new[] { -1, 2, -154, 9, -47, 13 };
//linq way
var min = nombers.SelectMany((n1, index1) => nombers.Where((_, index2) => index2 > index1).Select(n2 => Math.Abs(n2 - n1))).Min();
//traditional way
var min = int.MaxValue;
for (int i = 0; i < nombers.Length; i++)
{
for (int j = i + 1; j < nombers.Length; j++)
@newtomsoft
newtomsoft / for_in_of.js
Created June 28, 2020 17:39
javascript for in & for of
const table = ['val1', 'val2', 'val3'];
for (let i in table) {
console.log(`index : ${i} ; element : ${table[i]}`); // => index : 0 ; element : val1 index : 1 ; element : val2 index : 2 ; element : val3
}
for (let element of table) {
console.log(`element : ${element}`); // => element : val1 element : val2 element : val3
}
@newtomsoft
newtomsoft / FizzBuzz.js
Created June 28, 2020 14:26
FizzBuzz in JS
function FizzBuzz() {
for (let i = 1; i <= 100; i++) {
if ((i % 3 === 0) && (i % 5 === 0)) {
console.log("FizzBuzz");
} else if (i % 3 === 0) {
console.log("Fizz");
} else if (i % 5 === 0) {
console.log("Buzz");
} else {
console.log(i);
function alternatingSums(array) {
let evenSum = 0;
let oddSum = 0;
array.forEach(function(item, index) {
if (index % 2 == 0) evenSum += item;
else oddSum += item;
});
return [evenSum, oddSum];
}
function allLongestStrings(array) {
let lengthMax = 0;
array.forEach(word => lengthMax = word.length > lengthMax ? word.length : lengthMax);
return array.filter(word => word.length == lengthMax);
}
function add(...args) {
let result = 0;
args.forEach(element => result += element);
return result;
}
//or
function add2(...args) {
return args.reduce((accumulator, current) => accumulator + current);
}
using System;
using System.Collections.Generic;
namespace NarcissisticNumberDojo
{
public class NarcissisticNumber
{
public static IEnumerable<UInt64> NarcissisticNumberList(UInt64 maxNumber)
{
List<UInt64> narcissisticNumbers = new List<UInt64>();