Skip to content

Instantly share code, notes, and snippets.

View marinsagovac's full-sized avatar

Marin Sagovac marinsagovac

View GitHub Profile
@marinsagovac
marinsagovac / gist:df99321f23f255ef524973b5cc82388c
Created November 11, 2023 13:03 — forked from menht/gist:2698877
Install and Uninstall Android applications with PackageInstaller

In android source code can get

<activity android:name=".PackageInstallerActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="content" />
        <data android:scheme="file" />
@marinsagovac
marinsagovac / PHP Xrange
Created December 15, 2017 09:54
PHP Xrange
<?php
function xrange($start, $limit, $step = 1) {
if ($start < $limit) {
if ($step <= 0) {
throw new LogicException('Step must be +ve');
}
for ($i = $start; $i <= $limit; $i += $step) {
yield $i;
=======================
ONLINE RESOURCES:
=======================
SECTION 1 - OVERVIEW - COURSE INTRODUCTION
========================================
- understand the Magento architecture and modules
- efficiently and effectively customize and extend Magento
- enable the best upgrade path to new versions
@marinsagovac
marinsagovac / Apache Kafka
Last active July 14, 2021 02:28
Apache Kafka
=== Java install ===
java zookeeper-3.4.10.jar
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt install oracle-java8-set-default
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
sudo update-alternatives --config java
sudo update-alternatives --config javac
@marinsagovac
marinsagovac / psl.php
Created May 6, 2021 06:01
psl fork in PHP from JS
<?php
// https://github.com/lupomontero/psl/blob/master/index.js
class Domain
{
protected ?string $input = null;
protected $tld = null;
protected $sld = null;
protected $domain = null;
@marinsagovac
marinsagovac / Mailhog + Symfony 3
Last active March 29, 2021 19:37
Mailhog + Symfony 3
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody('You should see me from the profiler!')
;
$this->get('mailer')->send($message);
@marinsagovac
marinsagovac / API Platform Tests
Last active January 30, 2021 16:50
API Platform Tests
API PLATFORM
https://api-platform.com
https://github.com/api-platform/api-platform
### Install ###
composer create-project api-platform/api-platform bookshop-api
bin/console doctrine:database:create
bin/console server:run
@marinsagovac
marinsagovac / PHP EIO Event example
Last active December 21, 2020 10:15
PHP EIO Event example
<?php
// Add eio so file in php.ini
var_dump(extension_loaded('eio'));
// sudo pecl install eio-1.2.5
// add extension in php.ini extension=eio.so
/* Is called when eio_nop() finished */
function my_nop_cb($data, $result) {
sleep(1);
echo "my_nop ", $data, "\n";
sleep(2);
npm install react-i18next i18next --save
npm install i18next-http-backend i18next-browser-languagedetector --save
Create i18nextConf.js in a root:
```
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-xhr-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
@marinsagovac
marinsagovac / React Redux forms validators
Created August 12, 2019 11:31
React Redux forms validators
const required = value => (value || typeof value === 'number' ? undefined : 'Required');
const maxLength = max => value =>
value && value.length > max ? `Must be ${max} characters or less` : undefined;
const maxLength15 = maxLength(15);
export const minLength = min => value =>
value && value.length < min ? `Must be ${min} characters or more` : undefined;
export const minLength2 = minLength(2);
const number = value =>
value && isNaN(Number(value)) ? 'Must be a number' : undefined;
const minValue = min => value =>