Skip to content

Instantly share code, notes, and snippets.

@daum
daum / test.js
Created September 1, 2020 14:38
Clockify hours to decimals
var hourRegex = /([0-9]+):([0-9][0-9]):([0-9][0-9])/;
$("div").each(function(){
var matches =$(this).clone().children().remove().end().text().match(hourRegex);
if(matches && matches.length){
var decimal = parseInt(matches[1]);
decimal+= parseInt(matches[2])/60;
decimal+= parseInt(matches[3])/3600;
$(this).append("("+decimal.toFixed(2)+")");
<?php
// Generate the start timestamp
$start = time();
// Do other stuff....
// If the end timestamp is over 7 weeks in seconds throw an error
if( strtotime('+7 days') - $start > 86400) {
throw new \Exception('must be less than 7 weeks');
}
<?php
namespace Example\Doctrine\Util;
use Doctrine\ORM\Query;
class QueryUtils
{
/**
* @param Query $query
* @return array An array with 3 indexes, sql the SQL statement with parameters as ?, params the ordered parameters, and paramTypes as the types each parameter is.
my-logs/2016/09/14/23/MyApp.1473894000059:15674:abcefawed27be2305c30049c48552f8c46673340,2016-09-14 19:59:11
my-logs/2016/09/14/23/MyApp.1473894000059:15675:efwefwef8ce2b4bca75d8e00b8100815d9e2838b,2016-09-14 19:59:11
my-logs/2016/09/14/23/MyApp.1473894000059:15679:8b0cdwewewewed0831b4aa0e023f4874fc0f5799,2016-09-14 19:59:11
my-logs/2016/09/14/23/MyApp.1473894000059:15680:c5b4d66b9c30eeeeeeeea5b3d6b566877b2216dd,2016-09-14 19:59:11
22 Sep 2016 09:59:18 [INFO] my-logs/2016/09/14/23/MyApp.1473894000059:15674:abcefawed27be2305c30049c48552f8c46673340,2016-09-14 19:59:11
22 Sep 2016 09:59:18 [INFO] my-logs/2016/09/14/23/MyApp.1473894000059:15675:efwefwef8ce2b4bca75d8e00b8100815d9e2838b,2016-09-14 19:59:11
22 Sep 2016 09:59:18 [INFO] my-logs/2016/09/14/23/MyApp.1473894000059:15679:8b0cdwewewewed0831b4aa0e023f4874fc0f5799,2016-09-14 19:59:11
22 Sep 2016 09:59:18 [INFO] my-logs/2016/09/14/23/MyApp.1473894000059:15680:c5b4d66b9c30eeeeeeeea5b3d6b566877b2216dd,2016-09-14 19:59:11
s3.access_key=XXXX
s3.secret_key=YYYY
s3.bucket=my-bucket
search_term=my_search
is_regex_search=false
log_level=INFO
logger_pattern=%d{dd MMM yyyy HH:mm:ss} [%p] %m%n
java -jar s3-grep-1.0-SNAPSHOT.jar s3grep.properties.
<?php
$items = $em->getRepository('AppBundle:ExampleEntity')->findAll();
foreach($items as $i){
$c = new \ReflectionClass("AppBundle\\Entity\\ExampleEntity");
$prop = $c->getProperty('visible_label');
$prop->setAccessible(true);
$i->translate('en')->setVisibleLabel($prop->getValue($i));
$i->mergeNewTranslations();
}
CREATE TABLE `example_entity` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `example_entity_translation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`translatable_id` int(11) DEFAULT NULL,
`visible_label` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
CREATE TABLE `example_entity` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`visible_label` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;