Skip to content

Instantly share code, notes, and snippets.

View dmitry's full-sized avatar
🇪🇪
Water, earth and air.

Dmitry Polushkin dmitry

🇪🇪
Water, earth and air.
View GitHub Profile
@ffoxin
ffoxin / sqtm
Last active August 29, 2015 13:55
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <thread>
#include <vector>
using namespace std;
inline size_t calc(const size_t n, const size_t i, const size_t j)
{
@mhuggins
mhuggins / multiparameter_attribute_assignment.rb
Last active September 5, 2020 19:41
MultiparameterAttributeAssignment
# app/models/concerns/multiparameter_attribute_assignment.rb
module MultiparameterAttributeAssignment
include ActiveModel::ForbiddenAttributesProtection
def initialize(params = {})
assign_attributes(params)
end
def assign_attributes(new_attributes)
@kkoch986
kkoch986 / gist:8312121
Created January 8, 2014 05:11
Use of a Trie to compute all possible word combinations found in a single word
var Trie = require("./index").Trie;
var t = new Trie();
// ... add your word dictionary ....
t.addStrings(["experts", "exchange", "pen", "island", "choose", "spain", "kids", "express", "childrens", "wear", "dickson", "web"]);
var testDomains = ["expertsexchange", "penisland", "choosespain", "kidsexpress", "childrenswear", "dicksonweb"];
function decompose(search) {
// find all of the words which start from the first letter
@Fivell
Fivell / gist:8151821
Created December 27, 2013 19:54
ActiveAdmin Dynamic filters fix
module ActiveAdmin
module Filters
# This form builder defines methods to build filter forms such
# as the one found in the sidebar of the index page of a standard resource.
class FormBuilder < ::ActiveAdmin::FormBuilder
include ::ActiveAdmin::Filters::FormtasticAddons
def initialize(*args)
@use_form_buffer = true # force ActiveAdmin::FormBuilder to use the form buffer
module ActiveAdminHelper
def admin_arbre_context
@admin_arbre_context ||= Arbre::Context.new(assigns, self)
end
def default_renderer
case controller.send(:resource_class).name
when "ActiveAdmin::Page"
"page"
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active January 6, 2025 09:05
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@theblogarticles
theblogarticles / how to reduce alexa ranking quickly and easily day by day?
Created November 29, 2013 06:39
how to reduce alexa ranking quickly and easily day by day?
Install Alexa Toolbar
This issue is most vital in context to enhance Alexa rank.You must install Alexa Toolbar on all the browsers you often use.Also raise your guests,friends,Partners to put in Alexa Toolbar on their Browser likewise.
Claim/Verify your web site on Alexa.com
You can simply claim your web site on Alexa.com.Sign up with a brand new account of your {website|blog} then insert meta tag within the head Section of your site.Once Approved,you definitely see a forceful increment in Ranking and your Alexa rank improve inside per week.
place Alexa gizmo on your diary
As i had mentioned on top of,How Alexa rank is measured for a specific Website?So either your traveler ought to have put in Alexa Toolbar or your web site provides a gizmo that displays Alexa rank that it’s to counted within the Alexa Traffic Ranking Stats.
Increase Traffic
FROM ubuntu:12.04
MAINTAINER Nicolas BERNARD <[email protected]>
# Ruby
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C3173AA6
RUN echo deb http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu precise main > /etc/apt/sources.list.d/brightbox.list
# NodeJS (Assets pipeline)
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C7917B12
RUN echo deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu precise main > /etc/apt/sources.list.d/nodejs.list
/*
Cross-browser (including IE8-10)
Más info: http://coding.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css/
*/
.absolute-center {
/* height: must be declared */
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}

Saving ActiveAdmin filters between requests

This shows one technique for preserving filters on index pages for ActiveAdmin resources, without having to patch the ActiveAdmin core.

It restores any previously-used filters whenever the index page is rendered for a resource, unless the current request is an actual application of new filters. It also properly handles the clear-filters button (via a synchronous Ajax request that happens immediately before the normal filter form processing).

Yes, it's a bit of a hack, but it has worked well for me so far.

Usage