-
[YouTuve] Você quer ser um Milionário? - Não existe milágre, o segredo é guardar dinheiro e o tempo que se guarda o dinheiro. Seguir a regra dos 3Gs - [Ganho / Guardo (sempre antes de gastar) / Gasto] e pensar se um gasto agora é realmente importante.
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
| /** | |
| * In a static language like scala, how could we repeatedly flatten a datastructure without reflection? | |
| * This is an interesting example of using implicit parameters to do the work for you. | |
| */ | |
| object DeepFlatten { | |
| // what should this really be called? ;) | |
| trait Flattenable[F[_]] { | |
| def flatten[A](f: F[F[A]]): F[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
| Copyright (c) 2012 Rizal Almashoor | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE |
To view the progress of a Powerpoint presentation, a progress bar can be displayed at the bottom of the slide show.
Once the slideshow is complete, go to Tools > Macro > Visual Basic Editor.
In the new window, select Insert > Module and copy this text in the blank page:
Sub AddProgressBar()
On Error Resume Next
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
| // An ADT+shapeless as a drop-in replacement for a standard Scala Enumeration. | |
| // | |
| // First the unsafe standard Scala Enumeration ... | |
| // | |
| object ScalaEnumDemo extends App { | |
| // Example from scala.Enumeration scaladoc. Terse ... | |
| object WeekDay extends Enumeration { | |
| type WeekDay = Value | |
| val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value | |
| } |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
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 scala.language.postfixOps | |
| import scala.concurrent._ | |
| import scala.concurrent.duration._ | |
| import akka.pattern.pipe | |
| import akka.actor._ | |
| import akka.cluster.routing._ | |
| /** | |
| * Concept and some code lifted from | |
| * https://github.com/jsuereth/intro-to-fp, thanks Josh! |
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 ClusterMetricsElasticScaleListener extends Actor with ActorLogging { | |
| val selfAddress = Cluster(context.system).selfAddress | |
| override def preStart(): Unit = | |
| Cluster(context.system).subscribe(self, classOf[ClusterMetricsChanged]) | |
| override def postStop(): Unit = | |
| Cluster(context.system).unsubscribe(self) | |
| def receive = { |
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.util.Formatter; | |
| public class Bytes2Hex { | |
| public static String byteToHex(final byte[] hash) { | |
| try (final Formatter formatter = new Formatter()) { | |
| for (byte b : hash) | |
| formatter.format("%02x", b); | |
| return formatter.toString(); | |
| } | |
| } |
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.util.zip._ | |
| import java.io._ | |
| class InMemZip(compressionLevel: Int) { | |
| private val _outBytes = new ByteArrayOutputStream | |
| private val _zipOutStream = { | |
| val s = new ZipOutputStream(_outBytes) | |
| s.setLevel(compressionLevel) | |
| s | |
| } |