Skip to content

Instantly share code, notes, and snippets.

Avatar
🇨🇿
Wypili moją krew na hejnał

Glutexo Glutexo

🇨🇿
Wypili moją krew na hejnał
View GitHub Profile
@Glutexo
Glutexo / decline.php
Last active Aug 29, 2015
Funkce pro hezké české vyskloňování podstatného jména.
View decline.php
// 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 Aug 29, 2015
Trivia-based mystery-cache solver. Output in KML format.
View geocache-solver.rb
#!/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 Aug 29, 2015
PHP bug #66173 example
View 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 Aug 29, 2015
Simple script to use git instead of SCP for app deployment.
View post-receive
#!/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 / squash-patch.sh
Last active Aug 29, 2015
GIT: Creates a cumulative patch from the specified commit to the current HEAD.
View squash-patch.sh
#!/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 Aug 29, 2015
GIT: Incorporate changes made in an already merged branch to its merge commit.
View remerge.sh
#!/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 Aug 29, 2015
GIT: Remove # from the end of the name of all branches that end with it.
View remove-from-branch-name-end
#!/bin/sh
if [ $1 = "-f" ]
then
FORCE="$1"
TRAILING_PATTERN="$2"
else
FORCE=""
TRAILING_PATTERN="$1"
fi
@Glutexo
Glutexo / mail-log-and-notify.sh
Created Feb 17, 2015
Log mail an raise an OS X notification
View mail-log-and-notify.sh
#!/bin/sh
# Mail logging combined with OS X notification.
# Uses terminal-notifier – https://github.com/alloy/terminal-notifier.
# Writes the whole message with header to the file, timestamp included,
# and raises a system notification with the message subject. The log
# file (LOG_FILE variable) is opened in the Console app upon clicking
# on the notification.
#
@Glutexo
Glutexo / random-file.rb
Created Feb 22, 2015
Creates a file filled with random content.
View random-file.rb
#!/usr/bin/env ruby
require 'securerandom'
TARGET_FILE_NAME = "random-file.iso"
TARGET_FILE_SIZE = 4707319808 # DVD-RW
CHUNK_SIZE = 1000000 # 1 MB
file = File.new TARGET_FILE_NAME, 'w'
@Glutexo
Glutexo / rot13-automator.applescript
Created Dec 6, 2011
ROT13 jako textová služba pro Automator
View rot13-automator.applescript
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