Skip to content

Instantly share code, notes, and snippets.

View shybovycha's full-sized avatar

Artem Shubovych shybovycha

View GitHub Profile
@shybovycha
shybovycha / mobile_detector.rb
Created November 14, 2012 13:53 — forked from tubalmartin/mobile_detector.php
Lightweight detector of mobile devices, OSs & browsers (Ruby)
class MobileDetector
# pass request.env for Rails 3.2
def initialize(headers)
@headers = headers
end
def get_mobile_os
regexps = {
#mobile OSs
'ios' => 'ip(hone|ad|od)',
@shybovycha
shybovycha / index.html
Created January 17, 2013 22:13
A very beautiful modal dialog (or a pop-up) on a CSS3. The article: http://css-tricks.com/receding-background-modal-boxes/
<div id="page-wrap">
<h1>A receding background dialog box.</h1>
<button>Open Dialog Box</button>
</div>
<div id="dialog">
<h2>I'm a dialog box. You have to click a button to open me.</h2>
<button>Close Dialog Box</button>
</div>
</div>
@shybovycha
shybovycha / png_normalizer.rb
Last active December 15, 2015 03:49 — forked from AquaGeek/png.rb
# Helper method to fix Apple's stupid png optimizations
# Adapted from:
# http://www.axelbrz.com.ar/?mod=iphone-png-images-normalizer
# https://github.com/peperzaken/iPhone-optimized-PNG-reverse-script/blob/master/Peperzaken/Ios/DecodeImage.php
# PNG spec: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html
require 'zlib'
require 'stringio'
module PngNormalizer
@shybovycha
shybovycha / README.md
Last active December 20, 2015 23:09 — forked from killercup/README.md

You have your Rails Apps with specific Gemsets in RVM.

The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.

> rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails

Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails I will refer to [GEMSET]_unicorn_rails as [WRAPPED_NAME]

@shybovycha
shybovycha / main.cpp
Created September 24, 2013 18:32
Inline assembly in MSVC
#include <stdio.h>
extern "C" int __stdcall my_proc(int, int);
int main(void)
{
int a = 1, b = 0, c = 2;
// calculate b = c^2 - a
__asm
@shybovycha
shybovycha / Postings-editor.markdown
Last active August 29, 2015 14:10
Postings editor
import threadpool
# Array needs explicit size to work, probably related to issue #2287
const a: array[0..5, int] = [1,2,3,4,5,6]
proc f(n) = echo "Hello ", n
proc main =
parallel:
for i in countup(0, a.high-1, 2):
import strutils, threadpool
let a: array[10, int] = [1,2,3,4,5,5,6,4,3,2]
proc f(x:int) =
let s = intToStr(x)
echo s
proc main =
parallel:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def lev(s1, s2, l1 = None, l2 = None):
if l1 == None:
l1 = len(s1)
if l2 == None:
l2 = len(s2)
class Mines
attr_accessor :field
attr_accessor :dimension
def initialize
build_field(rand(10) + 1, rand(10))
end
def build_field(dimension, number_of_mines)
@field = []