Skip to content

Instantly share code, notes, and snippets.

View zishe's full-sized avatar
🏠
Working from home

Alexander Kireev zishe

🏠
Working from home
  • Ko Pha Ngan, Thailand
View GitHub Profile
players = [];
function onYouTubeIframeAPIReady() {
_.each($('.article__video-frame'), function(item, i) {
var player = new YT.Player('player' + i, {
height: '400',
width: '700',
videoId: $(item).attr('data-vid'),
events: {
'onStateChange': onPlayerStateChange
}
@zishe
zishe / ruby_override_new.rb
Created May 28, 2017 04:32 — forked from Integralist/ruby_override_new.rb
Ruby: override `new` constructor method using meta programming
module Bar
module ClassMethods
# `new` is a class method on the `Class` object
# It then uses `send` to access `initialize` which would otherwise be a private instance method
# So it can be overridden by extending the your class with a new `new` class method
def new(*args, &block)
super
p "new constructor defined"
end
end
@zishe
zishe / angular2-token.service.js
Created April 25, 2017 13:12
angular2-token/lib/angular2-token.service.js
import { Injectable, Optional } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Http, Headers, Request, RequestMethod, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/share';
import 'rxjs/add/observable/interval';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/pluck';
import 'rxjs/add/operator/filter';
var Angular2TokenService = (function () {
@zishe
zishe / test.rb
Last active August 29, 2015 14:13
Testing State Machine scopes
describe "scopes" do
# this doesn't work for state machine
# it "has scope :repaid" do
# AccountTransaction.should respond_to(:repaid)
# AccountTransaction.repaid.where_values_hash.should == { :state => :repaid }
# end
# The easiest solution
before(:all) do
@zishe
zishe / mysql_select
Created December 7, 2014 22:33
Torquebox 4 vs Go
gem 'torquebox', '4.0.0.alpha1'
jruby-1.7.16.1
$ wrk -t20 -c100 -d50s http://localhost:8080/
Running 50s test @ http://localhost:8080/
20 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 12.72ms 30.65ms 515.79ms 97.38%
Req/Sec 538.06 129.53 2.20k 78.01%
528710 requests in 50.00s, 90.20MB read
<div class="select-date-period" id="date-popup" style="display: none;">
<ul class="dates">
<li class="selected" data-start="<%= Date.today %>" data-end="<%= Date.today %>">
<span><%= t :today %></span></li>
<li class="" data-start="<%= Date.yesterday %>" data-end="<%= Date.today %>">
<span><%= t :yesterday %></span></li>
<li class="" data-start="<%= 7.days.ago.to_date %>" data-end="<%= Date.today %>">
<span><%= t :last_7_days %></span></li>
<li class="" data-start="<%= 30.days.ago.to_date %>" data-end="<%= Date.today %>">
<span><%= t :last_30_days %></span></li>
@zishe
zishe / 1. results
Created August 24, 2014 07:10 — forked from headius/1. results
# interpreted AST
system ~/projects/jruby $ jruby.bash -X-C mandelbrot.rb 20
warming up
running mandelbrot(500) for 20 iterations
4.862
4.822
4.822
4.846
5.057
// Generated on 2013-12-28 using generator-angular 0.7.1
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
require 'ostruct'
class DeepStruct < OpenStruct
def initialize(hash=nil)
@table = {}
@hash_table = {}
@array = []
if hash
@zishe
zishe / benchmark
Last active August 29, 2015 14:03
TorqBox 0.1.7 (3.1.1) + jRuby-1.7.13
plain
torqbox -b 0.0.0.0 -e production -p 9292
wrk -t20 -c100 -d10s http://0.0.0.0:9292/
Running 5s test @ http://0.0.0.0:9292/
20 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.61ms 468.01us 19.73ms 91.11%
Req/Sec 3.27k 264.78 5.00k 71.26%