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 | |
//Tasofidiy son generatsiya qilish | |
function lcg(&$seed) { | |
//ushbu qiymatlar CSda tasodifiy son generatsiyasi uchun eng ko'p statistikalarga asoslanib aniqlangan | |
$a = 1664525; | |
$c = 1013904223; | |
// 2ning 32-darajasi | |
$m = pow(2, 32); |
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
#include <sys/mman.h> | |
void* c_malloc(size_t size) { | |
void* ptr; | |
asm volatile ( | |
"mov $9, %%rax\n" | |
"mov $0, %%rdi\n" | |
"mov %1, %%rsi\n" | |
"mov $3, %%rdx\n" |
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
#include <stdio.h> | |
#include <string.h> | |
void similar_str( const char* txt1, int len1, const char* txt2, int len2, int* pos1, int* pos2, int* max, int* count ) { | |
*max = 0; | |
*count = 0; | |
for ( int i = 0; i < len1; i++ ) { | |
for ( int j = 0; j < len2; j++ ) { | |
int l = 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
<?php | |
function huffmannEncode($string) { | |
$originalString = $string; | |
$occurences = array(); | |
while (isset($string[0])) { | |
$occurences[] = array(substr_count($string, $string[0]), $string[0]); | |
$string = str_replace($string[0], '', $string); | |
} |
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 findArrayWithLevenshtein( $input, $dic ) { | |
$minDistance = PHP_INT_MAX; | |
$correctedWord = $input; | |
foreach ( $dic as $key => $value ) { | |
$distance = levenshtein( $input, $key ); | |
if ( $distance < $minDistance ) { | |
$minDistance = $distance; |
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 | |
username="root" #ssh uchun foydalanuvchi | |
ssh_key_path="/home/$USER/.ssh/id_rsa.pub" #ssh kalit | |
# serverlar ro'yxati | |
servers=( | |
server1.domain.uz | |
server2.domain.uz | |
server3.domain.uz |
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 check_tasix( $ip ){ | |
$range = @file_get_contents('tasix.json'); | |
$range = json_decode($range, TRUE); | |
if( !is_array( $range ) ) return false; | |
ksort( $range ); | |
$ip2long = ip2long( $ip ); | |
if( $ip2long !== false ) { |
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
yyyy-mm-dd: /^((((19|[2-9]\d)\d{2})\-(0[13578]|1[02])\-(0[1-9]|[12]\d|3[01]))|(((19|[2-9]\d)\d{2})\-(0[13456789]|1[012])\-(0[1-9]|[12]\d|30))|(((19|[2-9]\d)\d{2})\-02\-(0[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))\-02\-29))$/g | |
yyyy/mm/dd: /^((((19|[2-9]\d)\d{2})\/(0[13578]|1[02])\/(0[1-9]|[12]\d|3[01]))|(((19|[2-9]\d)\d{2})\/(0[13456789]|1[012])\/(0[1-9]|[12]\d|30))|(((19|[2-9]\d)\d{2})\/02\/(0[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))\/02\/29))$/g | |
mm-dd-yyyy: /^(((0[13578]|1[02])\-(0[1-9]|[12]\d|3[01])\-((19|[2-9]\d)\d{2}))|((0[13456789]|1[012])\-(0[1-9]|[12]\d|30)\-((19|[2-9]\d)\d{2}))|(02\-(0[1-9]|1\d|2[0-8])\-((19|[2-9]\d)\d{2}))|(02\-29\-((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/g | |
mm/dd/yyyy: /^(((0[13578]|1[02])\/(0[1-9]|[12]\d|3[01])\/((19|[2-9]\d)\d{2}))|((0[13456789]|1[012])\/(0[1-9]|[12]\d|30)\/((19|[2-9]\d)\d{2}))|(02\/(0[1-9]|1\d|2[0-8]) |
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 write_file( $path, $data, $mode = 'wb') { | |
if ( ! $fp = @fopen( $path, $mode ) ) return FALSE; | |
flock( $fp, LOCK_EX ); | |
for ( $result = $written = 0, $length = strlen( $data ); $written < $length; $written += $result ) { | |
if ( ( $result = fwrite( $fp, substr( $data, $written ) ) ) === FALSE ) break; | |
} |
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 (typeof String.prototype.parseFunction != 'function') { | |
String.prototype.parseFunction = function () { | |
var funcReg = /function *\(([^()]*)\)[ \n\t]*{(.*)}/gmi; | |
var match = funcReg.exec(this.replace(/\n/g, ' ')); | |
if(match) { | |
return new Function(match[1].split(','), match[2]); | |
} | |
return null; |
NewerOlder