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
package tailtopic | |
import org.apache.kafka.clients.consumer.KafkaConsumer | |
import java.util.Properties | |
import scala.collection.JavaConverters._ | |
import org.apache.avro.generic.GenericRecord | |
object Main extends App { | |
val consumerProperties = { | |
val props = new Properties() |
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.collection.mutable.ListBuffer | |
object Factorization { | |
implicit class FancyInt(val n: Int) extends AnyVal { | |
def primeFactors(): List[Int] = { | |
var factor = 2 | |
var number = n | |
var factors = new ListBuffer[Int]() | |
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
// Solution to Pere's first Scala challenge | |
// by Dejan | |
object Compression { | |
// Drops element ++el++ and all its consecutive appearances in head of the list ++li++ | |
def chop(li: List[Any], el: Any) = { | |
li dropWhile (_ == el) | |
} | |
// Eliminates consecutive duplicates of list elements |
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
package main | |
// using asymmetric crypto/RSA keys | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" |
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
[18] pry(main)> expense.errors.keys | |
=> [] | |
[19] pry(main)> expense.errors[:something] | |
=> [] | |
[20] pry(main)> expense.errors.keys | |
=> [:something] ### !!! so getter on L19 changed the state | |
[21] pry(main)> expense.errors.has_key? :something |
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
- title = 'auto_html demo' | |
- content_for :title, title | |
.page-header | |
%h1 | |
.pull-right | |
.btn-group | |
= link_to 'article', '/2010/08/15/auto_html', class: 'btn' | |
= link_to 'source', 'https://github.com/dejan/auto_html', class: 'btn' |
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
# This is a monkey patch for the SimpleForm issue (actually it's a Rails' collection_select issue) | |
# of adding attributes to select options. Downside is that you loose value/label_method options, | |
# but that's easily replacable by using map on the collection (and should be done in some decorator anyways). | |
# See here for more details about the issue: https://github.com/plataformatec/simple_form/issues/188 | |
module SimpleForm | |
module Inputs | |
class CollectionSelectInput < CollectionInput | |
def input | |
@builder.select attribute_name, collection, input_options, input_html_options | |
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 "twitter/bootstrap"; | |
.whatever { | |
@extend .well; | |
} |
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
Surround these with : e.g. :calling: | |
+1 | |
-1 | |
bulb | |
calling | |
clap | |
cop | |
feet |
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/sh | |
# http://onrails.org/articles/2009/09/04/rmagick-from-source-on-snow-leopard | |
# install wget, which is cleverer than curl | |
# curl -O http://ftp.gnu.org/gnu/wget/wget-1.11.tar.gz | |
# tar zxvf wget-1.11.tar.gz | |
# cd wget-1.11 | |
# ./configure --prefix=/usr/local | |
# make |
NewerOlder