Skip to content

Instantly share code, notes, and snippets.

View motin's full-sized avatar

Motin motin

View GitHub Profile
@motin
motin / chrome-console-javascript.js
Created January 15, 2016 10:56
Code to reproduce an encoding issue with copy as cURL in Chrome Developer Tools
var http = new XMLHttpRequest();
var params = '{"utf-8 characters": "åäöéñ"}';
http.open("POST", 'http://localhost:9000/', true);
http.setRequestHeader("Content-type", "application/json; charset=utf-8");
http.send(params);
@motin
motin / hmac-sign.php
Last active September 15, 2021 21:41
PHP equivalent of hmac.new(secret, message, hashlib.sha256).hexdigest()
<?php
$message = 'Message';
$secret = 'secret';
print "php\n";
print hash_hmac('SHA256', $message, $secret) . "\n";
<?php
use Propel\Generator\Model\Column;
use Propel\Generator\Model\Database;
use Propel\Generator\Model\ForeignKey;
use Propel\Generator\Model\Index;
use Propel\Generator\Model\Table;
use Propel\Generator\Model\Unique;
use Propel\Generator\Model\PropelTypes;
use Propel\Generator\Model\ColumnDefaultValue;
var module = angular.module('performantHandsontable', []);
module.factory('performantHandsontableFactory', [
function () {
return {
containerClassName: 'handsontable-container',
instance: null,
/**
* Append handsontable container div and initialize handsontable instance inside element
@motin
motin / ElasticsearchCommand.php
Created April 20, 2015 10:49
Old command from a project a couple of years ago to maintain elastic search indexes of contents stored in RDBMS tables using Yii 1
<?php
class ElasticSearchCommand extends AppConsoleCommand
{
public $model;
/**
* Fills ElasticSearch index from database contents
* @param <type> $modelRef
@motin
motin / StandardStreamsLogRoute.php
Created March 11, 2015 04:37
Workaround to get docker logs output for Yii 1 log routes when running in PHP-FPM
<?php
class StandardStreamsLogRoute extends CLogRoute
{
public function processLogs($logs)
{
foreach ($logs as $log) {
error_log('STDOUT: ' . $log[0]);
}
}
@motin
motin / composer.json
Created March 9, 2015 12:27
Composer example output - Your requirements could not be resolved to an installable set of packages
{
"name": "foo/project",
"description": "Foo project",
"keywords": ["yii", "web", "application", "cms"],
"type": "yii-application",
"license": "BSD-3-Clause",
"repositories": [
{
"type": "vcs",
"url": "git@github.com:neam/yii2-sir-trevor-js.git"
@motin
motin / DataModel.php
Last active August 29, 2015 14:16
Sample giic configuration for yii-dna model generation
<?php
class DataModel
{
/**
* The corresponding qa state models used by yii-qa-state
* @return array
*/
static public function qaStateModels()
@motin
motin / BehaviorActionControllerTrait.php
Created February 26, 2015 22:18
Yii 1. Allows controllers that use it to inherit actions from behaviors
<?php
/**
* BehaviorActionControllerTrait.php
*
* Allows controllers that use it to inherit actions from behaviors
* @author Brett O'Donnell <cornernote@gmail.com>
* Idea by Yii user Mimin and Kevin Higgins
* @link http://www.yiiframework.com/forum/index.php/user/9488-mimin/
* @link http://www.yiiframework.com/forum/index.php/user/24587-kevin-higgins/
* Relevant discussion in Yii Forum
@motin
motin / userapp.io-mock-api-blueprint.md
Last active August 29, 2015 14:13
Userapp.io Mock API Blueprint

FORMAT: 1A HOST: http://127.0.0.1:3000

Userapp.io Mock API

A simple mock api for Userapp.io that mocks api responses. For offline local development, install api-mock (npm -g install api-mock) and run:

git clone https://gist.github.com/c0812bc687804b526a2b.git userappiomock
api-mock userappiomock/userapp.io-mock-api-blueprint.md --port 3000 --cors-disable false

The local api is then available on http://localhost:3000/