Skip to content

Instantly share code, notes, and snippets.

@ytaras
ytaras / Links
Last active August 29, 2015 14:11
Preparing for Presentation
@ytaras
ytaras / rails_best_practices.rake
Created November 27, 2012 11:13 — forked from bash0C7/rails_best_practices.rake
exec rails_best_practices on "rails3 rake" for jenkins plot plugin
namespace :rails_best_practices do
desc "run rails best practices"
task :jenkins_plot_plugin => :environment do
cd Rails.root do
OUTDIR = "#{Rails.root}/reports"
mkdir OUTDIR unless FileTest.exist? OUTDIR
OUTFILE = "#{OUTDIR}/rails_best_practices.properties"
@ytaras
ytaras / Env.hs
Created July 8, 2013 16:32
Getting environment variable in type-safe and composable way
module Env where
import System.IO.Error (isDoesNotExistError)
import GHC.IO.Exception (IOException)
import System.Environment (getEnv)
import Control.Monad.Error (catchError, Error, ErrorT)
import Control.Monad ((>=>), liftM)
-- Error handler
data GenericError =
-- wrapper for IOExceptions
@ytaras
ytaras / gist:6352927
Last active December 21, 2015 19:18
React on user input only after some amount of time
import Graphics.Input as Input
(hashTagField, rawHashTag) = Input.field "Type your hash tag"
main = fields
fields = above <~ hashTagField ~ (asText <~ hashTag)
hashTag : Signal String
hashTag = delayed (2*second) [] rawHashTag
@ytaras
ytaras / gist:6362691
Last active December 21, 2015 20:39
Wip for TODO in Elm
import Graphics.Input as Input
import Text as T
import Keyboard as K
-- utility
ith : Int -> [a] -> a
ith index = head . drop index
replaceIth : [a] -> Int -> (a -> a) -> [a]
-- [x] Get input from user
-- [x] Do it only every two seconds
-- [x] Filter output < 3
-- [x] Send request to server
-- [x] Display results to user
import Graphics.Input as Input
import Maybe
import Http as H
import Json as J
@ytaras
ytaras / basic.rb
Last active December 22, 2015 16:09
# Dynamic typing
if false
"".foo
end
# Strong typing
[] + {}
{} + []
{} + ""
[] + ""
@ytaras
ytaras / Log
Created May 8, 2018 07:37
ltree resolve
2018-05-08 07:31:21.892 UTC [33] LOG: duration: 924169.808 ms plan:
Query Text: create temporary table resolved_by_ltree as
select rule_id, rule_pcd, product_leaf_pcd, location_leaf_pcd from
(select
rule_id,
rule_pcd,
product_leaf_pcd,
location_leaf_pcd,
row_number()
over (
package org.apache.beam.examples.usercount;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import java.io.Serializable;
import org.apache.beam.examples.usercount.ChangeStateTraker.ChangeResult;
import org.apache.beam.sdk.coders.AvroCoder;
import org.apache.beam.sdk.coders.Coder;
import org.apache.beam.sdk.coders.DefaultCoder;
import org.apache.beam.sdk.state.StateSpec;
package org.apache.beam.examples.usercount.transformexample;
import com.google.cloud.firestore.Firestore;
import com.google.cloud.firestore.FirestoreOptions;
import com.google.cloud.firestore.WriteBatch;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import org.apache.beam.examples.usercount.domain.ProgressEvent;