Skip to content

Instantly share code, notes, and snippets.

View vlastachu's full-sized avatar

Vlad Chuprin vlastachu

View GitHub Profile
//...
// 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)
}
/*
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
# -*- 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
@vlastachu
vlastachu / type_operators.swift
Created September 22, 2016 11:26
can't do anything with this
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
}
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? {
class AnkoViewHolder<out V : AnkoComponent<ViewGroup>>(val parent: ViewGroup, val createUI: () -> V) {
class ViewHolder<out V : AnkoComponent<ViewGroup>>(val view: View, val ui: V) : RecyclerView.ViewHolder(view)
val ankoContext by lazy { AnkoContext.createReusable(parent.context, parent) }
val viewHolder by lazy {
val ui = createUI()
val view = ui.createView(ankoContext)
view.setupTapEffectForBG(true) // default for every item in application
// TODO some items may be disabled...
ViewHolder(view, ui)
var _ = new Proxy({}, {get: (object, prop) => x => Reflect.get(x, prop)})
// Now you can use `_.method` instead of `x => x.method`
var a = {someMethod: x => x + 1}
_.someMethod(a)(1) // => 2
a.prototype.prototypeMethod = (a, b) => a + b
_.prototypeMethod(a)(1, 2) // => 3
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, Button } from 'react-native';
require 'digest'
require 'openssl'
require 'base64'
require 'net/http'
require 'json'
require 'time'
VWS_ENDPOINT = 'vws.vuforia.com'
TARGETS_PATH = '/targets'
import 'dart:math';
import 'package:cli/cli.dart' as cli;
abstract class AbstactBinarySearch {
final List<int> nums;
final int target;
int start = 0;
int end;