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
<?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
#!/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
// 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
// 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
<?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
/* | |
By [email protected] | |
<input type="hidden" name="rate" id="star_rate" value="0"> | |
<div class="stars empty" data-id="rate"> | |
<ul> | |
<li><i class="fa fa-star-o"></i></li> | |
<li><i class="fa fa-star-o"></i></li> | |
<li><i class="fa fa-star-o"></i></li> |
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 get_win($arr){ | |
$chance = rand(0, 100); | |
$keys = array_keys($arr); | |
$total = count($keys); | |
if($total == 0) return false; | |
$inter_stopper = 100;// DDOS FIX? |
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 | |
protected function parseCondition($field, $value = null, $join = '', $escape = true) { | |
if (is_string($field)) { | |
$operator = ''; | |
if (strpos($field, ' ') !== false) { | |
list($field, $operator) = explode(' ', $field); | |
} |