Skip to content

Instantly share code, notes, and snippets.

View yentsun's full-sized avatar

Maksim Korinets yentsun

  • SimpleCrew
  • Vung Tau, Vietnam
  • 07:34 (UTC +07:00)
View GitHub Profile
@yentsun
yentsun / structure.md
Last active April 28, 2018 21:08
File structure with ASCII
🗀 root/
├── 🗀 childOne/
│   ├── 🖹 fileOne.txt
│   ├── 🖹 fileTwo.rst
│   ├── 🖹 fileThree.md
│   └── 🖹 README
├── 🗀 childTwo/
│   ├── 🖹 fileOne.txt
│ └── 🖹 fileTwo.rst
@yentsun
yentsun / nginx.conf
Last active July 20, 2018 08:02
Simple Nginx config with SSL
server {
listen 80;
listen [::]:80;
server_name .example.com;
return 301 https://example.com;
}
server {
@yentsun
yentsun / sleep.js
Last active May 29, 2018 19:54
ES6 Sleep
const sleep = require('util').promisify(setTimeout);
//...
await sleep(15);
//...
@yentsun
yentsun / gist:7926035
Created December 12, 2013 10:36
apache2 site example
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example.net
ServerAlias www.example.net
DocumentRoot /var/www/example.net/public_html/
ErrorLog /var/www/example.net/logs/error.log
</VirtualHost>
@yentsun
yentsun / gist:7132890
Created October 24, 2013 07:43
Apache config for virtual hosts as directories
<VirtualHost *:80>
ServerName doesntmatter
UseCanonicalName Off
VirtualDocumentRoot /home/webdev/%0
</VirtualHost>
@yentsun
yentsun / gist:5619327
Last active December 17, 2015 13:48
A working example of Apache Virtual Host config for a pyramid app served with mod_wsgi. Ubuntu 13.04, Apache 2.
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName appname.com
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess appname user=username group=username processes=1 threads=4 python-path=/home/username/env/lib/python2.7/site-packages
WSGIProcessGroup appname
WSGIScriptAlias / /home/username/Projects/AppName/pyramid.wsgi
</VirtualHost>
@yentsun
yentsun / lycene_ibdex.py
Created February 2, 2012 07:31
An example of indexing records from a database with PyLucene 2.3 for later quering from Zend_Search_Lucene.
# -*- coding: utf-8 -*-
import os, sys, subprocess
import ConfigParser
import lucene
from optparse import OptionParser
from sqlalchemy import MetaData, Table, create_engine, orm
INDEX_DIRECTORY = '%s/items' % os.path.dirname(os.path.realpath(__file__))
@yentsun
yentsun / zend_lucene_pagination.php
Created February 1, 2012 14:09
An example of paginating Zend_Lucene search results
<?php
$index = Zend_Search_Lucene::open(your_index_dir);
$query = 'some search query';
$result = $index->find($query);
$perPage = 20;
$page = 5;
$range = 4;
Zend_Paginator::setDefaultScrollingStyle('Elastic');
@yentsun
yentsun / evenly_spread.js
Created February 1, 2012 08:05
An example of even spreading of li elements (with child li elements) within a set number of columns using jQuery.
$(function(){
var columns_no = 4;
$('.popup').each(function(){
var total_height = $(this).find('li:not(.brands_column li)').length;
var column = $(this).find('.column1');
var average_height = Math.ceil(total_height / columns_no);
column.data('height', 0);
var total_categories = $(this).find('li.depth1').length;
$(this).find('li.depth1').each(function(){
if (total_categories == columns_no) {