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
// TODO parse with headers['content-type'] | |
const body = []; | |
request | |
.on('data', chunk => body.push(chunk)) | |
.on('end', () => body = Buffer.concat(body).toString()); |
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
const ip = req.headers['x-forwarded-for'] || // TODO add .split(',') | |
req.connection.remoteAddress || | |
req.socket.remoteAddress || | |
req.connection.socket.remoteAddress; |
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
<? | |
// $upload_dir = COption::GetOptionString("main", "upload_dir", "upload"); | |
// if GetOptionString don't use cache then make your ::getPaths([]) - for get path by []$ids | |
$res = CIBlockElement::GetList( | |
array("SORT"=>"ASC"), | |
array( | |
"SECTION_CODE" => "ryba", | |
"INCLUDE_SUBSECTIONS" => "Y", | |
"IBLOCK_ID" => 4, |
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
const PORT = process.env.port || 8080; | |
var http = require('http'); | |
http.createServer((request, response) => { | |
request.on('error', err => { | |
console.error(err); | |
response.statusCode = 400; | |
response.end(); | |
}); | |
response.on('error', err => console.error(err)); |
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
function inside(point, vs) { | |
// ray-casting algorithm based on | |
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html | |
var x = point[0], y = point[1]; | |
var inside = false; | |
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) { | |
var xi = vs[i][0], yi = vs[i][1]; | |
var xj = vs[j][0], yj = vs[j][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
/*кинетической прокрутки панелей движением пальца на устройствах с WebKit-браузерами*/ | |
.ui-ScrollPanel { | |
-webkit-overflow-scrolling: touch; | |
} | |
/*Или если надо скрыть полосу прокрутки для WebKit:*/ | |
.ui-Component { | |
&::-webkit-scrollbar { | |
-webkit-appearance: none; | |
} |
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 | |
$tpl = 'Hello, my name is [[+name]]'; | |
$props = array('name' => 'Bob'); | |
// Create the temporary chunk | |
$uniqid = uniqid(); | |
$chunk = $modx->newObject('modChunk', array('name' => "{tmp}-{$uniqid}")); | |
$chunk->setCacheable(false); | |
$output = $chunk->process($props, $tpl); |
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
// http://jsbin.com/pukeho/edit?html,js,console,output | |
function getElementsByIds(obj, map) { | |
Object.keys(map).forEach(function(key) { | |
obj[key] = document.getElementById(map[key]); | |
}); | |
} | |
function objectBindDOM(obj, map) { | |
Object.keys(map).forEach(function(key) { | |
map[key][0].addEventListener(map[key][1] || 'click', obj[key].bind(obj), false); |
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 | |
function mb_ucfirst($str) { | |
$fc = mb_strtoupper(mb_substr($str, 0, 1)); | |
return $fc.mb_substr($str, 1); | |
} | |
/** | |
* "word1, word2 word3" -> "Word1, Word2 word3" | |
* NOT ucwords | |
* @param null|string $commaString |
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 | |
namespace YanaProperty; | |
use CIBlockElement; | |
class Agents { | |
const IBLOCK_ID_ADVERTISEMENT = 4; | |
public static function elapsedTop() |
NewerOlder