source | gistUrl | gistFile |
---|---|---|
github-gist |
Todoist.md |
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 python3 | |
# encoding: utf-8 | |
"""Use instead of `python3 -m http.server` when you need CORS""" | |
from http.server import HTTPServer, SimpleHTTPRequestHandler | |
class CORSRequestHandler(SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_header('Access-Control-Allow-Origin', '*') |
rename a section of a filename, i. e. example.1.{txt,conf,db} or 12345.1.{wav,ogg,mp3} and change the 1 to a 2 in the filename while preserving the rest of it.
zmv -n '(*.)(<->)(.[^.]#)' '$1$(($2+1))$3' # would rename x.0001.y to x.2.y.
zmv -n '(*.0#)(<->)(.[^.]#)' '$1$(($2+1))$3'
$ zmv '*' '${(L)f}'
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 $ivy.`com.chuusai::shapeless:2.3.3` | |
import shapeless._ | |
trait Fields[T] { | |
def fields: List[String] | |
override def toString: String = fields.mkString(", ") | |
} | |
object Fields extends LabelledProductTypeClassCompanion[Fields] { | |
def apply[T](fs: List[String]): Fields[T] = new Fields[T] { | |
override def fields: List[String] = fs |
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 cats.effect._ | |
import scala.concurrent.{ExecutionContext, Future} | |
class FutureConcurrentEffect()(implicit ec: ExecutionContext) extends FutureEffect with ConcurrentEffect[Future] { | |
def start[A](fa: Future[A]): Future[Fiber[Future, A]] = Future.successful { | |
FutureFiber(fa) | |
} | |
def racePair[A, B](fa: Future[A], fb: Future[B]): Future[Either[(A, Fiber[Future, B]), (Fiber[Future, A], B)]] = ??? |
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 shiplis | |
import shapeless._, poly._, ops.hlist._ | |
object MapWith | |
{ | |
object Apply | |
extends Poly2 | |
{ | |
implicit def c[A, B, R, Tail <: HList, F <: Poly2] |
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 com.google.appsscript.adwords._ | |
import com.google.appsscript.base.Logger | |
import com.google.appsscript.spreadsheet._ | |
/** | |
* This is an example app for Apps Scaripped using Google Spreadsheet | |
*/ | |
object AppsScarippedMain extends js.JSApp{ | |
def main(): Unit = { | |
val adsIterator = AdWordsApp.ads() |
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 MySwingDomain._ | |
object Gui extends ReactiveSwingApp { | |
val button = new MyButton("test") | |
def top = new MainFrame { | |
contents = new FlowPanel { | |
contents += button | |
} | |
} |
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 MySwingDomain._ | |
object Gui extends ReactiveSwingApp { | |
val button = new MyButton("test") | |
def top = new MainFrame { | |
contents = new FlowPanel { | |
contents += button | |
} | |
} |