Skip to content

Instantly share code, notes, and snippets.

View zmij's full-sized avatar
🤡
Having fun with FPGAs

Sergei Fedorov zmij

🤡
Having fun with FPGAs
  • Playrix
  • Belgrade, Serbia
View GitHub Profile
@zmij
zmij / GetUIViewControler.cs
Created March 11, 2015 18:33
MonoTouch extension method to obtain a UIViewController from a UIView
public static class NameItAsYouLike {
public static UIViewController GetController(this UIView view)
{
UIResponder parent = view;
while (parent != null) {
parent = parent.NextResponder;
if (parent is UIViewController) {
return parent as UIViewController;
}
}
@zmij
zmij / DateTimeExtensions
Created March 13, 2015 06:46
C# DateTime to UnixTime and back
/**
* DOES NOT take timezones into account, just simple calculations
*/
namespace YourNamespace {
public static class ExtensionsClassName {
static readonly DateTime EPOCH = new DateTime (1970, 1, 1, 0, 0, 0);
public static double UnixTime(this DateTime date)
{
return (date - EPOCH).TotalSeconds;
@zmij
zmij / bigint_to_inet.sql
Created June 16, 2015 08:10
Cast inet to bigint and back
create or replace function bigint_to_inet (intaddr bigint) returns inet
as
$BODY$
begin
return '0.0.0.0'::inet + intaddr;
end
$BODY$
language plpgsql immutable strict;
create cast (bigint as inet) with function bigint_to_inet(bigint);
@zmij
zmij / has_io_operator.hpp
Last active February 1, 2017 08:52
Check for std::iostream input/output operators
template < typename T >
class has_output_operator {
template < typename U >
using helper = decltype( ::std::declval<::std::ostream&>() << ::std::declval<U>(), void() );
template < typename U = T>
static ::std::true_type test(helper<U>*);
static ::std::false_type test(...);
public:
using type = decltype(test(nullptr));
@zmij
zmij / is_callable.hpp
Created February 2, 2016 21:09
Check if object type is callable
namespace detail {
template <typename T>
struct has_call_operator {
private:
struct _fallback { void operator()(); };
struct _derived : T, _fallback {};
template<typename U, U> struct _check;
@zmij
zmij / has_free_function.hpp
Last active February 1, 2017 08:33
Metafunctions for checking for existence of member and free functions
template < typename T >
class has_FUNCTION_NAME_function {
template < typename U = T >
static ::std::true_type test(decltype(FUNCTION_NAME(::std::declval<T>()), void())*);
static ::std::false_type test(...);
public:
using type = decltype(test(nullptr));
static constexpr bool value = type::value;
};
@zmij
zmij / demangle.hpp
Last active June 23, 2016 14:48
Demangle c++ name
#ifndef _UTIL_DEMANGLE_HPP_
#define _UTIL_DEMANGLE_HPP_
#include <cxxabi.h>
#include <string>
namespace util {
/**
* Usage:
@zmij
zmij / iterator_value.hpp
Created November 24, 2018 13:31
Detect output iterator value type
#include <iterator>
template <typename T>
struct output_iterator_value {
using type = void;
};
template <typename Container>
struct output_iterator_value<std::insert_iterator<Container>> {
using type = typename Container::value_type;
@zmij
zmij / Readme.md
Created April 23, 2020 11:08
Join next Zoom Meeting

Swift program for getting a zoom app link from current or upcoming event in calendar.

Apple script calling the program and opening zoom.