Skip to content

Instantly share code, notes, and snippets.

@psttf
psttf / post-lattice.scala
Last active January 9, 2018 19:50
Proving boolean function properties via type-level logic in Scala
/***
scalaVersion := "2.12.4"
*/
import scala.language.higherKinds
/**
* Checking boolean function properties via type-level logic in Scala
*/
\ProvidesPackage{questiontask}
\RequirePackage{exsheets}
\newcounter{taskvariant}
% Переопределение \task необходимо для работы \questiontask
%
% ВНИМАНИЕ:
% Обновленная версия \task требует, чтобы весь текст примера был заключен в
$("#account-selector input").attr('checked', false);
@psttf
psttf / FlipFlopWheel.ps
Last active October 24, 2017 11:27
PowerShell one-liner to set reverse scrolling (flip wheel or reverse scrolling)
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }
@psttf
psttf / ConnectRemoteDesktopusingKeePassCredentials
Last active January 11, 2021 08:11 — forked from janikvonrotz/ConnectRemoteDesktopusingKeePassCredentials
Connect Remote Desktop using KeePass Credentials#KeePass#EmbededPost via URL Override
cmd://cmd /c "cmdkey /generic:TERMSRV/{URL:HOST} /user:{USERNAME} /pass:"{PASSWORD}" && mstsc /v:{URL:RMVSCM} && cmdkey /delete:TERMSRV/{URL:RMVSCM}"
import cats.Monad
import scala.concurrent.Future
import scala.language.higherKinds
import scala.concurrent.ExecutionContext.Implicits.global
object Swap {
def apply[F[_], A](l: List[F[A]])(implicit m: Monad[F]): F[List[A]] =
@psttf
psttf / methodUpdate.js
Created May 6, 2016 19:28
Method update in JavaScript
// from repl.it
function myClass() {
this.uniqueTask = function() {
return 2
}
}
var obj = new myClass();
obj.uniqueTask = function() {
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val i = 123 // значение для сравнения
i: Int = 123
scala> def if_i_1(x: Int) = x match { case i => true; case _ => false } // Scala нас предупреждает, что притаком определении сравнение проводиться не будет!
<console>:10: warning: patterns after a variable pattern cannot match (SLS 8.1.1)
def if_i_1(x: Int) = x match { case i => true; case _ => false }
@psttf
psttf / eeeee.sc
Created December 23, 2014 13:49
Projection of one shapeless extensive record to another. Results in a record that contains the same fields in the same order. Possibilities of mapping different case classes (via LabelledGeneric) are also included.
import shapeless._
import shapeless.ops.hlist.Tupler
import syntax.singleton._
import record._
object o {
trait Projection[F <: HList, L <: HList] extends DepFn1[L] { type Out <: HList}
object Projection{
implicit def hnil[L <: HList] = new Projection[HNil, L]{
override type Out = HNil
import shapeless._; import syntax.singleton._; import record._
object os {
trait OptionSelector[L <: HList, K] {
type Out
def apply(l : L): Out
}
trait LowPriorityOptionSelector {