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
#include <iostream> | |
#include <utility> | |
#include <tuple> | |
#include <typeinfo> | |
template<typename, template<typename...>class> | |
struct repack { | |
}; |
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
#include <iostream> | |
#include <utility> | |
template<template<typename ..._> class F, typename ...Ts> | |
F<Ts...> p(Ts... args){ | |
return F<Ts...>(args...); | |
} | |
int main(int argc, char const* argv[]) | |
{ |
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
private def request(charset: String)(f: => HttpUriRequest): Try[String] = Try { | |
val c = clientBuilder.build() | |
try { | |
val res = c.execute(f) | |
try { | |
EntityUtils.toString(res.getEntity, charset) | |
} finally { | |
HttpClientUtils.closeQuietly(res) | |
} | |
} finally { |
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.annotation.tailrec | |
object Prog { | |
def primes(n: Int): List[Int] = { | |
@tailrec | |
def loop(cs: List[Int], ps: List[Int]): List[Int] = { | |
cs.headOption match { | |
case Some(n: Int) => loop(cs.tail.filterNot(_ % n == 0), n::ps) | |
case None => ps | |
} |
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 twitter4j._ | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object Main{ | |
def open(url: String): Unit = { | |
import scala.sys.process.Process | |
Future { Process("open", Seq(url)).! } | |
} |
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 twitter4j._ | |
object Main{ | |
def main(args: Array[String]): Unit = { | |
val t = new TwitterStreamFactory().getInstance | |
t.addListener(new UserStreamAdapter { | |
override def onStatus(status: Status): Unit = { | |
val urls = status.getMediaEntities().collect { case e:MediaEntity if e.getType == "photo" => e.getMediaURL } | |
val eurls = status.getExtendedMediaEntities().collect { case e:ExtendedMediaEntity if e.getType == "photo" => e.getMediaURL } | |
(urls ++ eurls).distinct.foreach(println) |
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/bash -x | |
for fname in $(find $1 -type f);do | |
mv $fname ${fname%:orig} | |
done |
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
javascript:(function(){var e=window.location.href,t=new RegExp("(:(orig|large))?$");e=e.replace(t,":orig");var n=e.match(".+/(.+?):orig$")[1],o=document.createElement("a");o.href=e,o.setAttribute("download",n),o.dispatchEvent(new CustomEvent("click"))})(); |
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
#include <iostream> | |
#include <type_traits> | |
#include <iterator> | |
template<typename InputIterator, typename Predicate> | |
bool all_of(InputIterator begin, InputIterator end, Predicate pred){ | |
static_assert(std::is_integral<typename std::result_of<Predicate(typename std::iterator_traits<InputIterator>::value_type)>::type>::value, "pred should return integral"); | |
while (begin != end){ | |
if(!pred(*begin++)) return false; | |
} |
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
#include <iostream> | |
#include <type_traits> | |
#include <iterator> | |
#include <vector> | |
#include <utility> | |
template<typename Function, typename InputIterator> | |
auto mapping(Function f, InputIterator begin, InputIterator end) | |
-> std::vector< | |
typename std::result_of<Function(typename std::iterator_traits<InputIterator>::value_type)>::type |