Skip to content

Instantly share code, notes, and snippets.

View Kroid's full-sized avatar

George Kroid

  • uchi.ru
  • Russia/Moskow
View GitHub Profile
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@popravich
popravich / PostgreSQL_index_naming.rst
Last active March 25, 2024 12:42
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@Phlow
Phlow / for-loop-sorted-collection
Last active April 30, 2024 13:30
This Liquid loop for Jekyll sorts a collection by date in reverse order
{% comment %}
*
* This loop loops through a collection called `collection_name`
* and sorts it by the front matter variable `date` and than filters
* the collection with `reverse` in reverse order
*
* To make it work you first have to assign the data to a new string
* called `sorted`.
*
{% endcomment %}
@popovevgeny
popovevgeny / gist:a2f3a0b2d3a21268f7f1
Last active August 29, 2015 14:17
Multicolumn directive
// <div data-multicolumn-layout data-column-count="2" data-items="items">{{item}}</div>
(function () {
'use strict';
angular
.module('app')
.directive('multicolumnLayout', multicolumnLayout);
multicolumnLayout.$inject = ['$compile'];
@rafbm
rafbm / gist:9068f377f54b6b7a0915
Created January 19, 2015 15:52
Ruby String#tr VS String#gsub benchmark
require 'benchmark'
STRING = 'Haha hah hahaa ahah!!'
FIND = 'a'
REPLACE = 'o'
STRING.tr(FIND, REPLACE) == STRING.gsub(FIND, REPLACE) or abort
Benchmark.bmbm do |bm|
bm.report '.tr' do
@SerafimArts
SerafimArts / tips.md
Last active October 22, 2021 21:43
Tips And Tricks: PhoneGap + Mobile Development (~2015 year)
  • На iOS устройствах числовые значения подчёркиваются синим. Эта проблема возникает из-за того, что iOS устройства по умолчанию считают все числа похожие на телефонные номера - телефонными номерами. Решается добавлением <meta name="format-detection" content="telephone=no" /> Тоже самое касается адреса: <meta name="format-detection" content="address=no" />

  • Пользователь может уменьшать и увеличивать приложение. Решается добавляением тега <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

  • Ссылки нажимаются с задержкой (примерно 300ms). Решается подпиской на событие touchstart и принудительной инициализацией события click после него. Если проблема всё равно возникает - ничего не поделать, надо облегчать dom. Как вариант - можно использовать библиотеку, посоветанную @adubovsky ниже в комментариях: https://gist.github.com/SerafimArts/de9900f99

@xaviervia
xaviervia / nginx-environment.md
Last active July 1, 2019 12:45
Nginx and Docker links with environment variables, a love story

How to add environment variables to nginx.conf

This is the hack approach to adding environment variables to the nginx configuration files. As with most Google results for this search, the reason is Docker.

The setup

I intended to deploy two Docker containers.

@ismell
ismell / Dockerfile
Created July 10, 2013 14:38
Installing ruby into a Docker image
FROM cws/base:2013-07-01
MAINTAINER Raul E. Rangel "Raul.Rangel@disney.com"
# Download the ruby-build code
RUN \curl -L https://github.com/sstephenson/ruby-build/archive/v20130518.tar.gz | tar -zxvf - -C /tmp/
# Install ruby-build
RUN cd /tmp/ruby-build-* && ./install.sh && cd / && rm -rfv /tmp/ruby-build-master
# Install ruby
@jpetazzo
jpetazzo / README.md
Last active September 30, 2022 05:36
Share a directory with a docker container

Rectifier

The diode bridge is the simplest rectifier I know.

Rectifier lets you share a directory with a docker container (just like $yourvm shared folders).

You don't have to install anything in your containers, and you only need to install diod in the host. diod is packaged on Ubuntu/Debian distros, and will automatically be apt-get install-ed if needed.

Since it uses diod to make a bridge, I called it rectifier. Yeah, that sucks, so if you have a better name, I'll steal it!

@miguelgrinberg
miguelgrinberg / rest-server.py
Last active March 29, 2024 09:05
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':