Skip to content

Instantly share code, notes, and snippets.

View Kcko's full-sized avatar
🦜
fly like a bird ...

Roman Janko Kcko

🦜
fly like a bird ...
View GitHub Profile
@Kcko
Kcko / move.html
Created September 16, 2015 09:10
Move between two select
<select id="from" style="float: left; width: 200px;" multiple>
<option value="1">AA</option>
<option value="2">BB</option>
<option value="3">CC</option>
<option value="4">DD</option>
<option value="5">EE</option>
</select>
@Kcko
Kcko / pop-stripe.md
Created October 13, 2015 13:10 — forked from mirisuzanne/pop-stripe.md
Rainbow stripe mixin with SCSS + Compass

Rainbow stripe mixin with SCSS + Compass

I'm trying to make a horizontal rainbow stripe background gradient mixin, but I feel like this is way too verbose. How can it be better?

Goals:

  1. [check] Use variables for colors so they can be swapped out for different colors.
  2. [check] The widths are hard coded for 8 colors. Can it be done smarter where it adjusts to the number of colors you add? Or is that asking too much?
  3. [check] The colors are defined twice for the color starts and stops. Can this be done better?
  4. [see below] Right now I define the colors as variables at the top level, then pass them in the mixin. Should they instead be created inside the mixin and then colors are brought in as arguments? Or does that matter?
@Kcko
Kcko / nette-download.php
Last active January 4, 2016 15:24
Nette download
public function downloadFile($source, $fileName){
$httpResponse = $this->context->getService('httpResponse');
$httpResponse->setHeader('Pragma', "public");
$httpResponse->setHeader('Expires', 0);
$httpResponse->setHeader('Cache-Control', "must-revalidate, post-check=0, pre-check=0");
$httpResponse->setHeader('Content-Transfer-Encoding', "binary");
$httpResponse->setHeader('Content-Description', "File Transfer");
$httpResponse->setHeader('Content-Length', filesize($source));
$this->sendResponse(new FileResponse($source, $fileName));
}
<?php
protected function createComponentOrder()
{
$that = $this;
return new Multiplier(function ($itemId) use($that) {
$form = new Form;
$form->getElementPrototype()->class[] = "ajax";
$form->addText('count', 'Počet zboží:')
->addRule($form::FILLED,'Zadejte prosím počet kusů.')
@Kcko
Kcko / Nette-flashes.php
Last active March 11, 2016 11:20
Flashes
<div n:if="$flashes">
<div n:foreach="$flashes as $flash" class="alert-{$flash->type}">{$flash->message}</div>
</div>
<div n:if="$form->hasErrors()">
<div n:foreach="$form->errors as $error" class="alert-error">{$error}</div>
</div>
@Kcko
Kcko / 01-gulpfile.js
Created February 12, 2016 18:39 — forked from markgoodyear/01-gulpfile.js
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
@Kcko
Kcko / send-mail-with-attachment.php
Created March 11, 2016 08:32
Nette - odeslání přílohy emailem
if ($values['cv']->isOk())
{
$mail->addAttachment($values['cv']->name, file_get_contents($values['cv']->temporaryFile));
}
$(function(){
var $win = $(window)
var $nav = $('.mytoolbar');
var navTop = $('.mytoolbar').length && $('.mytoolbar').offset().top;
var isFixed=0;
processScroll()
$win.on('scroll', processScroll)
function processScroll() {
@Kcko
Kcko / replace-tag-by-another.js
Created April 5, 2016 11:42
Jquery - replace tag with another
$('li').replaceWith(function(){
return $("<div />").append($(this).contents());
});
@Kcko
Kcko / on-document-click-close.js
Created April 8, 2016 12:48
Close on document, but not on this element.
$(document).on('click', function(e){
if ($(e.target).closest('.user-sign-in-form').length === 0)
{
$('.user-sign-in-form').fadeToggle();
}
});