Skip to content

Instantly share code, notes, and snippets.

🚔
git inspector

Andrew Luca iamandrewluca

Block or report user

Report or block iamandrewluca

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nested-object-flatten-keys.js
const theObject = {
nested1: {
key1: "value1",
nested2: {
key2: "value2"
}
},
key3: "value3",
key4: ["test", "test1"]
};
@iamandrewluca
iamandrewluca / spy-typing.js
Created May 15, 2019
This script will spy the page for what you type and when will match what you find will inform
View spy-typing.js
function spy(regexp, callback) {
let state = "";
document.addEventListener("keydown", function(e) {
state += e.key;
console.log(e.key);
const match = state.match(regexp);
if (match) {
callback(match[0]);
state = "";
}
@iamandrewluca
iamandrewluca / mailto-confirm.js
Last active Mar 26, 2019
Will prompt to confirm mailto links.
View mailto-confirm.js
Array.from(document.querySelectorAll('[href^="mailto:"]')).forEach(a => {
a.addEventListener('click', function(e) {
if (!confirm('Are you sure?')) {
e.preventDefault()
}
})
})
@iamandrewluca
iamandrewluca / array-operator-overload.cpp
Created Mar 20, 2019
Supraincarcarea operatorului paranteze patrate de 2 ori in C++ creind o matrice.
View array-operator-overload.cpp
/**
Titlu: Supraincarcarea operatorului [][] in C++ creind o matrice.
Autor: Luca Andrei
Ideone: http://ideone.com/y8Km37
Descriere: De fapt operatorul [][] nu poate fi supraincarcat,
deoarece el nu este operator )), ma contrazic pe mine ce am scris in titlu ).
De fapt aici sunt doi operatori []. Pentru a "supraincarca" [][], avem nevoie
sa cream 2 clase, si pentru fiecare in parte sa supraincarcam [].
Urmariti exemplul de mai jos pentru lamurire.
/**/
@iamandrewluca
iamandrewluca / array-alloc.c
Created Mar 20, 2019
Alocarea dinamica a unui tablou bidimensional
View array-alloc.c
#include <stdio.h>
#include <conio2.h>
#include <stdlib.h>
int **a, n, m, i, j;
int main(void){
// citesti numarul de linii
printf("Dati numarul de linii >> ");
@iamandrewluca
iamandrewluca / conio.c
Created Mar 20, 2019
Citeva functii din conio.h create cu ajutorul bibliotecii windows.h
View conio.c
#include <windows.h>
// ShowCursor(true) afiseaza cursorul
// ShowCursor(false) nu afiseaza cursorul
void ShowCursor(bool show)
{
HANDLE hConsoleOutput;
CONSOLE_CURSOR_INFO structCursorInfo;
hConsoleOutput = GetStdHandle( STD_OUTPUT_HANDLE );
GetConsoleCursorInfo( hConsoleOutput, &structCursorInfo );
View time-machine.c
// determinarea timpului de executie a unui program
// sau a oricarei parti din program doriti
// cu ajutorul functiei clock() din biblioteca time.h
// clock() returneaza timpul in milisec de la executarea programului
// returneaza -1 in caz de eroare
#include <time.h> // clock();
#include <windows.h> // Sleep()
#include <stdio.h>
int main()
{
@iamandrewluca
iamandrewluca / number-generate.c
Created Mar 20, 2019
Generarea unui numar intre 2 intervale
View number-generate.c
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
int rnd(int min, int max) {
return min + rand() % (max - min +1);
}
int main() {
srand(time(NULL));
@iamandrewluca
iamandrewluca / ProtectedLink.jsx
Last active Jan 25, 2019
react-router, composition vs inheritance
View ProtectedLink.jsx
You can’t perform that action at this time.