Skip to content

Instantly share code, notes, and snippets.

View bocharsky-bw's full-sized avatar
💔
#StandWithUkraine 🇺🇦

Victor Bocharsky bocharsky-bw

💔
#StandWithUkraine 🇺🇦
View GitHub Profile
@bocharsky-bw
bocharsky-bw / bw-timer.js
Last active August 29, 2015 13:57
Count down timer in seconds
function BWTimer(_delay, _step) {
var self = this;
/**
* Delay in seconds
*/
var delay = _delay;
/**
@bocharsky-bw
bocharsky-bw / oop.js
Last active August 29, 2015 13:57
Create class with object constructor and public/private properties and methods.
function MyClass(publicVal, privateVal) {
var self = this;
/**
* Public Property
*/
this.publicValue = publicVal;
@bocharsky-bw
bocharsky-bw / doctrine-default-value.php
Created March 25, 2014 10:45
Default value of the field in Doctrine 2
<?php
/**
* @var string $surname
*
* @ORM\Column(name="surname", type="string", length=255, options={"default" = ""})
*/
private $surname;
@bocharsky-bw
bocharsky-bw / default-values.php
Last active August 29, 2015 13:57
Passed array options with default values
<?php
public function __construct(array $options = array()) {
/* By default */
$options = array_merge(
array(
'one' => 1,
'two' => 2,
'three' => 3,
),
<?php
$data = new stdClass();
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
/* Router */
if (isset($_POST['buy'])) {
$data->success = TRUE;
$data->message = 'Message succesfully sent';
@bocharsky-bw
bocharsky-bw / display-errors.php
Created March 14, 2014 13:18
Display errors in PHP
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
@bocharsky-bw
bocharsky-bw / call.php
Last active April 14, 2017 00:19
Automatic call getter and isser methods
<?php
public function __call($method, $arguments) {
if ( method_exists($this->lang, $method) ) {
return call_user_func_array(array($this->lang, $method), $arguments);
}
$getter = 'get'. ucfirst($method);
if ( method_exists($this->lang, $getter) ) {
@bocharsky-bw
bocharsky-bw / dump-array-keys.php
Last active August 29, 2015 13:56
Dump array keys
<?php
foreach ($result as $key => $value) {
var_dump($key);
}