Skip to content

Instantly share code, notes, and snippets.

View yakirh's full-sized avatar

Yakir Hanoch yakirh

View GitHub Profile
@yakirh
yakirh / API.php
Created December 8, 2013 14:07
custom - to - http - exceptions
protected function _execute($action)
{
try
{
try
{
$this->{$action}();
}
catch (\ResourceBundle\Model\Exception\NotFound $e)
{
@yakirh
yakirh / clock.mustache
Last active December 25, 2015 18:59
Time range exercise
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1 id="message"></h1>
<script type="text/javascript">
var now = new Date,
hoursFloat = now.getHours()+(now.getMinutes()/60),
@yakirh
yakirh / time.mustache
Last active December 25, 2015 18:59
JS Timer exercise
<!DOCTYPE html>
<html>
<head>
<title>Timer</title>
</head>
<body>
<h2>Current Time: </h2>
<div id="time"></div>
<script type="text/javascript">
var now,
@yakirh
yakirh / test.html
Created October 13, 2013 14:40
Time range exercise
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1 id="message"></h1>
<script type="text/javascript">
var now = new Date,
hours_float = now.getHours()+(now.getMinutes()/60),
@yakirh
yakirh / timer.html
Created October 13, 2013 13:38
JS Timer exercise
<!DOCTYPE html>
<html>
<head>
<title>Timer</title>
</head>
<body>
<h2>Current Time: </h2>
<div id="time"></div>
<script type="text/javascript">
var now;
@yakirh
yakirh / Geo.php
Created August 13, 2013 15:51
repository instances without DI container
public function post_collection()
{
$result =
(
new Context_Installer_Geo_Create(
$this->_request_payload,
new Repository_Product,
new Repository_Installer,
new Repository_Installer_Geo,
new Repository_Installer_Geo_Step,
@yakirh
yakirh / home.php
Created August 6, 2013 09:42
Testing random alphanumeric token exercise
<?php
try
{
$length = 8;
$start_time = microtime(TRUE);
for ($i = 1; $i <= 10000; $i++)
{
$token = $this->rand_alphanumeric($length);
if (strlen($token) !== $length)
throw new Exception('Token "'.$token.'" length is invalid. token length is '.(strlen($token)).' instead of '.$length);
@yakirh
yakirh / jquery.js
Created July 31, 2013 14:10
submit filtes on some events
$(document)
// ----------- Submit filters form when ----------- //
// - changing text inputs
.on('keyup', 'form.filters input[type="text"]', function() {
$(this).parents('form:first').trigger('submit');
})
// - changing select-box option
// - toggling checkboxes
.on('change', 'form.filters select, form.filters input[type="checkbox"]', function() {
$(this).parents('form:first').trigger('submit');
@yakirh
yakirh / Domain.php
Last active December 20, 2015 09:49
LEFT join should be after the total query
<?php
// Join Accounts table
$select
->join('accounts', 'INNER')
->on('accounts.id', '=', 'domains.account_id')
->group_by($this->table_name.'.id', 'accounts.id');
// Count select query records
$total_count = $this->get_query_total_count($select);
if (this.model.metadata.active_installers.length) {
var dialogView = new ItemView({
model: template,
template: tplTitle,
form: {
className: 'form-horizontal',
buttons: false
},