Skip to content

Instantly share code, notes, and snippets.

View alexandru-calinoiu's full-sized avatar
💭
Crafting

Calinoiu Alexandru Nicolae alexandru-calinoiu

💭
Crafting
View GitHub Profile
ab -p tests/errors.txt -T application/x-www-form-urlencoded -H "Token: token" -H "Api-Key: api-key" -e tests/errors_mri_result.csv -n 1024 -c 16 http://localhost:3000/v1/api/errors/
@alexandru-calinoiu
alexandru-calinoiu / user_finders.rb
Last active December 25, 2015 03:49
finding users
module UserFinders
extend ActiveSupport::Concern
def find_user_application(token)
user_applications.find(token)
end
end
Concurrency Level: 16
Time taken for tests: 186.323 seconds
Complete requests: 1024
Failed requests: 0
Write errors: 0
Total transferred: 583680 bytes
Total POSTed: 366592
HTML transferred: 246784 bytes
Requests per second: 5.50 [#/sec] (mean)
Time per request: 2911.298 [ms] (mean)
Concurrency Level: 16
Time taken for tests: 23.776 seconds
Complete requests: 1024
Failed requests: 0
Write errors: 0
Total transferred: 583680 bytes
Total POSTed: 366592
HTML transferred: 246784 bytes
Requests per second: 43.07 [#/sec] (mean)
Time per request: 371.504 [ms] (mean)
class UserApplication
include Mongoid::Document
include Mongoid::Timestamps
include ApplicationErrorBuilder
include UserApplicationFinders
field :name, type: String, default: ''
embeds_many :application_errors
belongs_to :user
@alexandru-calinoiu
alexandru-calinoiu / errors_api.rb
Last active December 25, 2015 03:49
Grape api end point
module Apibugfreak
class Resources::V1::ErrorsAPI < Grape::API
resources :errors do
desc 'Create a error'
post do
authenticate!
ApplicationErrorService.new(@current_application).create_application_error(params)
end
end
ActiveAdmin::Dashboards.build do
# Add this section in your dashboard...
section "Background Jobs" do
now = Time.now.getgm
ul do
li do
jobs = Delayed::Job.where('failed_at is not null').count(:id)
link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red'
end
using System.Text;
public class KDoubleSubstrings
{
public int howMuch(string[] str, int k)
{
int result = 0;
StringBuilder stringBuilder = new StringBuilder();
foreach (string s in str)
using System;
using System.Globalization;
using System.Text;
public class MountainWalk
{
private string[] _areaMap;
private int _height;
@alexandru-calinoiu
alexandru-calinoiu / widget.js
Created December 7, 2012 16:20
Load tg widget
(function () {
var jQuery;
var token = "42";
var location = "<%= "http://#{ActionMailer::Base.default_url_options[:host]}/" %>";
if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.8.2') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js");
if (script_tag.readyState) {