Skip to content

Instantly share code, notes, and snippets.

View Naktibalda's full-sized avatar

Gintautas Miselis Naktibalda

  • Vilnius, Lithuania
View GitHub Profile
@Naktibalda
Naktibalda / test.php
Created April 1, 2019 07:48
Perl script reads line from stdin, writes response to stdout. It doesn't work when executed from php
<?php
$descriptors = [
0 => ["pipe", "r"], // stdin is a pipe that the child will read from
1 => ["pipe", "w"], // stdout is a pipe that the child will write to
2 => ["pipe", "w"], // stderr is a file to write to
];
$pipes = [];
$command = 'perl test.pl';
$process = proc_open($command, $descriptors, $pipes);
@Naktibalda
Naktibalda / testmybot.spec.js
Created September 6, 2017 15:44
Setting up testmybot
var env = require('node-env-file');
env(__dirname + '/../.env');
const botkitHelper = require('@naktibalda/testmybot/helper/botkit');
const mochaHelper = require('@naktibalda/testmybot/helper/mocha');
const Botkit = require('botkit');
const bot = require('../build/bot.js').default;
const controller = Botkit.facebookbot({access_token: 'test', verify_token: 'test'});
@Naktibalda
Naktibalda / Helper_Unit.php
Created November 13, 2015 12:18
assertMatchesTypes method
<?php
namespace Helper;
use Codeception\Util\JsonType;
class Unit extends \Codeception\Module
{
public function assertMatchesTypes(array $types, array $data, $message = null)
{
$jsonType = new JsonType($data);
<?php
function get_menu_items( $menu_name ) {
if( !$menu_name )
return false;
if( ( $locations = get_nav_menu_locations() ) && isset( $locations[$menu_name] ) ) {
$menu = wp_get_nav_menu_object( $locations[$menu_name] );
$menu_items = wp_get_nav_menu_items( $menu->term_id ) ;
<?php
function staticReturn()
{
if(isset($static_user))
{
return $static_user;
}
$user = fetchUser();
static $static_user = $user;