Skip to content

Instantly share code, notes, and snippets.

View Artem-Schander's full-sized avatar

Artem Schander Artem-Schander

View GitHub Profile
@Artem-Schander
Artem-Schander / fix.js
Last active November 10, 2015 15:49
Typo3 + Twitter Bootstrap - Checkbox/Radio Button Fix
$('[data-toggle=buttons] .btn > input[type=hidden]').each(function() {
if($(this).attr('name') == $(this).next().attr('name') || $(this).attr('name') + '[]' == $(this).next().attr('name'))
$(this).insertBefore($(this).parent().parent());
});
@Artem-Schander
Artem-Schander / get_files.php
Last active January 6, 2016 08:42
Get files from folder (date, name, size). + Filter, Sort, Ignore.
<?php
public function scan_dir($dir, $contains = null, $sort = 'date', $ignored = array('.', '..', '.htaccess')) {
$files = array();
$finfo = finfo_open(FILEINFO_MIME_TYPE);
foreach (scandir($dir) as $i => $file) {
preg_match('/'.$contains.'(\D)/', $file, $matches);
if (isset($contains) && is_string($contains) && count($matches) === 0) continue;
$files[$i] = array(
@Artem-Schander
Artem-Schander / fileproxy.php
Last active October 15, 2015 11:26
PHP Fileproxy method
<?php
/**
* @param string $file_name
* @param string $mime
* @param string/bool $download
* @return void
*/
public function fileProxyAction($file_name, $mime, $download = false) {
@Artem-Schander
Artem-Schander / parse_date.js
Created October 23, 2015 08:07
Parse Date - Plain JS
var date = new Date('2015-10-21 15:54:44');
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
var hours = date.getHours();
var minutes = date.getMinutes();
var dateString = ('0' + day).slice(-2) + '.' + ('0' + month).slice(-2) + '.' + year + ' - ' + ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2);
@Artem-Schander
Artem-Schander / template.ts
Last active November 12, 2015 11:46
TypoScript: Navi with li > searchfield
lib.nav_with_search = COA_INT
lib.nav_with_search {
stdWrap.prefixComment = 2 | lib.searchbox
10 = TEXT
10.value = <ul class="sf-menu navbar-table">
20 < lib.mainmenu
20 {
@Artem-Schander
Artem-Schander / MIME.php
Last active April 18, 2016 15:03
Simple repository of common file mime types
<?php
/**
* Simple repository of common file mime types
*/
class MIME {
private static $types = array(
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
@Artem-Schander
Artem-Schander / css
Last active September 4, 2017 14:11
star rating - radio
.rating {
border: none;
float: left;
}
.rating > input { display: none; }
.rating > label:before {
margin: 5px;
font-size: 1.25em;
@Artem-Schander
Artem-Schander / closetags.php
Last active February 21, 2017 20:00
Close opened HTML tags
<?php
function closetags($html) {
preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
$openedtags = $result[1];
preg_match_all('#</([a-z]+)>#iU', $html, $result);
$closedtags = $result[1];
if (count($closedtags) == count($openedtags)) {
return $html;
@Artem-Schander
Artem-Schander / opentags.php
Created February 21, 2017 19:59
Open closed HTML tags
<?php
function opentags($html) {
preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
$openedtags = $result[1];
preg_match_all('#</([a-z]+)>#iU', $html, $result);
$closedtags = $result[1];
$len_closed = count($closedtags);
if (count($openedtags) == $len_closed) {
@Artem-Schander
Artem-Schander / duration-query.sql
Created March 24, 2017 08:49
MySQL Query to get a duration in days by two unix timestamps
SELECT name, TIMESTAMPDIFF(DAY, DATE(FROM_UNIXTIME(date_start)), DATE(FROM_UNIXTIME(date_end))) + 1 AS duration
FROM some_table