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
# lib/someapi_service/json.rb | |
module SomeapiService | |
class << ::ActiveSupport::JSON | |
# Exposes ActiveSupport::JSON decoding regardless of global ActiveSupport.parse_json_times. | |
# See https://api.rubyonrails.org/classes/ActiveSupport/JSON.html for more info. | |
# | |
# @note Only available in the context of SomeapiService module | |
def open_decode(json) | |
Time.use_zone('UTC') do |
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
module Api::ParamsSanitizer | |
def sanitize_param_timezones | |
params.merge!(traverse_params(params.to_unsafe_h)) | |
end | |
def traverse_params(params) | |
params.map { |k, v| traverser(k, v) }.to_h | |
end |
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
#!/bin/zsh | |
# This should work out of the box on debian based systems. See last comment for sysvinit specific adjustments | |
# required libs: | |
# - xsetwacom | |
# - xinput | |
# Attach tools to specific monitor (use port name e.g. "VGA1" for non NVIDIA drivers) | |
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
# you can write to stdout for debugging purposes, e.g. | |
# puts "this is a debug message" | |
def solution(a, k) | |
# write your code in Ruby 2.2 | |
result = [] | |
n = a.length | |
raise ArgumentError.new( | |
"Invalid argument type" | |
) if !a.is_a?(Array) || !k.is_a?(Integer) |
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
def solution(x, y, d) | |
raise ArgumentError.new( | |
"Invalid argument type" | |
) if !x.is_a?(Integer) || !y.is_a?(Integer) | |
raise ArgumentError.new( | |
"y should be less or equal to 1 000 000 000" | |
) if y > 1000000000 | |
raise ArgumentError.new( | |
"x should be less then y and greater then 0" | |
) if x > y || x < 1 |
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
module Analyzer | |
class EditDistance | |
attr_accessor :word1, :word2, :matrix | |
def initialize(word1, word2) | |
@word1 = word1 | |
@word2 = word2 | |
@w1l = @word1.length | |
@w2l = @word2.length | |
@matrix = Array.new(@w1l+1){Array.new(@word2.length+1){|i| 0}} |
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 <iostream> | |
#include "edit_distance.h" | |
using namespace std; | |
// public | |
EditDistance::EditDistance(char *string1, char *string2){ | |
s1 = string1; | |
s2 = string2; | |
rows = strlen(s1)+1; |
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
def solution(n) | |
# n - integer to calculate binary gap on, constrained | |
raise ArgumentError.new( | |
"Expected n to be an integer 'n' where 1 < n < 2,147,483,647" | |
) if !n || !n.is_a?(Integer) || n < 1 || n > 2147483647 | |
max_length = 0 | |
occurance_count = 0 | |
n.to_s(2).split('').each do |bit| |
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
def mult(a,b) | |
return 0 if a == 0 || b == 0 | |
if a == 1 | |
b | |
else | |
b+mult(a-1,b) | |
end | |
end |
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 React from "react"; | |
import "./withNestedScrolling"; | |
// On scrolling down comment-list-navigation will dissapear with slideOutUp animation | |
// On scrolling up comment-list-navigation will reappear with slideInDown animatio | |
const CommentsList = props => { | |
const { nestedScrollTargetHeight, scrollTargetRef, nestedScrollTargetRef } = props; | |
return ( |