Skip to content

Instantly share code, notes, and snippets.

View Glutexo's full-sized avatar
🇨🇿
Wypili moją krew na hejnał

Glutexo Glutexo

🇨🇿
Wypili moją krew na hejnał
  • Frýdek, Czechia
View GitHub Profile
@Glutexo
Glutexo / rot13-automator.applescript
Created December 6, 2011 09:38
ROT13 jako textová služba pro Automator
on run {input, parameters}
(* A když se jako další akce přidá provedení tohoto AppleScriptu
vyskočí nám zROT13ovaný vstup jako upozornění. *)
display dialog input as text buttons {"OK"}
return input
end run
@Glutexo
Glutexo / cs.yml
Last active December 13, 2015 20:38
České formátování data/času pro gem delocalize. Názvy měsíců jsou v genitivu, protože to tak při vypsání celého data vypadá dobře. Samozřejmě pro vypsání pouze názvu měsíce to chce vyřešit jinak. Poznámka: Soubor cs.yml patří do složky /config/locales.
cs:
number:
format:
separator: ','
delimiter: ' '
precision: 2
date:
input:
formats:
- :default
@Glutexo
Glutexo / decline.php
Last active August 29, 2015 13:57
Funkce pro hezké české vyskloňování podstatného jména.
// Vyskloňuje slovo hezky česky buď podle staršího,
// méně benevoletního a méně prasáckého paradigmatu:
// 1 položka, 2 položky, 5 položek, 10 položek,
// 15 položek, 20 položek, 21 položka, 22 položky
// 25 položek, 100 položek, 101 položka…
// nebo podle nového, čuňáckého:
// 1 položka, 2 položky, 5 položek, 10 položek,
// 15 položek, 20 položek, 21 položek, 22 položek
// 25 položek, 100 položek, 101 položek…
//
@Glutexo
Glutexo / geocache-solver.rb
Last active August 29, 2015 13:57
Trivia-based mystery-cache solver. Output in KML format.
#!/usr/bin/ruby
=begin
Easy quiz/trivia mystery-cache solver. Takes possible
answers to questions and instructions how to transform
the indices into coordinates. Brute-force is used to
check all possible combinations that produce meaningful
coordinates. Returns a set of waypoins in KML format.
The values here are real for a specific Geocache.
@Glutexo
Glutexo / php-bug-66173-example
Last active August 29, 2015 14:02
PHP bug #66173 example
#!/usr/bin/php
<?php
# Demo script of a bug #66137 (https://bugs.php.net/bug.php?id=66173)
# Converting an object with properties that have numeric names results
# in having an array with inaccessible keys.
$ary = [];
$ary["0"] = 'string';
var_dump($ary);
@Glutexo
Glutexo / post-receive
Last active August 29, 2015 14:05
Simple script to use git instead of SCP for app deployment.
#!/bin/sh
# Checkouts the repository into the webserver application folder.
# Inspired by http://www.sitepoint.com/one-click-app-deployment-server-side-git-hooks/ by Matthew Setter.
# The script assumes that the bare repository directory name (somename.git) is same as the deployment
# directory name, just without the .git extension (somename). The destination path (htdocs) needs to be
# changed according to your environment (line 14, DEPLOYPATH variable).
read OLDREV NEWREV REFNAME
CURRENTDIR=`pwd | grep -o [^/]\\\\+$`
@Glutexo
Glutexo / current-date-and-time.applescript
Created September 14, 2014 12:48
AppleScript to get current date and time (YYYY-MM-DD HH:MM:SS). Usable as a Text Service in Mac OS X.
(*
The zero_pad function taken from:
http://www.nineboxes.net/2009/10/an-applescript-function-to-zero-pad-integers/
*)
on zero_pad(value, string_length)
set string_zeroes to ""
set digits_to_pad to string_length - (length of (value as string))
if digits_to_pad > 0 then
repeat digits_to_pad times
set string_zeroes to string_zeroes & "0" as string
@Glutexo
Glutexo / squash-patch.sh
Last active August 29, 2015 14:11
GIT: Creates a cumulative patch from the specified commit to the current HEAD.
#!/bin/sh
# Won’t work if a branch called _squash_patch_tmp already exists.
# And probably many other caveats?
REFS_NAMED_HEAD=`git show-ref --heads --tags | grep "^[0-9a-f]\{40\} refs/\(heads\|tags\)/HEAD$"`;
if [ "$REFS_NAMED_HEAD" ]; then
echo "HEAD is ambiguous.";
exit 2
fi
@Glutexo
Glutexo / remerge.sh
Last active August 29, 2015 14:14
GIT: Incorporate changes made in an already merged branch to its merge commit.
#!/bin/sh
# Takes changes done in a branch that was already merged into another and
# incorporates them into the already existing merge commit. Leaves in a
# detached HEAD state, the current HEAD being the patched original commit.
# If the patch cannot be applied cleanly, it is saved into ./patch.
if [ -z $1 -o -z $2 ]
then
@Glutexo
Glutexo / remove-from-branch-name-end
Last active August 29, 2015 14:14
GIT: Remove # from the end of the name of all branches that end with it.
#!/bin/sh
if [ $1 = "-f" ]
then
FORCE="$1"
TRAILING_PATTERN="$2"
else
FORCE=""
TRAILING_PATTERN="$1"
fi