$event = new SyncDispatcher;
$event->listen('subscribed', function () {
echo 'handling it 1' . PHP_EOL;
});
$event->listen('un-subscribed', function () {
echo 'un-subscribed it 1' . PHP_EOL;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT engine, | |
count(*) as TABLES, | |
concat(round(sum(table_rows)/ | |
1000000,2),'M') rows, | |
concat(round(sum(data_length)/ | |
(1024*1024*1024),2),'G') DATA, | |
concat(round(sum(index_length)/ | |
(1024*1024*1024),2),'G') idx, | |
concat(round(sum(data_length+index_length)/ | |
(1024*1024*1024),2),'G') total_size, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Matches | |
// youtube.com/v/vidid | |
// youtube.com/vi/vidid | |
// youtube.com/?v=vidid | |
// youtube.com/?vi=vidid | |
// youtube.com/watch?v=vidid | |
// youtube.com/watch?vi=vidid | |
// youtu.be/vidid | |
// youtube.com/embed/vidid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################### | |
######################### Install and Configure Redis ######################### | |
############################################################################### | |
############################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'titlecase' | |
}) | |
export class TitlecasePipe implements PipeTransform { | |
transform(value: any): any { | |
if (!value) { | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'summary' | |
}) | |
export class SummaryPipe implements PipeTransform { | |
transform(value: string, limit?: number) { | |
if (!value) { | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countNegatives($matrix) { | |
if (!is_array($matrix)) { | |
throw new TypeError('The matrix is not an array'); | |
} | |
//rows | |
$rows = count($matrix); | |
// columns | |
$columns = (array_sum(array_map('count', $matrix)) / $rows); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# example line | |
# 372|"Baby Beluga CD"|Raffi8054BabyBeluga.mp3|http://www.domain.com/img/data/ETA_CD56.jpg | |
while IFS='|' read field1 field2 field3 field4 || [[ -n "$line" ]]; do | |
f=$(echo $field2 | tr -d '"' | tr -d ' ' | tr -d '®' | tr -d "'" | tr -d '‘' | tr -d '’' | tr -d '&' | tr -d ',' | tr -d '-') | |
ffmpeg -loop 1 -i $field4 -i $field3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -shortest ./out/$f.mp4 < /dev/null | |
done < "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT COLUMN_NAME, COUNT(*) c FROM table GROUP BY COLUMN_NAME HAVING c > 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only run this script in CLI | |
(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('cli only'); |