Skip to content

Instantly share code, notes, and snippets.

View ruslanchek's full-sized avatar
🎯
Focusing

Mike Burton ruslanchek

🎯
Focusing
View GitHub Profile
var Templates = function(){
this.tmpls = {};
function renderer(html, data){
for (var p in data) {
if (data.hasOwnProperty(p)) {
html = html.replace(new RegExp('%' + p + '%', 'g'), data[p]);
}
}
@ruslanchek
ruslanchek / jquery.KVNum.js
Created November 7, 2014 12:44
Price formatter
(function ($) {
$.fn.KVNum = function (method) {
var settings = {
};
function process($input){
var input = $($input)[0];
var value = $input.val(),
@ruslanchek
ruslanchek / nginx
Created November 21, 2014 11:54
Nginx Kvadroom
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@ruslanchek
ruslanchek / designer.html
Last active August 29, 2015 14:13
designer
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../notification-elements/notification-alert.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-calculator/paper-calculator.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@ruslanchek
ruslanchek / gist:b62616ccd7c9979a0ce7
Last active August 29, 2015 14:13
Click outside JS class
var UIClickOutside = function(container, onClickOutside){
var $container = $(container);
this.bind = function(){
$(document).on('mouseup.UIClickOutside', function (e){
if (!$container.is(e.target) && $container.has(e.target).length === 0){
if(onClickOutside) onClickOutside(e.target);
}
});
};
<?php
function showOAuthError($error, $error_description){
if($error == 'access_denied'){
header("Location: http://".$_SERVER['HTTP_HOST']);
}else{
$error = '<strong>Error: '.$error.'</strong>
<p>'.preg_replace('/\+/', ' ', $error_description).'</p>';
die($error);
};
@ruslanchek
ruslanchek / db
Created October 25, 2012 16:46
DB PHP
<?php
class Database extends Core {
private
$link,
$db_vars,
$enconing = 'utf8';
public function __construct($host, $db, $user, $pass){
$this->db_vars = new stdClass();
@ruslanchek
ruslanchek / core.js
Last active December 20, 2015 10:20
Очеловечивание времени - выводит дату в человеческом формате (27 июля, 2013, 21:00:15). Работает как со строками вида MySQL Timestamp, так и с простым объектом Date.
function humanizeDate(date, output_with_time) {
if(!(Object.prototype.toString.call(date) === "[object Date]")){
var t = date.split(/[- :]/);
date = new Date(t[0], t[1] - 1, t[2], t[3], t[4], t[5]);
}
if (!date) {
return '&mdash;';
}
@ruslanchek
ruslanchek / AppDispatcher.ts
Last active April 23, 2016 10:40 — forked from tgroshon/AppDispatcher.js
A Flux Dispatcher with an Action Queue sitting on top to allow dispatching actions at any time.
import {Dispatcher} from 'flux';
const DELAY_TIME = 100;
export class QDispatcher {
private dispatcher:Dispatcher = null;
private isProcessing:boolean = false;
private actionQueue:any[] = [];
constructor() {
export interface Browser {
name:string,
version:any,
osversion:string,
tablet:boolean,
mobile:boolean,
opera:boolean,
chromeBook:boolean,
chrome:boolean,
yandexbrowser:boolean,