Skip to content

Instantly share code, notes, and snippets.

Stanislav Palatnik stanpalatnik

Block or report user

Report or block stanpalatnik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stanpalatnik
stanpalatnik / ParquetToArrow.java
Created Jun 5, 2019 — forked from animeshtrivedi/ParquetToArrow.java
Example program to convert Apache Parquet data to Apache Arrow
View ParquetToArrow.java
/* This code snippet is a part of the blog at
https://github.com/animeshtrivedi/blog/blob/master/post/2017-12-26-arrow.md
*/
import com.google.common.collect.ImmutableList;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.*;
import org.apache.arrow.vector.dictionary.DictionaryProvider;
import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.pojo.ArrowType;
View loader.css
$boxsize: 20;
$gutter: 5;
$x1: $boxsize + $gutter;
$x2: $x1 * 2;
$duration: 7;
.loader {
position: absolute;
top: 50%;
View textsum.scala
case class Summary(results: IndexedSeq[Sentence]) extends Traversable[String] {
lazy val charCount = if (results.isEmpty) 0 else results.map(_.sentence.size).sum
def foreach[U](f: String => U) {
results.foreach( s => f(s.sentence) )
}
def takeChars(limitCharCount: Int): Summary = {
var count = 0
View euler02.scala
import scala.annotation.tailrec
import scala.collection.mutable
object Euler02 extends App {
@tailrec
def fib(num: Int, prev: Int, result: mutable.Builder[Int, Vector[Int]] = Vector.newBuilder[Int]): Vector[Int] = {
num match {
case 0 => result.result()
case x if x > 4000000 => result.result()
View AbstractBackend.scala
import DbWrapper._
import scala.util.{Failure, Success, Try}
class Auctioneer {
/**
*
* @param item
* @return Boolean Whether or not the auction was successfully started
*/
def startAuction(item: Item): Boolean = {
View gist:9ef1b4baefb6847aa58b
@tailrec
def extractor[T](resultSet: ResultSet,
result: scala.collection.mutable.Builder[T, Vector[T]] = Vector.newBuilder[T])( process: ResultSet => T ): Vector[T] = {
if (!resultSet.next) result.result()
else {
val value = process(resultSet)
extractor(resultSet, result += value)(process)
}
}
View approach2.scala
detach { //this creates a new actor
completeWith { //we use a completeWith directive which respones with whatever we output at the end of the code block
var person = new Person();
person.address = getAddress(address['latitude'], address['longitude']).then((result) => person.address = result)
person.save
"saved!"
}
}
View gist:2287475
<form id="form" name="form" method="post" action="/signin">
<h1>Sign-in form</h1>
<div><label>Username
</label>
<input type="text" name="user[username]" class="required" id="username"/></div>
<div>
<input type="password" name="user[password]" class="required" id="password"/></div>
@stanpalatnik
stanpalatnik / index.html
Created Mar 3, 2012
Dust.js Client side
View index.html
<html>
<head>
<script src="dust-full-0.3.0.min.js"></script>
<script type="text/javascript">
//example showing client-side compiling and rendering
var compiled = dust.compile("Hello {name}!", "index");
dust.loadSource(compiled);
dust.render("index", {name: "David"}, function(err, out) {
if(err != null)
You can’t perform that action at this time.