Skip to content

Instantly share code, notes, and snippets.

View hrach's full-sized avatar

Jan Škrášek hrach

View GitHub Profile
@Cifro
Cifro / AnotherLatteMacros.php
Created July 3, 2010 15:20
Static class for additional Nette Latte Macros with first macro {each}{eachelse}{/each}
<?php
namespace Nette\Templates;
use Nette\Object;
use Nette\String;
/**
* Another Latte Macros
*
@janmarek
janmarek / BaseForm.php
Created September 3, 2010 16:51
Nette datepicker
<?php
class BaseForm extends Nette\Application\AppForm
{
public function addDatePicker($name, $label = NULL, $cols = NULL, $maxLength = NULL)
{
return $this[$name] = new Nette\Forms\DatePicker($label, $cols, $maxLength);
}
}
@dawsontoth
dawsontoth / populateYUVLuminanceFromRGB.java
Created November 29, 2011 16:48
How to take a Bitmap (in RGB) and grab the luminance values for YUV. Useful for passing an image to ZXing for processing.
public void handleBitmap(Bitmap image) {
int w = image.getWidth(), h = image.getHeight();
int[] rgb = new int[w * h];
byte[] yuv = new byte[w * h];
image.getPixels(rgb, 0, w, 0, 0, w, h);
populateYUVLuminanceFromRGB(rgb, yuv, w, h);
}
// Inspired in large part by:
@phpdude
phpdude / nginx.conf
Last active October 6, 2024 19:22
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@fprochazka
fprochazka / explained.md
Created February 20, 2012 15:59
Useful git hooks for Gitolite

Git push deploy

Requires installed gitolite in /home/git and following directory structure

/var
    /www
        /apps
        /hosts

/libs

@jaromirnyklicek
jaromirnyklicek / BootstrapHorizontalFormRenderer.php
Created March 14, 2012 19:56
Changes Nette form default markup to be compatible with Bootstrap CSS framework.
<?php
namespace SmartCMS;
use Nette,
Nette\Utils\Html;
class BootstrapHorizontalFormRenderer extends Nette\Forms\Rendering\DefaultFormRenderer
{
public $wrappers = array(
@JanTvrdik
JanTvrdik / add_pull_request_to_issue_github.sh
Last active June 6, 2016 19:25
Add pull request to existing issue on github
#!/bin/bash
current_branch="$(git symbolic-ref HEAD 2>/dev/null)" || current_branch="(unknown)"
current_branch=${current_branch##refs/heads/}
github_username="JanTvrdik"
github_token="..."
if [[ $current_branch = "(unknown)" ]]
then
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active November 14, 2024 18:34
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@vvondra
vvondra / GitBranchPanel.php
Created September 5, 2012 21:27
Git branch Nette debugger panel
<?php
namespace Vondra;
class GitBranchPanel implements \Nette\Diagnostics\IBarPanel
{
public function getPanel()
{
return '';
@lichtner
lichtner / Article.php
Created November 6, 2012 11:03
Redactor.js nette presenter integration
<?php
class Article extends Base {
function getUploadDir() {
# e.g. something like this
return "upload/articles/article-$this[id]";
}
}