This file contains 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
infix operator .? : NilCoalescingPrecedence | |
func .?<ARG, RES> (fn: (ARG) -> RES, arg: ARG?) -> RES? { | |
if let arg = arg { | |
return fn(arg) | |
} | |
return nil | |
} | |
func .?<ARG0, ARG1, RES> (fn: (ARG0, ARG1) -> RES, arg: (ARG0?, ARG1?)) -> RES? { |
This file contains 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
enum Either<A,B> { | |
case left(A) | |
case right(B) | |
} | |
func |<A,B>(left: A.Type, right: B.Type) -> Either<A, B>.Type { | |
return Either<A, B>.self | |
} |
This file contains 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
# -*- coding: utf-8 -*- | |
import json | |
from subprocess import * | |
from collections import Counter | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import matplotlib.dates as mdates | |
from scipy.interpolate import splev, splrep, InterpolatedUnivariateSpline | |
import datetime | |
import time |
This file contains 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
/* | |
Copyright 2005-2016 Intel Corporation. All Rights Reserved. | |
This file is part of Threading Building Blocks. Threading Building Blocks is free software; | |
you can redistribute it and/or modify it under the terms of the GNU General Public License | |
version 2 as published by the Free Software Foundation. Threading Building Blocks is | |
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
See the GNU General Public License for more details. You should have received a copy of | |
the GNU General Public License along with Threading Building Blocks; if not, write to the |
This file contains 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
//... | |
// change instance property setter to custom at runtime | |
let type = self.view.superview!.superview!.superview!.dynamicType | |
if String.fromCString(class_getName(type)) != "runtimeUIView" { | |
let newtype = objc_allocateClassPair(type, "runtimeUIView", 0) | |
let imp = class_getMethodImplementation(ViewController.self, #selector(ViewController.fakeFrameSetter(_:))) | |
let types = method_getTypeEncoding(class_getInstanceMethod(ViewController.self, #selector(ViewController.fakeFrameSetter(_:)))) | |
class_addMethod(newtype, Selector("setFrame:"), imp, types) | |
object_setClass(self.view.superview!.superview!.superview!, newtype) | |
} |
This file contains 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
zipWithIterNum :: (Integer -> a -> b -> c) -> [a] -> [b] -> [c] | |
zipWithIterNum fun l r = zipWithIterNum' 0 l r | |
where n = length l | |
zipWithIterNum' _ [] _ = [] | |
zipWithIterNum' _ _ [] = [] | |
zipWithIterNum' i (x:xs) (y:ys) = (fun i x y):(zipWithIterNum' (i + 1) xs ys ) |
This file contains 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
module Main (main) where | |
import Control.Concurrent (forkIO, threadDelay) | |
import Control.Concurrent.Chan (Chan, newChan, writeChan, readChan) | |
import Control.Monad (forM_, replicateM) | |
baseDelay = 2000 | |
writerDelay = 1 * baseDelay | |
readerDelay = 2 * baseDelay | |
This file contains 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
-- such functionality already exist in Control.Lens in '&' operator | |
-- '|>' alreade used in Data.Sequence | |
module Main where | |
(|>) :: a -> (a -> b) -> b | |
(|>) a fun = fun a | |
infixl 1 |> | |
main = print $ [1..10] |> map (*2) |> filter (>5) |> foldr1 (+) | |
-- have idea to improve that function: print $ [1..10] |> map (*2) |> filter (>5) |> foldr1 (+) |
This file contains 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 <Windows.h> | |
#include <WinUser.h> | |
#include <iostream> | |
using namespace std; | |
int main(){ | |
//0..65535,0..65535 | |
int x =30000, y = 3000; | |
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0); | |
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); |
This file contains 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 com.company; | |
import javax.net.ssl.HttpsURLConnection; | |
import java.io.*; | |
import java.net.InetAddress; | |
import java.net.ServerSocket; | |
import java.net.Socket; | |
import java.net.URL; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; |