Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / ConcreteMailerHandler.php
Last active July 24, 2018 23:37
[concrete5] [v8]Add logging handler
<?php
namespace Application\Logging\Handler;
use Concrete\Core\Logging\Logger;
use Concrete\Core\Mail\Service;
use Concrete\Core\Support\Facade\Application;
use Monolog\Handler\MailHandler;
class ConcreteMailerHandler extends MailHandler
{
@hissy
hissy / StatusCodeCheck.php
Created June 26, 2018 10:43
#concrete5 Status Code Check Command
<?php
// application/src/Console/Command/StatusCodeCheck.php
namespace Application\Console\Command;
use Concrete\Core\Console\Command;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Http\Client\Client;
use Concrete\Core\Page\Page;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Url\Url;
@hissy
hissy / Entry.php
Last active June 5, 2018 01:12
#concrete5 SmartFormat RSS (An example to customize Zend Feed with Extension)
<?php
// application/src/Feed/Writer/Extension/SmartNews/Entry.php
namespace Application\Src\Feed\Writer\Extension\SmartNews;
use Zend\Feed\Exception\InvalidArgumentException;
use Zend\Feed\Uri;
use Zend\Feed\Writer\Exception\BadMethodCallException;
use Zend\Stdlib\StringUtils;
use Zend\Stdlib\StringWrapper\StringWrapperInterface;
@hissy
hissy / example.sql
Created May 22, 2018 09:28
#concrete5 #mysql count how many workflow request completed between range of dates
select count(wp.wpID)
from WorkflowProgress wp
where wp.wpIsCompleted
and wp.wpCurrentStatus = 30
and wp.wpCategoryID = 1
and wp.wfID = 2
and wp.wpDateLastAction >= "2017-05-01 00:00:00"
and wp.wpDateLastAction < "2017-06-01 00:00:00"
@hissy
hissy / example.sql
Last active May 22, 2018 09:29
#concrete5 #mysql count pages published between range of dates
select count(p.cID)
from Pages p
left join PageTypes pt on p.ptID = pt.ptID
inner join Collections c on p.cID = c.cID
inner join CollectionVersions cv on p.cID = cv.cID
where p.cPointerID < 1
and p.cIsTemplate = 0
and cvIsApproved = 1
and p.cIsActive = true
and p.cIsSystemPage = false
@hissy
hissy / default.php
Created May 19, 2018 02:07
#concrete5 Minimum Foundation6 Theme
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- Compressed CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/foundation.min.css" integrity="sha256-GSio8qamaXapM8Fq9JYdGNTvk/dgs+cMLgPeevOYEx0= sha384-wAweiGTn38CY2DSwAaEffed6iMeflc0FMiuptanbN4J+ib+342gKGpvYRWubPd/+ sha512-QHEb6jOC8SaGTmYmGU19u2FhIfeG+t/hSacIWPpDzOp5yygnthL3JwnilM7LM1dOAbJv62R+/FICfsrKUqv4Gg==" crossorigin="anonymous">
<?php
View::element('header_required', [
'pageTitle' => isset($pageTitle) ? $pageTitle : '',
'pageDescription' => isset($pageDescription) ? $pageDescription : '',
@hissy
hissy / default.php
Created May 19, 2018 02:06
#concrete5 Minimum Bootstrap4 Theme
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
@hissy
hissy / top-hit-filterby-email-read.sql
Created March 29, 2018 19:48
#mautic #mysql Get most common page hits by users who opened a specific email
select count(page_hits.url) as count, page_hits.url
from page_hits
left join leads on page_hits.lead_id = leads.id
left join email_stats on leads.id = email_stats.lead_id
where email_stats.is_read = 1 and email_stats.email_id = 20
group by page_hits.url
order by count desc
limit 50;
@hissy
hissy / top-hit-by-segment-users.sql
Created March 29, 2018 19:11
#mautic #mysql Get most common page hits by specific segment users
select count(page_hits.url) as count, page_hits.url
from page_hits
left join leads on page_hits.lead_id = leads.id
left join lead_lists_leads on leads.id = lead_lists_leads.lead_id
left join lead_lists on lead_lists.id = lead_lists_leads.leadlist_id
where lead_lists.id = 31
group by page_hits.url
order by count desc
limit 10;
@hissy
hissy / http-api-error-log.php
Created March 3, 2018 05:53
[WordPress Plugin] Logging HTTP API Request Errors
<?php
/*
Plugin Name: HTTP API DEBUG LOG
Version: 0.1
*/
add_action('http_api_debug', function ($response, $context, $class, $r, $url) {
// $response = new WP_Error('http_request_failed', 'debug');
/** @var WP_Error $response */