Skip to content

Instantly share code, notes, and snippets.

@matteopic
matteopic / CHANGELOG.md
Last active November 25, 2022 09:54
Some templates to use when a new project starts

Changelog

All notable changes to this project will be documented in this file.

[Unreleased]

Added

Changed

Deprecated

@matteopic
matteopic / IOUtils.java
Created February 27, 2020 12:16
Utilities for java.io
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class IOUtils {
public static void copyStream(InputStream is, OutputStream os) throws IOException {
byte[] buffer = new byte[512];
int read;
@matteopic
matteopic / convert.bat
Created February 6, 2019 08:41
Massive convert .dae to .gltf using COLLADA2GLTF.exe
@ECHO OFF
echo ### CONVERSIONE DAE/GLTF ###
SET DIR=%~dp0
:Loop
IF "%~1"=="" GOTO END
SETLOCAL
@matteopic
matteopic / convert to PDF.bat
Created February 6, 2019 08:36
Snippets pandoc
@ECHO OFF
SET MIKTEX=C:\Program Files (x86)\MiKTeX
:Loop
IF "%~1"=="" GOTO END
echo Creating file "%~n1.pdf"
pandoc -s %1 -o "%~n1.pdf" "--latex-engine=%MIKTEX%\miktex\bin\pdflatex.exe" -V papersize:A4 -V geometry:margin=1cm
SHIFT
GOTO Loop
@matteopic
matteopic / pgadmin.sh
Created February 6, 2019 08:34
pgadmin container
#!/bin/bash
imageName=dpage/pgadmin4
containerName=pgadmin4
function start(){
count=$(docker ps --all --filter "name=${containerName}" | tail -n+2 | wc -l)
if [ "$count" -eq "1" ];
then
echo "Resuming ${containerName}"
docker start $containerName
@matteopic
matteopic / ResultSet.cs
Created November 8, 2018 17:10
A wrapper for System.Data.SqlClient.SqlDataReader
public class ResultSet : IDisposable
{
private SqlDataReader reader;
public ResultSet(SqlDataReader reader)
{
this.reader = reader;
}
public bool Next()
@matteopic
matteopic / _check.php
Last active March 29, 2018 13:35
Some security check concerning PHP
<?php
function getMemInfo(){
if(PHP_OS == "Linux"){
$meminfo = exec( 'grep MemTotal /proc/meminfo', $output);
if(preg_match('/^MemTotal:\s+(\d+)\skB$/', $meminfo, $pieces)){
$mem = (int)$pieces[1];
return $mem * 1024;
}
}else if(PHP_OS == "WIN" || PHP_OS == "WINNT"){
@matteopic
matteopic / upload.php
Last active October 17, 2017 08:57
A simple PHP file to test the upload on the server
<?php if(isset($_FILES['uploadfile'])){ ?>
<p>
<?php if($_FILES['uploadfile']['error'] == 0){?>
<h3 style="color: green">Upload completed:</h3>
<div>
<strong>File Name:</strong>
<code><?php echo $_FILES['uploadfile']['name']?></code>
</div>
<div>
<strong>Size:</strong>
@matteopic
matteopic / BindingAdapters.java
Last active September 22, 2020 07:52
Adapters and Convertes for Android Databinding library
import android.databinding.BindingAdapter;
import android.support.annotation.ColorRes;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.widget.ImageView;
import android.text.Html;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
@matteopic
matteopic / dense_single_line_list_item.xml
Last active February 28, 2020 10:58
Material Design Layouts for Android
<?xml version="1.0" encoding="utf-8"?>
<!-- Based on following specs: https://material.io/guidelines/components/lists.html#lists-specs -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView