Skip to content

Instantly share code, notes, and snippets.

View slavikdev's full-sized avatar
🇺🇦
Donate to protect Europe: https://u24.gov.ua

Slavik Shynkarenko slavikdev

🇺🇦
Donate to protect Europe: https://u24.gov.ua
View GitHub Profile
@slavikdev
slavikdev / readme.md
Created April 21, 2017 19:51
When ElasticSearch GET works, but POST and PUT return 403 Forbidden

One of the possibilities is that in your elasticsearch.yml you have CORS enabled and the regex you use to match the origin doesn’t work. For example Chrome extensions add chrome-extension:// to the origin and matching it as /https?:\/\/.+/ won’t work. Instead you may use broader regex:

http.cors.enabled: true
http.cors.allow-origin: /.*/
@slavikdev
slavikdev / cheatsheet.md
Created March 16, 2017 17:54
Rails request path cheatsheet

Rails request path cheatsheet

Full path with query string

>>  request.url
=> "http://localhost:3000/ask-help.amp?hui=pizda"

Virtual path without query string

>>  request.path
=> "/ask-help.amp"
@slavikdev
slavikdev / gist:6117629
Created July 30, 2013 22:26
JavaScript example how to print HTML document in a separate window (specifically tested in Internet Explorer 10).
var print_window = window.open( '', 'Title', 'height=400,width=600' );
print_window.document.write( '<html><body><h1>Hello!</h1></body></html>' );
// NOTE: two statements below make it all work in IE 10.
print_window.document.close();
print_window.focus();
print_window.print();
print_window.close();
@slavikdev
slavikdev / gist:5649267
Last active December 17, 2015 17:49
Moving from VS 2008 to VS 2012 I had trouble with msbuild targets. This is easy solution is to set new v11 build targets when you're building on desktop machine and old v9 targets when build is run on a build server via command line. Put it into your .csproj file.
<Import
Condition="'$(IsDesktopBuild)' == 'true'"
Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v11.0\
WebApplications\Microsoft.WebApplication.targets" />
<Import
Condition="'$(IsDesktopBuild)' == 'false'"
Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\
WebApplications\Microsoft.WebApplication.targets" />
@slavikdev
slavikdev / cl_obj_loc_perf.rb
Created November 7, 2011 13:37
Demonstration of the code execution difference in speed when class, object and local variables are used.
# Demonstration of the code execution difference in speed when class, object and local variables are used.
# This example shows class variables performing much much worst, perhaps due to internal synchronization within Ruby engine.
# I've recently noticed that issue, profiling my code, so I don't really know the reason.
# The PI calculation algorithm has been taken somewhere and might be not best, but that's not the point.
# Results:
# MRI 1.9.3
# user system total real
# @@class => 434.228000 0.063000 434.291000 (437.134613)
# @object => 200.243000 0.031000 200.274000 (202.477156)
# local => 132.492000 0.000000 132.492000 (133.706739)
@slavikdev
slavikdev / web.config
Created October 16, 2011 13:45
web.config, helicon zoo, disable for static
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!--
This removes Helicon Zoo handler and makes IIS processing static files.
-->
<remove name="rails.project.x64" />
<remove name="rails.project.x86" />
@slavikdev
slavikdev / web.config
Created October 16, 2011 13:43
web.config, helicon zoo, thin, rails 3.1
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<heliconZoo>
<application name="rails.project.x86" >
<environmentVariables>
<add name="DEPLOY_FILE" value="deploy.rb" />
<add name="DEPLOY_LOG" value="log\zoo-deploy.log" />
@slavikdev
slavikdev / deploy.rb
Created September 15, 2011 16:58
Zoo files
# NOTE!
# Helicon Zoo module runs this script every time IIS application pool recycles.
# This has several reasons:
# 1. you may not have ability to run required commands yourself (on a shared hosting, for example);
# 2. specific URL for deployment may cause security issues;
# 3. application pool doesn't recycle often.
#
# If you're sure you don't need this file, it can be removed.
APP_ROOT = File.dirname( __FILE__ )