Skip to content

Instantly share code, notes, and snippets.

View wojtha's full-sized avatar

Vojtěch Kusý wojtha

View GitHub Profile
@wojtha
wojtha / profile.ps1
Created June 19, 2011 10:18 — forked from markembling/profile.ps1
My preferred prompt for Powershell - includes git info.
# My preferred prompt for Powershell.
# Displays git branch and stats when inside a git repository.
# See http://gist.github.com/180853 for gitutils.ps1.
. (Resolve-Path ~/Documents/WindowsPowershell/gitutils.ps1)
function prompt {
$path = ""
$pathbits = ([string]$pwd).split("\", [System.StringSplitOptions]::RemoveEmptyEntries)
if($pathbits.length -eq 1) {
@wojtha
wojtha / gist:1034262
Created June 19, 2011 13:16
PHP Syntax Check for Git pre-commit hook for Windows PowerShell
###############################################################################
#
# PHP Syntax Check for Git pre-commit hook for Windows PowerShell
#
# Author: Vojtech Kusy <[email protected]>
#
###############################################################################
### INSTRUCTIONS ###
@wojtha
wojtha / drush_module_cleanup.ps1
Created June 22, 2011 11:32
Cleanup of Drupal modules using Drush & Windows PowerShell
###############################################################################
#
# Cleanup of Drupal modules using Drush & Windows PowerShell
#
# Author: Vojtech Kusy <[email protected]>
#
###############################################################################
# Create directory .trash if doesn't exist
if(!(Test-Path .\.trash -pathtype container)) {
@wojtha
wojtha / mysql_db_conversions.sql
Created June 23, 2011 21:19
MySQL database conversions
/**
* MYISAM --> INNODB query generator.
*
* Converts all tables in the given database from MYISAM to INNODB.
*
* http://codesnippets.joyent.com/posts/show/1451
* http://rackerhacker.com/2007/10/03/convert-myisam-tables-to-innodb/#comment-23295
*/
SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' engine=MyISAM;') FROM information_schema.tables WHERE TABLE_SCHEMA='my_database' AND ENGINE = 'InnoDB';
@wojtha
wojtha / drupal_views_revoke_cache.php
Created June 24, 2011 11:11
Drupal snippet: Revoke Views cache on each insert, update, delete of the node
<?php
/**
* Implementation of hook_nodeapi().
*
* Revoke Views cache on each insert, update, delete of the node.
*/
function mymodule_special_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
// Clear all cached views results and rendered outputs on node updates
// for particular views:
@wojtha
wojtha / gist:1048852
Created June 27, 2011 13:29
Drupal snippet - wipeout obsolete Feature
<?php
/**
* NOT SAFE! Disable the Feature before running this!
*/
$name = 'obsolete_feature';
db_query("DELETE FROM {system} WHERE `name`='%s'", $name);
db_query("DELETE FROM {cache} WHERE `cid`='features_module_info'");
db_query("DELETE FROM {variable} WHERE `name`='features_codecache'");
@wojtha
wojtha / gist:1049224
Created June 27, 2011 16:33
Drupal snippet - wipeout whole taxonomy vocabulary
<?php
/**
* Wipe out whole taxonomy vocabulary.
*/
$vocabulary_vid = 4;
$result = db_query("SELECT * FROM `term_data` WHERE `vid`=%d;", $vocabulary_vid);
while ($term = db_fetch_array($result)) {
$term['type'] = 'term';
taxonomy_del_term($term);
}
@wojtha
wojtha / gist:1098113
Created July 21, 2011 20:21
Git - Move whole repository to the subdirectory
# http://stackoverflow.com/questions/3058560/how-do-i-change-a-files-path-in-gits-history/3063008#3063008
git filter-branch --index-filter '
git ls-files -s |
sed "s-\t\"*-&subdirectory/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
' HEAD
@wojtha
wojtha / gist:1098236
Created July 21, 2011 21:19
Git - modify the first commit
# git rebase -i allows you to conveniently edit any previous commits, except for the root # commit. The following commands show you how to do this manually.
# http://stackoverflow.com/questions/2246208/change-first-commit-of-project-with-git/2322798#2322798
# tag the old root, "git rev-list ..." will return the hash of first commit
git tag root `git rev-list HEAD | tail -1`
# switch to a new branch pointing at the first commit
git checkout -b new-root root
# make any edits and then commit them with:
git commit --amend
@wojtha
wojtha / gist:1166444
Created August 23, 2011 20:35
Czech prepositions
během,bez,díky,do,k,kolem,krom,kromě,kvůli,mezi,mezi,mimo,místo,na,nad,nade,naproti,o,od,okolo,oproti,po,pod,pode,podél,podle,pomocí,pro,prostřednictvím,proti,před,před,při,s,skrz,skrze,stran,u,v,vedle,z,za,zpět