Skip to content

Instantly share code, notes, and snippets.

View Alex-Bond's full-sized avatar
🏠
Working from home

Alex Bondarevskyi Alex-Bond

🏠
Working from home
View GitHub Profile
@Alex-Bond
Alex-Bond / mbox_reader.py
Created October 10, 2023 03:24
Fixed MboxReader
import email
from email.policy import default
class MboxReader:
def __init__(self, filename):
self.handle = open(filename, 'rb')
assert self.handle.readline().startswith(b'From ')
def __enter__(self):
RUN apt-get install -y libwebp-dev libde265-dev autotools-dev automake pkg-config libtool wget git make gcc pkg-config autoconf g++ curl
RUN wget https://github.com/strukturag/libheif/archive/v1.6.2.tar.gz && \
tar -xvf v1.6.2.tar.gz && \
cd libheif-1.6.2/ && \
./autogen.sh && \
./configure && \
make && \
make install
@Alex-Bond
Alex-Bond / form.tsx
Last active December 29, 2019 01:17
Smart validator - not finished
import * as React from 'react'
import validate from 'validate.js'
import { ValidationRules } from 'utils/validate'
import { findValueByPath } from 'utils/path'
type FieldConfiguration = {
key: string
validation?: ValidationRules
defaultValue?: any
nested?: FieldConfiguration[]
for _, e := range config.Tasks {
err := c.AddFunc(e.Time, func() {
task := e
out, err := exec.Command("/bin/sh", "-c", task.Command).Output()
if err != nil {
raven.CaptureErrorAndWait(err, map[string]string{"command": e.Command, "time": task.Time})
log.Printf("%s: %s", e.Command, err)
}
if e.Output != nil {
f, err := os.OpenFile(*task.Output, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
# Compile RoadRunner
FROM golang:1.11 as RoadRunner
RUN git clone https://github.com/spiral/roadrunner --branch v1.2.8 /app
WORKDIR /app
RUN ./build.sh Linux
# Build PHP image
<?php
require __DIR__ . "/vendor/autoload.php";
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
$relay = new Spiral\Goridge\StreamRelay(STDIN, STDOUT);
$psr7 = new Spiral\RoadRunner\PSR7Client(new Spiral\RoadRunner\Worker($relay));
<?php
ini_set('display_errors', 'stderr');
use App\Kernel;
use Spiral\Goridge\StreamRelay;
use Spiral\RoadRunner\PSR7Client;
use Spiral\RoadRunner\Worker;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
use Symfony\Component\Debug\Debug;
<div class="row">
<div class="span12">
<h1><?php echo $h1; ?></h1>
</div>
</div>
<form action="" method="POST">
<div class="row">
<div class="span6">
<div class="row">
<div class="span12">
public function actionLogger()
{
$base = Yii::app()->db->createCommand()->select('*')->from('cr_log')->order("when DESC");
$where = array();
$where_replace = array();
if (isset($_GET['username']) AND strlen($_GET['username']) > 0) {
$where[] = 'username LIKE \'%' . $_GET['username'] . '%\'';
}
if (isset($_GET['type']) AND $_GET['type'] != 0) {
$where[] = 'type=:type';
<?php
/**
* Created by Alex Bond at UPDG.
* Date: 2/19/15 6:59 PM
*/
namespace frontend\modules\store\controllers;
use common\models\Categories;