Skip to content

Instantly share code, notes, and snippets.

View Awilum's full-sized avatar
🧙‍♂️
WORK HARD. PLAY HARD

Sergey Romanenko Awilum

🧙‍♂️
WORK HARD. PLAY HARD
View GitHub Profile
$array1 = array("PHP" => "Rasmus", "Javascript" => "Brendan", "R" => "Robert", "flextype" => ["founder" => "Sergey"], 10 => 'num1', '11' => 'num1');
$array2 = array("Java" => "James", "R" => "Ross", "Python" => "Guido", "flextype" => ['version' => '1.0'], 10 => 'num2', '11' => 'num2');
$result = array_merge($array1, $array2);
$result2 = array_replace($array1, $array2);
$result3 = array_merge_recursive($array1, $array2);
$result4 = array_replace_recursive($array1, $array2);
echo '<pre>array_merge: <br>';
print_r($result);
### Keybase proof
I hereby claim:
* I am Awilum on github.
* I am awilum (https://keybase.io/awilum) on keybase.
* I have a public key whose fingerprint is 6348 9E76 D86B 773D 0B30 024A 923A FFE7 3AC6 DB03
To claim this, I am signing this object:
protected function checkboxField(string $element, string $name, $value, array $property) : string
{
$field = '<div class="form-group ' . $property['size'] . '">';
$field .= '<div class="custom-control custom-checkbox">';
$field .= '<input type="checkbox" value="'. ($value == 'checked' ? 'checked' : '') .'" name="'. $name .'" class="custom-control-input" id="'. $element .'" '. ($value == 'checked' ? 'checked="checked"' : '') .'>';
$field .= ($property['title'] ? '<label class="custom-control-label" for="'. $element .'">'. __($property['title']) .'</label>' : '');
$field .= '</div>';
$field .= '</div>';
return $field;
for ($i=0; $i < 10000; $i++) {
mkdir(__DIR__ . '/site/entries/blog/' . 'post' . $i);
file_put_contents(__DIR__ . '/site/entries/blog/' . 'post' . $i . '/entry.md',"
---
title: 'Allamco laboris nisi ut aliquip nisi ut aliquip {$i}'
summary: '<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>'
template: blog-post
fieldset: blog-post
description: ''
uuid: 81ce89fa-7a95-4a01-b37f-b7f9b7dc2c9a
<?php
namespace Flextype;
use Flextype\Component\Event\Event;
use Flextype\Component\Filesystem\Filesystem;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Event: onShortcodesInitialized
Event::addListener('onShortcodesInitialized', function () {
@Awilum
Awilum / Http
Created February 6, 2019 07:46
<?php
/**
* @package Flextype Components
*
* @author Sergey Romanenko <awilum@yandex.ru>
* @link http://components.flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
<?php
/**
* @package Flextype
*
* @author Sergey Romanenko <awilum@yandex.ru>
* @link http://flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
<ul class="navbar-nav">
<?php foreach (Arr::sort(Menus::get('default')['items'], 'order') as $item): ?>
<li class="nav-item">
<a class="nav-link <?php if ($item['url'] !== '' && strpos(Http::getUriString(), $item['url']) !== false): ?>active<?php endif ?>" href="<?php if(isset($item['external'])): ?> <?= $item['url'] ?> <?php else: ?> <?= Http::getBaseUrl() . '/' . $item['url'] ?> <?php endif ?>"><?= $item['title'] ?></a>
</li>
<?php endforeach ?>
</ul>
@Awilum
Awilum / multi_language_entries
Created January 18, 2019 13:07
multi_language_entries
$multi_language_entries = true;
// Set current requested entry data to global $entry array
if ($multi_language_entries) {
$locales = ['ru', 'en'];
$default_locale = 'en';
if (in_array(Http::getUriSegment(0), $locales)) {
if (Http::getUriSegment(0) == $default_locale) {
// Simple text-input, for multi-line fields.
textarea
// The hidden field is like the text field, except it's hidden from the content editor.
hidden
// A WYSIWYG HTML field.
html
// A specific WYSIWYG HTML field for entry content editing