Skip to content

Instantly share code, notes, and snippets.

@kachar
kachar / gist:b2773353ef25a8f3100e
Created October 21, 2014 07:45
twig extension
class Project_Set_TokenParser extends \Twig_TokenParser
{
public function parse(\Twig_Token $token)
{
$parser = $this->parser;
$stream = $parser->getStream();
$name = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
$stream->expect(\Twig_Token::OPERATOR_TYPE, '(');
$value = $parser->getExpressionParser()->parseExpression();
jQuery('.wcml_details').on('click', function() {
var close = jQuery(this);
var id = close.attr('href');
setTimeout(function() {
var row = jQuery('.wcml_product_row'+id);
var table = jQuery('.wcml_products_translation', row);
var textarea = jQuery('textarea', table);
var source = jQuery('.edit_slug_block', table).prev('br').prev('textarea')
var dest = jQuery('.edit_slug_block', table).prev('textarea');
dest.html(source.html()).trigger('change');
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test case | Fancytree</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" type="text/javascript"></script>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'question-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'question',
'answer_a',
'answer_b',
array(
@kachar
kachar / pooling1.php
Last active January 3, 2016 08:09
yii long polling
<?php
if(Yii::app()->request->isAjaxRequest) {
session_write_close();
$linesToLoad = $totalLines-$currentLine;
if($linesToLoad == 0) {
echo CJSON::encode(array(
'type' => 'no data',
'currentLine' => $currentLine,
"totalLines" => $totalLines,
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;
use Zend\Mvc\Console\Controller\AbstractConsoleController;
@kachar
kachar / markup.html
Last active February 22, 2019 14:51
nextjs + SASS
<div class="test___1F_O8 we-test-this-class">Test<div class="best___56sMK">Best</div></div>
@kachar
kachar / actions.js
Created July 1, 2019 21:30
actions.js
import React from 'react'
import _ from 'lodash'
import PropTypes from 'prop-types'
import lang from 'lang'
import Form from 'common/components/form'
import './actions.scss'
export default class EmotionWordActions extends Form {
@kachar
kachar / RouteIndicator.tsx
Last active March 8, 2020 23:51 — forked from jaydenseric/RouteIndicator.js
A route change indicator for Next.js using React hooks.
import cn from 'classnames'
import Router from 'next/router'
import React, { useState } from 'react'
const DONE_DURATION = 250
export default function RouteIndicator() {
const [loading, setLoading] = useState(false)
const [timeoutId, setTimeoutId] = useState<ReturnType<typeof setTimeout>>()