Skip to content

Instantly share code, notes, and snippets.

View kladov's full-sized avatar

Boris Kladov kladov

View GitHub Profile
@kladov
kladov / getZodiacSign.js
Last active October 17, 2023 04:39
Zodiac sign (javascript)
/**
* Return zodiac sugn by month and day
*
* @param day
* @param month
* @return {string} name of zodiac sign
*/
function getZodiacSign(day, month) {
var zodiacSigns = {
@kladov
kladov / validator.js
Created August 31, 2013 10:50
validate something in javascript
function Validate () {
this.byValidatorsArray = function(value, validators) {
var result = true;
var arrayLength = validators.length;
for(var i = 0; i < arrayLength; i++) {
if(!this[validators[i]](value)) {
result = false;
}
}
@kladov
kladov / endOfWordByQuantity.php
Last active December 22, 2015 01:38
return ending of word by quantity
<?php
/**
* Возвращает слово с нужным окончанием в зависимости от количества
*
* @param int $n - количество в зависимости от которого необходима нужная форма слова
* @param string $form1 - форма слова для 1 штуки
* @param string $form2 - форма слова для 2 штук
* @param string $form2 - форма слова для 11 штук
*/
function get_end_of_word_by_quantity($n, $form1, $form2, $form5)
@kladov
kladov / .bashrc
Last active December 22, 2015 01:39
Prepare for work with git
#~/.bashrc
alias go='git checkout '
@kladov
kladov / gist:8576544
Last active January 4, 2016 05:39
symfony 1.4 - get all form errors by field
<?php
//symfony 1.4 - get all form errors by field
foreach( $this->form->getFormFieldSchema( ) as $name => $formField )
{
if( $formField->getError( ) != "" )
{
print( $name . " : " . $formField->getError( ) . "\n" );
}
}
newExcitingAlerts = (function () {
var oldTitle = document.title;
var msg = "New!";
var timeoutId;
var blink = function() { document.title = document.title == msg ? ' ' : msg; };
var clear = function() {
clearInterval(timeoutId);
document.title = oldTitle;
window.onmousemove = null;
timeoutId = null;
@kladov
kladov / only-number.js
Last active September 28, 2018 08:26
set only number input
$(function(){
$('#some-element').on('keypress keydown', isNumber);
})
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 37 && charCode != 39 && charCode != 46) {
return false;
@kladov
kladov / rm-all-docker-images-containers.sh
Created August 10, 2017 13:34
Docker remove all Images and Containers
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
// formatRequest generates ascii representation of a request
func formatRequest(r *http.Request) string {
// Create return string
var request []string
// Add the request string
url := fmt.Sprintf("%v %v %v", r.Method, r.URL, r.Proto)
request = append(request, url)
// Add the host
request = append(request, fmt.Sprintf("Host: %v", r.Host))
// Loop through headers
brew tap grpc/grpc
brew install --with-plugins grpc