Skip to content

Instantly share code, notes, and snippets.

Vlad Chuprin vlastachu

Block or report user

Report or block vlastachu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View App.js
/**
* 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';
View method-to-function.js
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
View AnkoAdapter.kt
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)
View optional_arguments_application.swift
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? {
@vlastachu
vlastachu / type_operators.swift
Created Sep 22, 2016
can't do anything with this
View type_operators.swift
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
}
View mda_counter.py
# -*- 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
View astar_readmodel.cpp
/*
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
View disable_set_rect.swift
//...
// 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)
}
@vlastachu
vlastachu / zipWithIterNum.hs
Created Mar 8, 2016
version of zipWith with number of iteration
View zipWithIterNum.hs
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 )
View channels.hs
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
You can’t perform that action at this time.