This file contains hidden or 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
#!/usr/bin/env sh | |
# | |
# Launch this script in a new MODx directory | |
# | |
old_path=$(sed -ne "s/^.*\\\$modx_base_path[[:space:]]*=[[:space:]]*'\\(.*\\)';.*$/\\1/p" core/config/config.inc.php) | |
new_path=$(readlink -f ${2:="."} 2&>/dev/null) | |
for file in $(grep -lR --exclude-dir="cache" $old_path * 2&> /dev/null) |
This file contains hidden or 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
#!/usr/bin/env bash | |
# | |
# Launch this script in a new Joomla folder | |
# | |
current_dir=$(readlink -f .) | |
if [[ ! -w $current_dir/configuration.php ]]; then | |
echo "Error: configuration.php isn't writable or doesn't exists" 1>&2 | |
exit 1; |
This file contains hidden or 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
#!/usr/bin/env sh | |
remote_url='https://webdav.yandex.ru/backups' | |
credentials=$(cat ~/.yapwd) # user:password | |
curl_command="curl -u $credentials" | |
create_remote_dir() { | |
$curl_command -X MKCOL "$remote_url/$1" | |
return $? |
This file contains hidden or 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 | |
/** | |
* Создает подготовленное выражение на основе готового SQL запроса и переданных данных. | |
* | |
* @param mysqli $link Ресурс соединения | |
* @param string $sql SQL запрос с плейсхолдерами вместо значений | |
* @param array $data Данные для вставки на место плейсхолдеров | |
* | |
* @throws \UnexpectedValueException Если тип параметра не поддерживается |
This file contains hidden or 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 | |
class Tweet | |
{ | |
private $id; | |
private $content; | |
public function __construct(int $id, string $content) | |
{ | |
$this->id = $id; |
This file contains hidden or 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 | |
$routes = [ | |
'GET /' => function (string $method, array $params) { | |
echo 'Welcome!'; | |
}, | |
'(GET|POST) /hello(/(?<name>[^/]++))?' => function (string $method, array $params) { | |
\printf('Hello, %s!', $params['name'] ?? 'World'); | |
}, | |
]; |
This file contains hidden or 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 | |
binary="${1:-./a.out}"; | |
test() { | |
input="$1"; | |
expected="$2"; | |
actual="$(echo $input | $binary)"; | |
if [ "$expected" = "$actual" ]; then |
This file contains hidden or 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
#include <ctype.h> | |
int fuzzy_match(const char *needle, const char *haystack) | |
{ | |
while (*needle && *haystack) { | |
if (*haystack == tolower(*needle) || *haystack == toupper(*needle)) { | |
needle++; | |
} | |
haystack++; |
This file contains hidden or 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
#include <stddef.h> | |
#include "xor.h" | |
void *memxor(void *s, size_t ssize, void *k, size_t ksize) | |
{ | |
unsigned char *sp = s; | |
unsigned char *kp = k; | |
for (size_t i = 0; i < ssize; ++i) { |
This file contains hidden or 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
var Encore = require('@symfony/webpack-encore'); | |
if (!Encore.isRuntimeEnvironmentConfigured()) { | |
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); | |
} | |
Encore | |
.setOutputPath('public/build/') | |
.setPublicPath('/build') | |
.addEntry('app', './assets/js/app.js') |
OlderNewer