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
require 'benchmark' | |
NA = 1000000 | |
N = 1000 | |
ARR = Array.new(NA) { rand }.freeze | |
Benchmark.bm do |x| |
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
kRPC Benchmarks & Checks |
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
# | |
# http://puzzling.stackexchange.com/questions/32438/hey-they-are-all-under-4 | |
# | |
require 'active_support/core_ext/array' | |
c = "222123013102101232202311300000113113" | |
def decode(base,digits) | |
digits.reverse.inject([0,[]]) {|a,e| [a[0]+1, a[1] + [e*base**a[0]]]}[1].inject(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
# | |
# https://www.youtube.com/watch?v=vIdStMTgNl0 | |
# | |
$SUCCESS = 0 | |
$M = 1_000_000 | |
$N = 10 | |
puts Time.now |
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 prev_photo_url(album, photo, **options) | |
prev_photo_id = album.prev_photo_id(photo) | |
album_photo_url album, prev_photo_id, options if prev_photo_id | |
end | |
def prev_photo_path (album, photo, **options) | |
prev_photo_url(album, photo, {only_path: true}.merge!(options)) | |
end | |
def next_photo_url(album, photo, **options) | |
next_photo_id = album.next_photo_id(photo) |
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 java.time.LocalDateTime | |
import java.time.format.DateTimeFormatter | |
object HalfBirthdate { | |
val date_2000_02_29: LocalDateTime = LocalDateTime.parse("2000-02-29T00:00:00") | |
case class HalfBirthdate(earlierHalfBirthDate: LocalDateTime, laterHalfBirthDate: LocalDateTime) { | |
def show() { | |
println("Earlier half-BirthDate: " + format(earlierHalfBirthDate)) |
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
<div class='spinner-container'> | |
<div class='spinner'> | |
<% 8.times do %> | |
<div> | |
<div></div> | |
</div> | |
<% end %> | |
</div> | |
</div> |
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 PID | |
attr_reader :kp, :ki, :kd, :output, :previous_error | |
attr_accessor :setpoint, :history_depth, :output_range, :invert_output | |
def initialize(setpoint, options = {}) | |
@setpoint = setpoint | |
@kp = options[:kp] || 1 | |
@ki = options[:ki] || 0 | |
@kd = options[:kd] || 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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="org.example.battery_level_monitor_example" | |
android:versionCode="1" | |
android:versionName="0.0.1"> | |
<uses-sdk | |
android:minSdkVersion="9" | |
android:targetSdkVersion="16" /> |