Skip to content

Instantly share code, notes, and snippets.

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

Kcko

🦜
fly like a bird ...
View GitHub Profile
@Kcko
Kcko / FooControl.php
Last active August 29, 2015 14:05 — forked from matej21/FooControl.php
Ukázková komponenta - attached
<?php
use Nette\Application\UI;
class FooControl extends UI\Control
{
public function __construct(...)
{
//predani parametru a zavislosti
}
@Kcko
Kcko / ImageResponse.php
Last active August 29, 2015 14:05 — forked from matej21/ImageResponse.php
Image response - generování obrázků
<?php
class ImageResponse extends \Nette\Object implements \Nette\Application\IResponse
{
/** @var \Nette\Image|string */
private $image;
/**
* @param \Nette\Image|string
@Kcko
Kcko / AntispamControl.php
Last active December 26, 2020 18:03
Nette antispam control
<?php
use Nette\Forms\Controls\TextInput,
Nette\Forms\Form,
Nette\Utils\Html;
/**
* AntispamControl
@Kcko
Kcko / Nette-MessageFactory.php
Last active August 29, 2015 14:13 — forked from matej21/MessageFactory.php
Nette - správné použití odeslání emailu
<?php
interface MessageFactory
{
/**
* @return \Nette\Mail\Message
*/
public function create();
}
@Kcko
Kcko / parser-DOM.php
Last active August 29, 2015 14:14 — forked from martinsik/parser.php
Parser v PHP, ukázka práce s knihovnou DOM.
<?php
$curl = curl_init('http://www.livescore.com/soccer/england/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10');
$html = curl_exec($curl);
curl_close($curl);
if (!$html) {
@Kcko
Kcko / form.latte
Last active August 29, 2015 14:16 — forked from martiman/form.latte
<form n:name=$form class="form">
<div class="row">
<div class="col-md-12">
<ul class=error n:if="$form->ownErrors">
<li n:foreach="$form->ownErrors as $error">{$error}</li>
</ul>
</div>
</div>
<div class="row">
{foreach $form->controls as $input}
@Kcko
Kcko / event.js
Last active August 29, 2015 14:17 — forked from branneman/event.js
$(function() {
var resizeEnd;
$(window).on('resize', function() {
clearTimeout(resizeEnd);
resizeEnd = setTimeout(function() {
$(window).trigger('resizeEnd');

jQuery Caret

This is a very simple lightweight plugin to allow you to move the caret (or cursor) position in an <input /> or <textarea> element.

By exposing three jQuery.fn methods you can easily move a a caret to any position you like:

$.fn.caretTo( index , [ offset ] )

@Kcko
Kcko / php-sanitize-multidimensional-array.php
Last active August 29, 2015 14:26 — forked from esthezia/php-sanitize-multidimensional-array.php
PHP - Sanitize a multidimensional array
<?php
/**
* Sanitize a multidimensional array
*
* @uses htmlspecialchars
*
* @param (array)
* @return (array) the sanitized array
*/
@Kcko
Kcko / gist:bc336064e48a544f60e6
Last active August 29, 2015 14:27 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter