Skip to content

Instantly share code, notes, and snippets.

View ZhandosKz's full-sized avatar
🎯
Focusing

Zhandos ZhandosKz

🎯
Focusing
View GitHub Profile
package main
import (
"fmt"
"sync"
"time"
)
func main() {
@ZhandosKz
ZhandosKz / array.go
Created September 10, 2015 14:32
array pointer and array of pointers
package main
import "fmt"
func main() {
string1 := "one"
string2 := "two"
string3 := "three"
array1 := &[]string{
@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>
$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());
<?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) );
<?php
public function actionReplica() {
$this->file = fopen('update.sql', 'r');
if (!$this->file) {
throw new CHttpException(404, 'no worker');
}
flock($this->file, LOCK_EX);
$output = fopen('update_2.sql', 'w');
@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
@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: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
<?php
class Foo
{
public $firstValue;
public $secondValue;
public $thirdValue;
public function __construct($v1, $v2, $v3)
{
// ...
}