Skip to content

Instantly share code, notes, and snippets.

Flavio Maria De Stefano kopiro

View GitHub Profile
@kopiro
kopiro / AutoUpdater.vb
Created Nov 26, 2018
Auto Update VB.NET Compact 3.5 App
View AutoUpdater.vb
Public Class AutoUpdater
Public newVersion As String
Public urlOfCab As String
Public credentials As Net.NetworkCredential
Public askDest As Boolean = False
Public deleteCab As Boolean = True
Public useUI As Boolean = False
Public permitUninstall As Boolean = False
@kopiro
kopiro / README.md
Last active Nov 6, 2018
Extract from a JS object with a specific pattern
View README.md

extractWithPattern

Extract from a JS object with a specific pattern

let msg = [
	{ payload: { errors: { unknown_language: 'hello' } } },
	{ payload: { errors: { number: 1 } } },
	{ randomstuff: 42 }
];
@kopiro
kopiro / backup-repos.sh
Last active Oct 15, 2018
Backup all Repositories in current directory
View backup-repos.sh
backup-repos() {
for i in $(find . -type d -maxdepth 1 -mindepth 1); do
echo "Looking in $i..."
if [ -d "$i/.git" ]; then
echo "Found repository in $i, init backup..."
pushd $i > /dev/null
zip_name="$i-$(date +'%y%m%d').zip"
zip_path="/opt/backups/$zip_name"
echo "ZIP path: $zip_path"
if [ ! -f "$zip_path" ]; then
View number_to_english.js
const digit_to_string = {
0: 'zero',
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
@kopiro
kopiro / README.md
Created Jun 22, 2018
Download entire INTERNET
View README.md

Internet Downloader

Simple POC

Compilation

brew install wget
gcc -lcurl download_internet.c
View cake.js
// Stringify a piece of cake
function stringify(cake) {
return cake.map(e => e.join('')).join('\n')
}
// Check if this cut is a valid slice
function isAValidSlice(cake, x, y, width, height) {
// Is not valid if we exceed in width or height
if ((x + width) > cake[0].length) return false;
if ((y + height) > cake.length) return false;
@kopiro
kopiro / number-generator.php
Created Jun 13, 2018
PHP Number Generator
View number-generator.php
<?php
function autoIncrement($start = 0, $step = 1, $circle = -1, $repeat = 1) {
$i = $start;
while (true) {
for ($j = 0; $j < $repeat; $j++) yield $i;
$i += $step;
if ($i === $circle) $i = $start;
}
}
View Dockerfile OCI8
FROM php:7.1-fpm
RUN set -ex && \
apt-get update && \
apt-get -y --no-install-recommends install \
apt-utils \
unzip \
nano \
git
@kopiro
kopiro / aws-say.js
Created Apr 24, 2018
Convert text to mp3 using AWS Polly
View aws-say.js
const aws = require('aws-sdk');
aws.config.loadFromPath('aws.json');
const locale = 'it-IT';
const fs = require('fs');
const pollyClient = new aws.Polly({
signatureVersion: 'v4',
region: 'eu-west-1'
@kopiro
kopiro / ImplicitGrantWithPostmessage.php
Created Apr 12, 2018
Implicit Grant with Postmessage for Laravel Passport
View ImplicitGrantWithPostmessage.php
<?php
namespace App\Libraries\OAuth;
class ImplicitGrantWithPostmessage extends \League\OAuth2\Server\Grant\ImplicitGrant
{
public function completeAuthorizationRequest(\League\OAuth2\Server\RequestTypes\AuthorizationRequest $authorizationRequest) {
$response = parent::completeAuthorizationRequest($authorizationRequest);
$reflectionClassResponse = new \ReflectionClass($response);
You can’t perform that action at this time.