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 | |
function a() { | |
throw new \LogicException('bad logic in A'); | |
} | |
function b() { | |
try { | |
a(); | |
} catch (\LogicException $e) { |
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
unamestr=`uname` | |
PHP_INI_PATH=$(php --ini | egrep -o '\S+php.ini$') | |
if [ -z $(php -m | grep xdebug) ]; then | |
if [[ "$unamestr" == 'Linux' ]]; then | |
sudo sed -i "s/^;zend_extension/zend_extension/" $PHP_INI_PATH | |
elif [[ "$unamestr" == 'Darwin' ]]; then | |
sudo sed -i "" "s/^;zend_extension/zend_extension/" $PHP_INI_PATH | |
fi | |
echo 'Xdebug enabled' |
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 | |
$message = 'test'; | |
if ('ASCII' !== mb_detect_encoding($message, 'ASCII', true)) { | |
echo 'Unicode' . PHP_EOL; | |
} else { | |
echo 'ASCII' . 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
const fetch = require('node-fetch'); | |
const cheerio = require('cheerio'); | |
const fs = require('fs'); | |
let url = "http://loveread.ec/read_book.php?id=56443&p="; | |
let requests = []; | |
let startTime = new Date().getTime(); | |
for (let counter = 1; counter < 36; ++counter) { | |
requests.push( |
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
https://git-scm.com/docs/git-remote | |
git remote prune --dry-run origin | |
git remote update origin --prune | |
# get all removed branches on server side | |
git branch -vv | grep -Po '\s(feature\S+)(?=.*\s+gone\])' | |
# so you can remove all "gone" branches: | |
git branch -D $(b -vv | grep -Po '\s(feature\S+)(?=.*\s+gone\])') |
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 | |
declare(ticks = 1); | |
pcntl_signal(SIGTERM, 'signalHandler'); // Termination ('kill' was called) | |
pcntl_signal(SIGHUP, 'signalHandler'); // Terminal log-out | |
pcntl_signal(SIGINT, 'signalHandler'); // Interrupted (Ctrl-C is pressed) | |
$seconds = 0; | |
$total = 10; |
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 | |
# | |
# Automatically adds branch name and branch description to every commit message. | |
# changes commit message on branch example "feature/SPRINT-123" to message: "#SPRINT-123: commit message" | |
# | |
# INSTALLATION: | |
# - copy to .git/hooks/prepare-commit-msg | |
# - run chmod 555 .git/hooks/prepare-commit-msg | |
# | |
NAME=$(git branch | grep '*' | grep -Po '\w+-\d+' | sed -r 's/(.*)/#\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
percona2: | |
container_name: percona-compose | |
image: percona:latest | |
environment: | |
- MYSQL_ROOT_PASSWORD=12345 | |
php53: | |
container_name: php53-compose | |
image: markfletcher/php5.3-zend | |
links: |
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 org.apache.commons.io.IOUtils; | |
try { | |
// approach 1 | |
String extractProducts = IOUtils.toString(getClass().getResourceAsStream("/extractProducts.js")); | |
// approach 2 | |
byte[] bytes = Files.readAllBytes(Paths.get(getClass().getResource("/extractProducts.js").getPath())); | |
String js_extractProducts = new String(bytes); | |
} catch (IOException e) { |
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
/* | |
jackson-mapper here: | |
http://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl | |
*/ | |
import org.codehaus.jackson.JsonParseException; | |
import org.codehaus.jackson.map.JsonMappingException; | |
import org.codehaus.jackson.map.ObjectMapper; | |
import org.codehaus.jackson.type.TypeReference; |
NewerOlder