Skip to content

Instantly share code, notes, and snippets.

View ZhandosKz's full-sized avatar
🎯
Focusing

Zhandos ZhandosKz

🎯
Focusing
View GitHub Profile
$users = User::model()->findAll();
/**
* @var CAuthManager $authManager
*/
$authManager = Yii::app()->authManager;
$statuses = array(
ExtendedDbAuthManager::APPROVED => 0,
ExtendedDbAuthManager::BANNED => 0,
@ZhandosKz
ZhandosKz / gist:6269679
Last active December 21, 2015 07:09
TbJsonGridView example
<?php
// Controller
class TestController extends CController
{
public function actionIndex()
{
$items = array(
array('id' => 1, 'name' => 'Debora'),
array('id' => 2, 'name' => 'Joshua'),
array('id' => 3, 'name' => 'Kristina'),
@ZhandosKz
ZhandosKz / gist:6464831
Created September 6, 2013 14:45
import sql file from comand line
mysql -uusername -p
enter password
use tablename
source path_to_sql_file
@ZhandosKz
ZhandosKz / gist:6745376
Last active December 24, 2015 04:39
google maps v3 geocoder
<?php
class Geocoder
{
public static $url = 'http://maps.googleapis.com/maps/api/geocode/json';
public function performRequest($search)
{
$url = sprintf("%s?address=%s&sensor=false", self::$url, urlencode($search));
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@ZhandosKz
ZhandosKz / gist:6786141
Created October 1, 2013 22:20
carbage collector
git reflog expire --expire=now --expire-unreachable=now --all
git gc --prune=now
<?php
function getGeo($lat, $lng, $dist, $brng)
{
$lat = deg2rad($lat);
$lng = deg2rad($lng);
$brng = deg2rad($brng);
$distRadius = $dist / 6371;
$lat2 = asin(sin($lat) * cos($distRadius) +
cos($lat) * sin($distRadius) * cos($brng) );
$location->country_long = 'Canada';
$location->country_short = 'CA';
$location->city_long = "Saint John's";
$this->assertTrue($location->save());
$this->assertEquals(Location::ALIAS_PREFIX . 'Saint-John-s-Canada', $location->alias);
$this->assertEquals('Saint-John-s-Canada', $location->getUrl());
@ZhandosKz
ZhandosKz / a.html
Created July 21, 2015 12:03
mail header snippet
<tr>
<td class="one-column content">
<div class="column">
<table class="inner" width="100%" cellpadding="10" cellspacing="0">
<tr>
<td>
<div class="h3">Dear Rodrigo,</div>
<div class="h1"><br>Join people you know:</div>
</td>
</tr>
package main
import (
"fmt"
"sync"
"time"
)
func main() {