Skip to content

Instantly share code, notes, and snippets.

View dmitrymomot's full-sized avatar
🤨

Dmytro Momot dmitrymomot

🤨
View GitHub Profile
### redirect from www to non-www
# ----------------------------------------------------------------
# Options +FollowSymLinks
# RewriteEngine On
# RewriteCond %{HTTP_HOST} ^www.site.com$
# RewriteRule (.*) http://site.com/$1 [R=301,L]
# RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
# RewriteRule ^index\.html$ http://site.com/ [R=301,L]
# RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
<?php
class Text {
/**
* Limits a phrase to a given number of characters.
*
* $text = Text::limit_chars($text);
*
* @param string $str phrase to limit characters of

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@dmitrymomot
dmitrymomot / config.py
Last active August 29, 2015 14:20 — forked from dvapelnik/config.py
YandexApiKey = 'Your.Yandex.Translate.API.Key.Should.Be.Here'

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@dmitrymomot
dmitrymomot / nginx.conf
Created January 14, 2016 10:49 — forked from calebwoods/nginx.conf
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
@dmitrymomot
dmitrymomot / ApiHeaders.php
Created September 7, 2017 18:53
Headers for json api based on Laravel 5.5
<?php
namespace App\Http\Middleware;
use Closure;
class ApiHeaders
{
/**
* Handle an incoming request.
@dmitrymomot
dmitrymomot / Laravel PHP7 LEMP AWS.md
Created October 12, 2017 16:33 — forked from santoshachari/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@dmitrymomot
dmitrymomot / tls-client.go
Created November 14, 2017 22:16 — forked from michaljemala/tls-client.go
SSL Client Authentication Golang sample
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
@dmitrymomot
dmitrymomot / main.go
Created January 9, 2018 20:45 — forked from ivanmrchk/main.go
Sending email template with golang using gomail v2 and attaching files.
package main
import (
"bytes"
"html/template"
"log"
gomail "gopkg.in/gomail.v2"
)