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 | |
/* | |
Конвертирует полное ФИО в короткое сокращение. Можно менять последовательность слов вторым параметром. | |
@param $full_name Полное ФИО | |
@param $format формат, поддержиюваются буквы A,B,C для полных слов и a,b,c для сокращений в 1 букву | |
@author Dmitriy Nyashkin | |
*/ | |
function full_name_to_short ($full_name, $format="A b. c.") { | |
$words = explode(" ", $full_name); | |
$format_keys = array("A", "B", "C"); |
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
// from http://stackoverflow.com/questions/18151877/javascript-shorten-large-numbers-force-decimal-places-and-choose-to-represent | |
function shortenNumber (num, decimalPlaces) { | |
var str, | |
suffix = ''; | |
decimalPlaces = decimalPlaces || 0; | |
num = +num; | |
var factor = Math.pow(10, decimalPlaces); |
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://stackoverflow.com/a/488073 | |
function isScrolledIntoView(elem) | |
{ | |
var docViewTop = $(window).scrollTop(); | |
var docViewBottom = docViewTop + $(window).height(); | |
var elemTop = $(elem).offset().top; | |
var elemBottom = elemTop + $(elem).height(); | |
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); |
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 python | |
# -*- coding: utf-8 -*- | |
from PIL import Image | |
def image_squere(filepath): | |
img = Image.open(filepath) | |
width, height = img.size | |
if width > height: |
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 pearson_correlation($x,$y){ | |
if(count($x)!==count($y)){return -1;} | |
$x=array_values($x); | |
$y=array_values($y); | |
$xs=array_sum($x)/count($x); | |
$ys=array_sum($y)/count($y); | |
$a=0;$bx=0;$by=0; | |
for($i=0;$i<count($x);$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
import requests | |
def mailgun_sendmail(title='no title', content='', recipients=[]): | |
status = requests.post("https://api.mailgun.net/v3/DOMAIN/messages", # DOMAIN - your domain from mailgun | |
auth=("api", "key-2h2f...."), # YOR KEY with key- | |
data={"from": "postmaster@DOMAIN", # YOUR mail from mailgun | |
"to": recipients, | |
"subject": title, | |
"html": content |
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
/*//////////////////////////////////////// | |
// Spacing | |
///////////////////////////////////////*/ | |
/* Padding Zero */ | |
.p0{padding: 0} | |
/* Padding Top */ | |
.pt0{padding-top:0} | |
.pt10{padding-top:10px} | |
.pt15{padding-top:15px} | |
.pt20{padding-top:20px} |
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 python | |
# -*- coding: utf-8 -*- | |
# influxdata metric function | |
import requests, time | |
METRIC_URL = "http://0.0.0.0:8086/" | |
def metric(database, collection='metrics', tags={}, values={}): | |
url = '' |
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 | |
/* | |
@author Dmitriy Nyashkin | |
*/ | |
$folder_path="static/"; // путь куда ложить картинки | |
$folder_public_url="https://localhost/static/"; // путь на который заменить | |
function download_file($url, $folder, $filename){ |