Skip to content

Instantly share code, notes, and snippets.

View AmirOfir's full-sized avatar

Amir Ofir AmirOfir

  • Israel
View GitHub Profile
@AmirOfir
AmirOfir / MobileNetV1.cpp
Created May 16, 2021 10:15
An implementation of MobileNet v1 with libtorch c++
#pragma once
#include <torch/torch.h>
// Special thanks for wangvaton: https://github.com/wangvation/torch-mobilenet/blob/master/module/mobilenet.py
//# BSD 2 - Clause License
//
//# Copyright(c) 2019 wangvation.All rights reserved.
//
//# Redistribution and use in source and binary forms, with or without
//# modification, are permitted provided that the following conditions are met :
from collections import OrderedDict
class LRUCache:
# initialising capacity
def __init__(self, capacity: int):
self.cache = OrderedDict()
self.capacity = capacity
# we return the value of the key
# Python3 Program to print BFS traversal
# from a given source vertex. BFS(int s)
# traverses vertices reachable from s.
from collections import defaultdict
# This class represents a directed graph
# using adjacency list representation
class Graph:
# Constructor
@AmirOfir
AmirOfir / imdb-5000-movies.ipynb
Created August 18, 2020 17:35
IMDB 5000 movies
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AmirOfir
AmirOfir / deep-learning-exe2.ipynb
Created December 23, 2019 20:44
Deep learning exe2.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AmirOfir
AmirOfir / XrmXmlConditionOperators.cs
Last active July 31, 2018 08:46
Microsoft XRM Filter ConditionOperator to XML operators
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.Xrm.Sdk.Query;
public static class XmlConditionOperator
{
// Credit for BCA https://stackoverflow.com/a/41618045/1238848
public static Dictionary<string, string> GetAllPublicConstantValues(this Type type)
@AmirOfir
AmirOfir / GroupExtensions.cs
Created July 30, 2018 08:17
Group IEnumerable<T> by key, and get the first item from each group using a predicate
public static IEnumerable<T> FirstGroupItems<T, TKey>(this IEnumerable<T> list, Func<T, TKey> keySelector, Func<IGrouping<TKey, T>, T> firstPredicate = null) where T : class
{
return list.GroupBy(keySelector).Select(a => firstPredicate == null ? a.First() : firstPredicate(a) ?? a.First());
}
@AmirOfir
AmirOfir / ConditionalSelect.cs
Created July 29, 2018 10:36
ConditionalSelect c# apply Enumerable Select method on values, conditional on a predicate
public static IEnumerable<TResult> ConditionalSelect<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, Func<TSource, TResult> truthySelector, Func<TSource, TResult> falsySelector)
{
return source.Select(a => predicate(a) ? truthySelector(a) : falsySelector(a));
}
@AmirOfir
AmirOfir / OptionalDateRange.cs
Created July 29, 2018 07:15
DateRange with nullable optional parameters - c#
public DateTime? From { get; set; }
public DateTime? To { get; set; }
readonly DateTime minFrom = new DateTime(2000, 1, 1);
readonly DateTime maxTo = new DateTime(2100, 1, 1);
public DateTime SafeFrom() =>
From.GetValueOrDefault(To.GetValueOrDefault(minFrom));
public DateTime SafeTo() =>
To.GetValueOrDefault(From.GetValueOrDefault(maxTo));
{
"categories": [{
"name": "action",
"key": "action",
"icons": [{
"id": "ic_3d_rotation",
"name": "3d rotation",
"group_id": "action",
"keywords": ["action, 3d, rotation"],
"ligature": "3d_rotation",