Skip to content

Instantly share code, notes, and snippets.

View vaclavbohac's full-sized avatar

Vaclav Bohac vaclavbohac

View GitHub Profile
@vaclavbohac
vaclavbohac / sum.cpp
Created September 2, 2011 14:01
Example of the lambda functions in c++0x
// Copyright 2011 Vaclav Bohac <[email protected]>. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
@vaclavbohac
vaclavbohac / ajax.php
Created September 1, 2011 16:40
Small library enabling simple XHR requests to the Nette Framework powered backends.
<?php
require __DIR__ . '/libs/Nette/loader.php';
Nette\Diagnostics\Debugger::enable();
$configurator = new Nette\Configurator();
$context = $configurator->getContainer();
$payload = array('foo' => 'bar');
@vaclavbohac
vaclavbohac / TableMacros.php
Created July 1, 2011 12:06
Latte macro for creating table from Nette\Database\Selection easily
<?php
/**
* Latte macros.
*
* @copyright Copyright (c) 2011 Vaclav Bohac
* @package Macros
*/
use Nette\Latte;
@vaclavbohac
vaclavbohac / jQuery.mobile.formfix.js
Created June 16, 2011 15:48
AJAX forms in Nette FW and jQuery mobile
/**
* Formfix enables you to use AJAX forms with Nette FW
* and helps keep tracking of history in jQuery mobile.
*
* Requires jQuery 1.4+, jQuery mobile 1.0
*
* Usage:
* $("#foo").formfix();
*
* @author Vaclav Bohac <[email protected]>
@vaclavbohac
vaclavbohac / @layout.phtml
Created June 13, 2011 23:16
Mobile Sign in Form with Latte filter and jQuery mobile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<meta name="description" content="Example mobile login page">
<meta name="robots" content="{$robots}" n:ifset="$robots">
<title>{include #title}</title>
<link rel="stylesheet" media="screen" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" type="text/css">
@vaclavbohac
vaclavbohac / default.phtml
Created June 9, 2011 16:43
Example of Latte filter and jQuery mobile
{define detail}
<div data-role="page" id="{$name|webalize}">
<div data-role="header">
<h1>Detail vozidla {$name}</h1>
</div>
<div data-role="content">
<div data-role="collapsible">
<h3>Popis vozidla</h3>
@vaclavbohac
vaclavbohac / RegexExamples.cs
Created June 9, 2011 13:13
Regular expressions in C#
using System;
using System.Text.RegularExpressions;
class RegexExamples
{
public static void Main()
{
// Simple match.
string[] foo = {"vim", "mvim", "gvim", "emacs"};
@vaclavbohac
vaclavbohac / StringInterning.cs
Created June 9, 2011 12:13
Example v C# string interning.
using System;
using System.Text;
// Example of C# string interning.
// Created by Vaclav Bohac in 2011
class Test
{
public static void Main()
@vaclavbohac
vaclavbohac / HomepagePresenter.php
Created June 1, 2011 15:47
Mobile device detection in Nette
<?php
class HomepagePresenter extends BasePresenter
{
public function actionDefault()
{
$detector = $this->context->detector;
if ($detector->isMobile()) {
$this->redirect("mobile");
@vaclavbohac
vaclavbohac / .emacs
Created May 23, 2011 14:38
My emacs config file.
" Set up color theme. "
(add-to-list 'load-path ".emacs.d")
(require 'color-theme)
(require 'color-theme-gruber-darker)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)