Skip to content

Instantly share code, notes, and snippets.

@obojdi
obojdi / checkHeight.js
Created September 25, 2014 12:53
overlay popup with height breakpoint
var breakpoint_1 = 800;
function checkHeight(){
var wh = $(window).height() || window.innerHeight || root.clientHeight || body.clientHeight ;
if (wh<=breakpoint_1){
$('html').addClass('smallscreen');
}else{
$('html').removeClass('smallscreen');
};
$('.popup').css('margin-left', $('.popup').width() / -2);
@obojdi
obojdi / POST_dynamic_fields.php
Created November 6, 2014 15:14
Handle POST from dynamically added form fields
<div class="button insert">Добавить поле</div>
<form class="ui-filterable" method="POST">
<?
$sum=4;
for ($count=0; $count <$sum ; $count++)
{
?>
<input type="text" class="input text" name="preset[]" placeholder="text" value="preset text <?=$count?>"/>
<?}?>
<input class="button submit" type="submit">
@obojdi
obojdi / ymaps_geo.js
Created January 13, 2015 15:36
Coordinates from string address
$('.geocode').click(function(e){
e.preventDefault();
var address = $('[name="address"]').val();
console.log(address)
$.ajax(
{
url:'http://geocode-maps.yandex.ru/1.x/?format=json&geocode='+address
}
).success(function(data){
var resp = data.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos
@obojdi
obojdi / .htaccess
Created February 4, 2015 10:41
apache standard conf
DirectoryIndex index.php
ErrorDocument 404 /404/
RewriteEngine On
Options +FollowSymlinks
Options -Indexes -MultiViews
@obojdi
obojdi / pepyaka_text.js
Created August 11, 2016 11:31
Пепячиватель текста
//подставить в el DOM-селектор попячиваемого элемента
function pepyachka(el) {
if (typeof window.jQuery == "undefined") {
var g = document.createElement('script');
g.type = "text/javascript";
g.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js";
document.head.appendChild(g);
}
var
a = document.createElement('link'),
@obojdi
obojdi / .zshrc
Created September 7, 2016 09:12
babun zsh
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
alias grep="/usr/bin/grep $GREP_OPTIONS"
unset GREP_OPTIONS
export CYGWIN="nodosfilewarning mintty detect_bloda"
echo -ne '\eP\e]10;#CCCCCC\a' # Foreground -> base0
echo -ne '\eP\e]11;#2D2D2D\a' # Background -> base03
echo -ne '\eP\e]12;#00AAFF\a' # Cursor -> red
@obojdi
obojdi / script.js
Created June 30, 2017 13:41
lightningmaps.org restyling
var a = setInterval(function() {
$('canvas').parent().addClass('canvas');
}, 1000)
@obojdi
obojdi / imageUploader.php
Created August 1, 2017 16:35
Image uploader class
<?php
/**
* Image uploader
*/
class ImageUploader
{
private $this;
private $id;
private $uploadPath;
public $updateId;
@obojdi
obojdi / check_user.php
Created August 2, 2017 09:11
random username checker
<?php
$dbh = ['user_10', 'user_02', 'user_05', 'user_08', 'user_07', 'user_06', 'user_09'];
$a = function ($un = '') use ($dbh, &$a){
$random_digit = sprintf("%02d", rand(0, 10));
$username_random = "user_" . $random_digit;
if(strlen($un)){
$username = $un;
}else{
$username = $username_random;
}