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
| scala> trait Presence { | |
| | type Apply[_] | |
| | } | |
| defined trait Presence | |
| scala> | |
| scala> trait Yes extends Presence { | |
| | type Apply[A] = A | |
| | } |
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
| <scheme name="Kind Darcula" version="142" parent_scheme="Darcula"> | |
| <option name="FONT_SCALE" value="1.0" /> | |
| <metaInfo> | |
| <property name="created">2017-08-30T01:26:35</property> | |
| <property name="ide">Idea</property> | |
| <property name="ideVersion">2017.2.2.0.0</property> | |
| <property name="modified">2017-09-10T01:44:15</property> | |
| <property name="originalScheme">_@user_Darcula</property> | |
| </metaInfo> | |
| <option name="EDITOR_FONT_SIZE" value="16" /> |
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
| akar.try-out=> (defn tail-recursive-sum [x running-total] | |
| #_=> (if (zero? x) running-total #(tail-recursive-sum (dec x) (+ running-total x)))) | |
| #'akar.try-out/tail-recursive-sum | |
| akar.try-out=> (alter-var-root #'tail-recursive-sum (fn [cur] (partial trampoline cur))) | |
| #object[clojure.core$partial$fn__4759 0x6188158f "clojure.core$partial$fn__4759@6188158f"] | |
| akar.try-out=> (tail-recursive-sum 10000 0) | |
| StackOverflowError clojure.lang.Util.equiv (Util.java:30) |
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
| Prelude> -- Poor man's row polymorphism | |
| Prelude> data Employee row = Employee { id :: Int, name :: String, otherFields :: row } deriving Show | |
| Prelude> data SalaryInfo = SalaryInfo Int | |
| Prelude> let e = Employee 12 "Rajguru" (SalaryInfo 10000) | |
| Prelude> :t e | |
| e :: Employee SalaryInfo | |
| Prelude> | |
| Prelude> -- Poor man's column polymorphism | |
| Prelude> data AST column = Num Int | Str String | Other column deriving Show | |
| Prelude> let c = Other (SalaryInfo 11) |
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, ZoneId} | |
| import com.amazonaws.auth.{AWSCredentialsProvider, BasicAWSCredentials, InstanceProfileCredentialsProvider} | |
| import com.amazonaws.internal.StaticCredentialsProvider | |
| import com.amazonaws.util.IOUtils | |
| import com.sksamuel.elastic4s.ElasticsearchClientUri | |
| import com.sksamuel.elastic4s.http.{HttpClient, NoOpRequestConfigCallback} | |
| import io.ticofab.AwsSigner | |
| import org.apache.http.client.methods.HttpRequestWrapper | |
| import org.apache.http.impl.nio.client.HttpAsyncClientBuilder |
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
| ! Our fancy decomposer | |
| : decompose-word ( fog -- f g ) def>> dup length 2/ cut ; | |
| ! Let's define a couple of functions, and a composition thereof to play with. | |
| : inc ( n -- n+1 ) 1 + ; | |
| : square ( n -- n^2 ) dup * ; | |
| : inc-and-square ( n -- (n+1)^2 ) inc square ; | |
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 OpenSums | |
| data FancySum a = Bar Integer | |
| | Baz | |
| | More a | |
| FancySumFlat : Type | |
| FancySumFlat = FancySum Void |
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
| > data FancySum a = Bar Int | Baz | More a deriving (Eq, Show) | |
| > let x = Bar 3 :: FancySum Void | |
| > :{ | |
| Prelude Data.Void| case x of | |
| Prelude Data.Void| Bar i -> i | |
| Prelude Data.Void| Baz -> -1 | |
| Prelude Data.Void| :} | |
| 3 | |
| > data Pet = Cat | Dog | |
| > let p = More Cat :: FancySum Pet |
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
| #!/usr/bin/env ruby | |
| # | |
| # Convert blogger (blogspot) posts to jekyll posts | |
| # | |
| # Basic Usage | |
| # ----------- | |
| # | |
| # ./blogger_to_jekyll.rb feed_url | |
| # | |
| # where `feed_url` can have the following format: |
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
| #!/usr/bin/env ruby | |
| # | |
| # Convert blogger (blogspot) posts to jekyll posts | |
| # | |
| # Basic Usage | |
| # ----------- | |
| # | |
| # ./blogger_to_jekyll.rb feed_url | |
| # | |
| # where `feed_url` can have the following format: |