Skip to content

Instantly share code, notes, and snippets.

View kickboxer's full-sized avatar
🕊️

Maksim Mnatsakanov kickboxer

🕊️
View GitHub Profile
@kickboxer
kickboxer / ajax отправка формы на email с помощью jQuery и php
Last active July 3, 2023 21:14
ajax отправка формы на email с помощью jQuery и php
$(document).ready(function() { // вся магия после загрузки страницы
$("#ajaxform").submit(function(){ // перехватываем все при событии отправки
var form = $(this); // запишем форму, чтобы потом не было проблем с this
var error = false; // предварительно ошибок нет
form.find('input, textarea').each( function(){ // пробежим по каждому полю в форме
if ($(this).val() == '') { // если находим пустое
alert('Заполните поле "'+$(this).attr('placeholder')+'"!'); // говорим заполняй!
error = true; // ошибка
}
});
@kickboxer
kickboxer / CSS clearfix
Last active August 29, 2015 14:14
CSS clearfix
.clearfix:after {
clear: both;
color: transparent;
content: ".";
display: block;
font-size: 0;
zoom: 1;
}
@kickboxer
kickboxer / scrollTo.js
Created January 27, 2015 08:57
jQuery scrollTo
$(function(){
$('a[href^="#"]').click(function(){
var target = $(this).attr('href');
$('html, body').animate({scrollTop: $(target).offset().top}, 1000);
return false;
});
});
// СВОЙСТВА И АТРИБУТЫ: prop and attr
// =======================================
// PROP - для disabled
// правильно
$("input").prop('disabled', true);
$("input").prop('disabled', false);
// не правильно!
@kickboxer
kickboxer / Angular checkbox CheckAll.js
Last active August 29, 2015 14:20
Angular checkbox CheckAll
$scope.options = [
{value:'Option1', selected:true},
{value:'Option2', selected:false},
{value:'Option3', selected:false},
{value:'Option4', selected:false},
{value:'Option5', selected:false},
{value:'Option6', selected:false}
];
$scope.toggleAll = function() {
@kickboxer
kickboxer / Generate password.js
Created June 26, 2015 14:33
Generate password
function passGen(charsCount) {
var result = '';
var words = '0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
var max_position = words.length - 1,
position,
i;
for(i = 0; i < charsCount; ++i) {
position = Math.floor (Math.random() * max_position);
result = result + words.substring(position, position + 1);
}
'use strict';
var React = require('react-native');
var {
Bundler,
StyleSheet,
Text,
TouchableHighlight,
View,
ScrollView,
@kickboxer
kickboxer / gist:5028d7d602da63ac5769
Created February 19, 2016 08:49 — forked from marty-wang/gist:5a71e9d0a6a2c6d6263c
Compile and deploy React Native Android app of Release version to device.
Disclaimer: The instructions are the collective efforts from a few places online.
Nothing here is my original. But I want to put them together in one place to save people from spending the same time as I did.
First off, bundle.
==================
1. cd to the project directory
2. Start the react-native packager if not started
3. Download the bundle to the asset folder:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
@kickboxer
kickboxer / gist:abed5b29f6d3a3fd55e0a6ee254d4498
Created October 3, 2016 14:00
Создать новый массив с объектами с уникальными свойствами
var districts = [];
function removeDuplicateDistricts(cities) {
for (let i = 0; i < cities.length; i++) {
if (districts.length === 0) {
districts.push(cities[0]);
} else {
var uniqueDistrict = true;
districts.forEach(function(dist) {
if (cities[i].Region == dist.Region && cities[i].District == dist.District) {
uniqueDistrict = false;
@kickboxer
kickboxer / gist:710263ed096bff90fbf5558d1888d145
Created August 23, 2018 12:12
Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
// Чтобы git не конвертировал переносы строк автоматом в crlf в скачиваемых репозиториях, прописываем это комманду:
git config --global core.autocrlf false