Skip to content

Instantly share code, notes, and snippets.

View cosminpopescu14's full-sized avatar
🎯
Focusing

Cosmin Popescu cosminpopescu14

🎯
Focusing
View GitHub Profile
@cosminpopescu14
cosminpopescu14 / squash.php
Created May 30, 2018 14:06 — forked from woganmay/squash.php
Use PHP to flatten a multidimensional stdClass object (like a json_decode result)
<?php
function squash($array, $prefix = '')
{
$flat = array();
$sep = ".";
if (!is_array($array)) $array = (array)$array;
foreach($array as $key => $value)
@cosminpopescu14
cosminpopescu14 / ConstructorsAndProtectedField.cs
Last active June 2, 2018 14:48
Playing with some c# and oop
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp11
{
class Person
{
@cosminpopescu14
cosminpopescu14 / send_mail.php
Created June 3, 2018 13:27
snippef for sending mail with php and php mailer
<?php
/**
* Created by PhpStorm.
* User: cosmi
* Date: 03-Jun-18
* Time: 3:55 PM
*/
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jul 28, 2018 at 06:26 PM
-- Server version: 5.7.21-log
-- PHP Version: 7.2.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
// ConsoleApplication12.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
struct Carte {
@cosminpopescu14
cosminpopescu14 / DemoSerialize.java
Created August 19, 2018 09:46
Java serialize and unserialize object
package com.company;
public class DemoSerialize implements java.io.Serializable
{
public int a;
public String b;
public DemoSerialize(int _a, String _b)
@cosminpopescu14
cosminpopescu14 / Java11_Features.java
Created September 28, 2018 05:28
java 11 features
package com.company;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
@cosminpopescu14
cosminpopescu14 / LuhnAlgorithm.cs
Created October 7, 2018 15:10
Implementation of Luhn algorithm
using System;
namespace Luhn
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(IsValid());
Console.ReadLine();
public static uint ConvertEndianess(uint data)
{
uint goodData = ((data & 0x000000FF) << 24) + ((data & 0x0000FF00) << 8) + ((data & 0x00FF0000) >> 8) + ((data & 0xFF000000) >> 24);
return goodData;
}
@cosminpopescu14
cosminpopescu14 / NthRoot.cs
Created October 11, 2018 18:05
compute nth root
static double ComputeNthRoot(double value, double degree) => Pow(value, (double)(1 / degree));