Skip to content

Instantly share code, notes, and snippets.

@sofakingworld
sofakingworld / Example.ex
Last active March 25, 2018 15:18
Meta Elixir (Create methods dynamic)
defmodule Dynamic do
@methods ~w(method1 method2 method3)a
@methods
|> Enum.each( fn method ->
method_name = "prefix_#{method}"
def unquote(:"#{method_name}")(argument1, argument2) do
{unquote(method), argument1, argument2}
end
end)
@andrewstobbe
andrewstobbe / MacOSXSierra:Brew+Apache+Mysql+PHPSwitcher+DNSMasq+SSL.md
Last active July 19, 2021 02:12
Mac OSX Sierra : Brew Apache + Mysql + PHP Switcher + DNSMasq + SSL

Mac OSX Sierra : Brew Apache + Mysql + PHP Switcher + DNSMasq + SSL 👍

Things I had to do using Homebrew to get my local web dev environment back up and running after migration to OSX Sierra + Xcode 8.1.

Note: I used brew reinstall because I had already installed most of this previously under Yosemite. Probably better ways to do this, but this is what worked for me.

brew doctor

brew tap homebrew/dupes
brew tap homebrew/versions
@arenoir
arenoir / group-by.js
Last active March 26, 2016 21:39
Ember group by computed macro
import Ember from 'ember';
var get = Ember.get,
arrayComputed = Ember.arrayComputed;
export default function (dependentKey, property) {
var options = {

Elasticsearch - поисковый движок с json rest api, использующий Lucene и написанный на Java. Описание всех преимуществ этого движка доступно на официальном сайте. Далее по тексту будем называть Elasticsearch как ES.

Подобные движки используются при сложном поиске по базе документов. Например, поиск с учетом морфологии языка или поиск по geo координатам.

В этом уроке я расскажу про основы ES на примере индексации постов блога. Покажу как фильтровать, сортировать и искать документы.

Что бы урок был максимально кроссплатформенным все запросы к ES я буду делать с помощью CURL. Так же есть плагин для google chrome.

По тексту урока расставлены ссылки на другие источники. В конце урока размещены ссылки для быстрого доступа к документации. Определения незнакомых терминов можно прочитать в [глоссарии](http://www.elasticsearch.org/guide/en/elasticsearch/reference/curre

@dragolabs
dragolabs / ubunru-rsyslog-hack.sh
Last active August 18, 2017 16:35
Hack to repair 100% CPU load by rsyslog on ubuntu 12.04 in openvz
#!/bin/sh
service rsyslog stop
sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf
service rsyslog start
@pixelhandler
pixelhandler / transforms.js
Last active October 3, 2016 06:54
Raw object and array tranforms for Ember Data
/*
DS.attr('object')
*/
App.ObjectTransform = DS.Transform.extend({
deserialize: function(value) {
if (!$.isPlainObject(value)) {
return {};
} else {
return value;
}
@ryrych
ryrych / computed_property_builder.js.coffee
Created February 18, 2014 20:23
Ember.js Dynamic Computed Property Builder (based on http://www.thesoftwaresimpleton.com/blog/2013/08/11/dyanamic-cp/ by Paul Cowan)
Em.computedPropertyBuilder = (that, name, key, fn) ->
Em.defineProperty that, name, Em.computed(->
fn
).property "#{key}"
@zeroDivisible
zeroDivisible / gist:5936526
Last active January 6, 2024 20:14
Learning Japanease, taken from http://pastebin.com/w0gRFM0c
Resources marked with > are used, have been used, or are actively advocated in the threads. This applies for everything in the [Necessities] section.
[Necessities]
Hiragana & Katakana: http://www.realkana.com/
Kanji: http://kanjidamage.com/
Japanese IME: http://www.google.com/intl/ja/ime/
Anki Flashcards: http://ankisrs.net/
Genki (↓Bottom↓)
Tae Kim Japanese: http://www.guidetojapanese.org/learn/grammar
@zinkkrysty
zinkkrysty / padded_box_helper.rb
Created December 18, 2012 10:35
Automatic padding of bounding box in Prawn, and allows for filling in the background color. Currently only when specifying height, but I'm open to suggestions.
require 'prawn'
module PaddedBoxHelper
#
# Fills the background of the box you're in
#
def fill_bg_color color
float do
fill_color color
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active June 29, 2024 23:43
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#