Skip to content

Instantly share code, notes, and snippets.

View ReeMii's full-sized avatar

Remigiusz Loginow ReeMii

  • DCX @ Capgemini Deutschland
  • Munich, Germany
  • X @reemii76
View GitHub Profile
@ReeMii
ReeMii / remove-git-from-project
Created September 18, 2013 12:01
remove .git or .svn folders from project
rm -rf `find . -type d -name .git`
@ReeMii
ReeMii / vertical-align-middle.js
Created September 24, 2013 13:40
Vertical Align Middle
$(window).resize(function() {
$(".container > img").each(function() {
var cHeight = $(this).parent(".container").height(),
cWidth = $(this).parent(".container").width(),
iHeight = $(this).height(),
iWidth = $(this).width();
$(this).css({
top: 0.5*(cHeight - iHeight),
left: 0.5*(cWidth - iWidth)
});
@ReeMii
ReeMii / str2url.php
Created September 26, 2013 09:25
str2url
function str2url($string, $slug = '-', $extra = null)
{
return strtolower(trim(preg_replace('~[^0-9a-z' . preg_quote($extra, '~') . ']+~i', $slug, unaccent($string)), $slug));
}
function unaccent($string) // normalizes (romanization) accented chars
{
if (strpos($string = htmlentities($string, ENT_QUOTES, 'UTF-8'), '&') !== false) {
$string = html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1', $string), ENT_QUOTES, 'UTF-8');
}
@ReeMii
ReeMii / setcookie.js
Created October 4, 2013 08:43
setcookie
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
@ReeMii
ReeMii / limitCheckboxes.js
Created October 4, 2013 10:17
limit checkboxes
function limitCheckboxes(control, max) {
$(control).click(function () {
if(!$(this).is(':checked')) {
return true;
} else if($(control).filter(":checked").length>max) {
return false;
}
});
}
@ReeMii
ReeMii / wrap-long-strings.php
Created October 17, 2013 20:51
wrap long strings after n chars without visual distraction
<?php
$text = wordwrap($text, 12, "&#8203;", true);
@ReeMii
ReeMii / table-relations.sql
Created October 24, 2013 11:07
get table relations
SELECT
constraint_schema as db,
CONCAT( table_name, '.', column_name, ' -> ', referenced_table_name, '.', referenced_column_name ) AS relationship
FROM
information_schema.key_column_usage
WHERE
referenced_table_name = 'TableName'
ORDER BY
constraint_schema, table_name, column_name;
@ReeMii
ReeMii / table-comment.sql
Created October 24, 2013 12:24
Select table comment
SELECT table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='my_cool_database'
AND table_name='my_table';
@ReeMii
ReeMii / column-comment.sql
Created October 24, 2013 12:27
show column comment
SELECT
COLUMN_NAME,COLUMN_COMMENT
FROM
information_schema.COLUMNS
WHERE
TABLE_NAME = 'My_Table'
@ReeMii
ReeMii / mysql-connection-time-zone
Created November 3, 2013 20:49
set time zone for MySQL connection in ZF2
<?php
function timezone_offset_string( $offset )
{
return sprintf( "%s%02d:%02d", ( $offset >= 0 ) ? '+' : '-', abs( $offset / 3600 ), abs( $offset % 3600 ) );
}
$offset = timezone_offset_get( new DateTimeZone( 'Europe/Warsaw' ), new DateTime() );
return array(
'service_manager' => array(
'factories' => array(