Skip to content

Instantly share code, notes, and snippets.

@dshster
dshster / resize.jsx
Last active August 29, 2015 14:02
Скрипт уменьшения изображений в Adobe Photoshop для публикации в веб
#target photoshop
app.bringToFront();
$.localize = true;
var target_size = 999;
var tmp_target_size = target_size * 2;
var inputFolder = Folder.selectDialog("Выберите папку с фотографиями");
@dshster
dshster / modslasses.js
Last active August 29, 2015 14:02
bem classes modifiers
(function() {
'use strict';
var delimiter = '--';
DOMTokenList.prototype.modify = function(mod) {
if (false === tag.classList.modified(mod)) {
this.add([this[0], delimiter, mod].join(''));
}
};
HTMLTextAreaElement.prototype.getCaretPosition = function () { //return the caret position of the textarea
return this.selectionStart;
};
HTMLTextAreaElement.prototype.setCaretPosition = function (position) { //change the caret position of the textarea
this.selectionStart = position;
this.selectionEnd = position;
this.focus();
};
HTMLTextAreaElement.prototype.hasSelection = function () { //if the textarea has selection then return true
if (this.selectionStart == this.selectionEnd) {
@dshster
dshster / gulpfile.js
Created July 6, 2014 09:30
Gulp less basic task
/* global require */
'use strict';
var gulp = require('gulp'),
less = require('gulp-less');
gulp.task('less', function() {
gulp.src('styles/less/bootstrap.less')
.pipe(less({
compress: true
@dshster
dshster / gist:d77a3b660590bd4ab4e1
Last active August 29, 2015 14:06
callbackhunter popup fire
down = document.createEvent("MouseEvents");
down.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
document.getElementById('clbh_phone_div').dispatchEvent(down)
up = document.createEvent("MouseEvents");
up.initMouseEvent("mouseup", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
document.getElementById('clbh_phone_div').dispatchEvent(up)
@dshster
dshster / index.html
Created February 11, 2015 21:01
Drag and drop, resize and xhr post
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<title>Filereader</title>
</head>
<body>
<div id="dragarea" class="drag-area"></div>

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@dshster
dshster / application.js
Last active August 29, 2015 14:17
AngularJS backend-less development
'use strict';
var application = 'application';
var dependences = ['ngMockE2E'];
angular.module(application, dependences)
.config(['$compileProvider', function($compileProvider) {
$compileProvider.debugInfoEnabled(false);
}])
@dshster
dshster / gist:3103740
Created July 13, 2012 08:51 — forked from sapegin/gist:925002
CSS3 Buttons in Springhare
/* Button */
button, input[type="submit"] {
display: inline-block;
padding: 2px 20px;
background: #c4c4c4;
background: -webkit-linear-gradient(top, #eee, #c4c4c4);
background: -moz-linear-gradient(top, #eee, #c4c4c4);
background: -ms-linear-gradient(top, #eee, #c4c4c4);
background: -o-linear-gradient(top, #eee, #c4c4c4);
background: linear-gradient(top, #eee, #c4c4c4);
// Originally solved by Tim Branyen in his drop file plugin
// http://dev.aboutnerd.com/jQuery.dropFile/jquery.dropFile.js
jQuery.event.props.push('dataTransfer');