Skip to content

Instantly share code, notes, and snippets.

@DBasic
DBasic / Yii # actionBatchUpdate method.php
Last active August 29, 2015 13:57
Yii # actionBatchUpdate method
public function actionBatchUpdate()
{
// retrieve items to be updated in a batch mode
// assuming each item is of model class 'Item'
$items=$this->getItemsToUpdate();
if(isset($_POST['Item']))
{
$valid=true;
foreach($items as $i=>$item)
{
@DBasic
DBasic / global.php
Created March 5, 2014 21:36
Yii # global.php (Shortcuts)
<?php
/**
* global.php file.
* Global shorthand functions for commonly used Yii methods.
* @author Christoffer Niska <christoffer.niska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2013-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
@DBasic
DBasic / Yii # loadModel method.php
Last active August 29, 2015 13:57
Yii # loadModel method
/**
* Возвращает модель основываясь на первичном ключе полученном из GET переменной,
* если модель не найдена, кидает HTTP исключение.
* @param string $type тип модели
* @param int $id первичный ключ
* @param string $errorMessage [optional] сообщение об ошибке
* @param int $errorNum [optional] код HTTP ошибки
* @return CActiveRecord модель полученную с помощью первичного ключа.
* @throws CHttpException
*/
@DBasic
DBasic / git_move.sh
Created March 7, 2014 07:30
Git # Move repository
#!/usr/bin/env bash
# Usage:
# ./git_move.sh git@repo_site.com:/my_repo.git origin/folder/path/ /destination/repo/path/ new/folder/path/
repo=$1
folder=$2
dest_repo=$3
dest_folder=$4
clone_folder='__git_clone_repo__'
@DBasic
DBasic / SP.php
Created March 8, 2014 17:45 — forked from stden/SP.php
/**
* @static Вызов хранимой процедуры
* @param $sp_name Название хранимой процедуры
* @param $params
* @return array
*/
public static function Query($sp_name, $params)
{
// Получаем CommandBuilder
$b = Yii::app()->db->getCommandBuilder();
@DBasic
DBasic / juiautocomplete
Created March 14, 2014 11:00
jQuery UI Autocomplete _renderItem usage.
$("#some_id")
.autocomplete({
...
}).data("ui-autocomplete")._renderItem = function (ul, item) { ... };
If you want to create the _renderItem function for multiple autocompletes with id #some_id just use it in the create event:
$('#some_id').autocomplete({
create: function() {
$(this).data('ui-autocomplete')._renderItem = function (ul, item) { ... };
@DBasic
DBasic / placeholder.scss
Last active August 29, 2015 14:03 — forked from antsa/placeholder.scss
[SASS] Placeholder mixin
// Placeholder @mixin for Sass
//
// A mixin to style placeholders in HTML5 form elements.
// Includes also a .placeholder class to be used with a polyfill e.g.
// https://github.com/mathiasbynens/jquery-placeholder
// Requires Sass 3.2.
//
// Example usage (.scss):
//
// input {
@DBasic
DBasic / gist:83ea6e45ff4868102e67
Created July 17, 2014 13:35
Проблема с отрисовкой submit кнопки на iOS
-webkit-appearance: none;
@DBasic
DBasic / gist:3fde15b61c81178c12f2
Created July 17, 2014 13:36
Prevent iPhone default keyboard when focusing an <input>
By setting the input field to readonly="true" you should prevent anyone typing anything in it, but still be able to launch a click event on it.
This is also usefull in non-mobile devices as you use a date/time picker
@DBasic
DBasic / github-oauth2-client.php
Last active December 8, 2016 09:56
[php] github oauth2 authorization
<?php
define('OAUTH2_CLIENT_ID', '');
define('OAUTH2_CLIENT_SECRET', '');
$authorizeURL = 'https://github.com/login/oauth/authorize';
$tokenURL = 'https://github.com/login/oauth/access_token';
$apiURLBase = 'https://api.github.com/';
session_start();