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
var drawArrow = function (context, x1, y1, x2, y2) { | |
context.lineWidth = 1.25; | |
context.beginPath(); | |
context.moveTo(x1, y1); | |
context.lineTo(x2, y2); | |
context.stroke(); | |
var a = Math.PI / 8; | |
var h = 12; | |
var sa = Math.sin(a); |
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
// (Math.exp(704.6589) / Math.expm1(704.6589) - 1) / Number.EPSILON | |
var isExpOK = Math.exp(704.6589) >= 1.0702171200481775e+306 * (1 - 16 * Math.pow(2, -52)) && | |
Math.exp(704.6589) <= 1.0702171200481775e+306 * (1 + 16 * Math.pow(2, -52)); | |
// (Math.exp(704.6589) / Math.expm1(704.6589) - 1) / Number.EPSILON | |
var isExpOK = Math.exp(704.6589) >= 1.0702171200481775e+306 * (1 - 16 * Math.pow(2, -52)) && | |
Math.exp(704.6589) <= 1.0702171200481775e+306 * (1 + 16 * Math.pow(2, -52)); | |
Math.exp = function (x) { | |
var hi = 0.6931471805598903; | |
var lo = 5.497923018708371e-14; | |
var k = Math.floor(x / hi + 0.5); |
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
// http://www.w3.org/TR/html5/association-of-controls-and-forms.html#concept-form-submit | |
// FormData (to support files?) FormData.append... (only POST + not string result???) | |
function serializeForm(form, submitter, useFormData) { | |
useFormData = useFormData && window.FormData; | |
var results = useFormData ? (new FormData()) : [], tagName, i, opts, j, field, elements = form.elements; | |
for (j = 0; j < elements.length; j++) { | |
field = elements[j]; | |
tagName = field.tagName.toLowerCase(); | |
if (tagName === 'object' || (tagName === 'input' && (field.type === 'image' || (!useFormData && field.type === 'file')))) { | |
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
// http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order | |
// callback(permutation, even) | |
function permutations(n, callback) { | |
n >>>= 0; | |
var p = n ? [] : null, | |
even = true; | |
for (i = 0; i < n; i++) { | |
p[i] = i; | |
} |
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
// http://en.wikipedia.org/wiki/Approximate_string_matching | |
function fuzzySearch(t, p) { // returns minimum edit distance between substring of t and p | |
var a = [], // current row | |
b = [], // previous row | |
pa = [], // from | |
pb = [], | |
s, i, j; | |
for (i = 0; i <= p.length; i++) { | |
s = b; | |
b = a; |
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 strtolower_utf8($string) { | |
$convert_to = array( | |
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", | |
"v", "w", "x", "y", "z", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", | |
"ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "а", "б", "в", "г", "д", "е", "ё", "ж", | |
"з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", | |
"ь", "э", "ю", "я" | |
); | |
$convert_from = array( | |
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", |
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
/*jslint node: true, indent: 2 */ | |
"use strict"; | |
var httpPort = 4022; | |
var http = require('http'); | |
var dgram = require('dgram'); | |
var querystring = require('querystring'); |
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
CREATE TABLE IF NOT EXISTS `rabota_ids` ( | |
`ID` varchar( 255 ) NOT NULL DEFAULT '', | |
`region` varchar( 1 ) NOT NULL , | |
`parsed` varchar( 1 ) DEFAULT '0', | |
`added` date NOT NULL , | |
UNIQUE KEY `ID` ( `ID` ) | |
) ENGINE = MYISAM DEFAULT CHARSET = utf8; | |
ALTER TABLE `zarplata_v` CHANGE `source` `source` ENUM( '0', '1', '2', '3', '4' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0'; | |
ALTER TABLE `zarplata_r` CHANGE `source` `source` ENUM( '0', '1', '2', '3', '4' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0'; |
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
было: | |
if($fitwidth>$originalsize[0]) $fitwidth=$originalsize[0]; | |
if($fitheight>$originalsize[1]) $fitheight=$originalsize[1]; | |
if(($h[0]/$fitwidth)>($h[1]/$fitheight)) | |
{ | |
$x=($originalsize[0] - $h[1]/$fitheight*$fitwidth) / 2; | |
$y=0; | |
//$fitheight=$h[1]*$fitwidth/$h[0]; | |
}else{ |
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 parse_mysql_dump($url) { | |
$handle = @fopen($url, "r"); | |
$query = ""; | |
while(!feof($handle)) { | |
$sql_line = fgets($handle); | |
if (trim($sql_line) != "" && strpos($sql_line, "--") === false) { | |
$query .= $sql_line; | |
if (preg_match("/;[\040]*\$/", $sql_line)) { |
OlderNewer