Skip to content

Instantly share code, notes, and snippets.

View andrey-str's full-sized avatar

Andrey Streltsov andrey-str

View GitHub Profile
@andrey-str
andrey-str / qt5-postbuild.cmake
Created July 7, 2016 11:01
Copy Qt5 dlls to app's directory [WINDOWS]
function (add_copy_qt5_postbuild_step MY_APP_NAME MY_APP_BINARY_DIR)
ADD_CUSTOM_COMMAND(
TARGET ${MY_APP_NAME} POST_BUILD
# DEBUG
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libEGLd.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libGLESv2d.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt53DCored.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt53DExtrasd.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt53DInputd.dll ${MY_APP_BINARY_DIR}
@andrey-str
andrey-str / doc.md
Created July 3, 2016 11:17 — forked from oelmekki/doc.md
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

@andrey-str
andrey-str / GIF-Screencast-OSX.md
Created July 3, 2016 07:31 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@andrey-str
andrey-str / subscribeToEditorHideEvents.coffee
Created June 26, 2016 07:43
Hide/show CKEditor toolbar on focus events
subscribeToEditorHideEvents = (id) ->
CKEDITOR.instances[id].on 'instanceReady', (e) ->
$('#cke_' + id + " [id$='_top']").hide()
$('#cke_' + id + " [id$='_bottom']").hide()
@on 'focus', ->
$('#cke_' + id + " [id$='_top']").show()
$('#cke_' + id + " [id$='_bottom']").show()
@andrey-str
andrey-str / README.md
Created June 10, 2016 13:28 — forked from cjolly/README.md
How to securely set rails secret key when you deploy to Heroku.

Stop Versioning Rails Secret Tokens

After reading Code Climate's Rails' Insecure Defaults I realized I was guilty of breaking rule 3. Versioned Secret Tokens. Here's how I fixed it.

Use dotenv in development and test environments:

# Gemfile
gem 'dotenv-rails', groups: [:development, :test]
@andrey-str
andrey-str / singleton.m
Created May 4, 2016 13:35 — forked from abbeyjackson/sharedInstance Singleton
sharedInstance singleton
+ (instancetype)sharedInstance
{
static dispatch_once_t once;
static id sharedInstance;
dispatch_once(&once, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
@andrey-str
andrey-str / integer.rb
Created April 25, 2016 10:38 — forked from pithyless/integer.rb
Ruby Integer::MAX and Integer::MIN
class Integer
N_BYTES = [42].pack('i').size
N_BITS = N_BYTES * 16
MAX = 2 ** (N_BITS - 2) - 1
MIN = -MAX - 1
end
p Integer::MAX #=> 4611686018427387903
p Integer::MAX.class #=> Fixnum
p (Integer::MAX + 1).class #=> Bignum
@andrey-str
andrey-str / replaceColor.swift
Created April 22, 2016 00:05
Replace color in UIImage with give tolerance value
// color - source color, which is must be replaced
// withColor - target color
// tolerance - value in range from 0 to 1
func replaceColor(color:SKColor, withColor:SKColor, image:UIImage, tolerance:CGFloat) -> UIImage{
// This function expects to get source color(color which is supposed to be replaced)
// and target color in RGBA color space, hence we expect to get 4 color components: r, g, b, a
assert(CGColorGetNumberOfComponents(color.CGColor) == 4 && CGColorGetNumberOfComponents(withColor.CGColor) == 4,
"Must be RGBA colorspace")
double delayInSeconds = 0.7;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
// Your code here..
});
@andrey-str
andrey-str / random-color.m
Created April 12, 2016 20:26
Random UI/SK/NSColor snippet(obj-c)
- (UIColor*) randomColor{
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
return color;
}