A Pen by Artem Shoobovych on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
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]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <math.h> | |
| #include <SFML/Window.hpp> | |
| #define Persistence 1.f / 8.f | |
| #define Number_Of_Octaves 7 | |
| inline float interpolate(float a, float b, float x) | |
| { | |
| float ft = x * 3.1415927; |
OlderNewer