Skip to content

Instantly share code, notes, and snippets.

View fdcore's full-sized avatar
🦄
Работаю круглосуточно

Dmitriy Nyashkin fdcore

🦄
Работаю круглосуточно
View GitHub Profile
@mmolucio
mmolucio / cors-nginx.conf
Created April 30, 2020 15:21 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@CubexX
CubexX / plural.py
Created July 13, 2018 22:15
Python plural russian days / Склонение день/дня/дней
def plural_days(n):
days = ['день', 'дня', 'дней']
if n % 10 == 1 and n % 100 != 11:
p = 0
elif 2 <= n % 10 <= 4 and (n % 100 < 10 or n % 100 >= 20):
p = 1
else:
p = 2
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Author : Vitor Rodrigues Di Toro
# E-Mail : vitorrditoro@gmail.com
# Date : 14/03/2018
# Last Update : 19/03/2018
#
import unittest
@drewgates
drewgates / send_email.php
Last active November 30, 2016 09:52
Send email with mailgun.
<?php
//from email can be set in the relevant curl_setopt below.
//for my purposes, I was always using the same from email and didn't need one more variable to pass into this function.
//
function send_mail($email,$subject,$msg,$mailDomain,$api) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, 'api:'.$api_key);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
@ar7n
ar7n / plural.js
Created July 1, 2015 16:34
Russian plurals in js
function plural(number, one, two, five) {
var number = Math.abs(number);
number %= 100;
if (number >= 5 && number <= 20) {
return five;
}
number %= 10;
if (number == 1) {
return one;
}
@lkraider
lkraider / async-socket.py
Created August 14, 2014 23:13
Example of using gevent for async socket server and client
import gevent
import gevent.server
import gevent.monkey
gevent.monkey.patch_all()
import socket
import string
import random
import filecmp
@jonaslejon
jonaslejon / Mailgun PHP API with curl
Last active July 31, 2021 21:29
Send mail with Mailgun API version 2 and PHP. Should also work with version 3 of the Mailgun API
define("DOMAIN", "test.se");
define("MAILGUN_API", "XXX123"); // Mailgun Private API Key
function br2nl($string) {
return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $string);
}
function mg_send($to, $subject, $message) {
$ch = curl_init();
@jo
jo / js-crypto-libraries.md
Last active August 12, 2024 20:32
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

List some crypto libraries for JavaScript out there. Might be a bit out dated. Scroll to the bottom.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".
@nichtich
nichtich / README.md
Last active July 19, 2024 11:21 — forked from oodavid/README.md
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)