Skip to content

Instantly share code, notes, and snippets.

View preslavrachev's full-sized avatar

Preslav Rachev preslavrachev

View GitHub Profile
/**
* This gulpfile will copy static libraries and a index.html file as well as
* merge, babelify and uglify the rest of the javascript project.
*
* TODO:
* - Separate media, libs and src with different watchers.
* - Media and libs should only be copied to dist if they are different sizes.
*
* The expected project is to be laid out as such:
*
@preslavrachev
preslavrachev / SpringApplication.java
Created July 23, 2015 07:44
Spring Boot has a funky (and interesting) way of finding out the main application class. Basically, the method throws a runtime exception, which it swallows. The exception provides a list of stack trace elements, which the method loops through to find the one point on the stack, whose method name equals to "main".
private Class<?> deduceMainApplicationClass() {
try {
StackTraceElement[] stackTrace = new RuntimeException().getStackTrace();
for (StackTraceElement stackTraceElement : stackTrace) {
if ("main".equals(stackTraceElement.getMethodName())) {
return Class.forName(stackTraceElement.getClassName());
}
}
}
catch (ClassNotFoundException ex) {
@preslavrachev
preslavrachev / The Technical Interview Cheat Sheet.md
Last active August 25, 2015 19:35 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@preslavrachev
preslavrachev / setting-up-a-new-mac-for-development.md
Last active September 8, 2017 16:11
Some important steps and tools for setting up a new Mac and making it ready for development (in particular, Java development, but most of the steps matter for others too)

Setting Up a New Mac for Development

Command-Line Utilities

Homebrew

An absolute must. If you have ever worked with apt-get on Ubuntu, you know that it's the absolute developer bliss. Homebrew (or brew for short) is the missing package manager for OSX. Not only does it allow you to install/unisnstall/manage software with a few simple commands, the same way that apt-get does. It allows you to access and install ports of most of the cross-platform utilities that you might be familiar with from Linux, over to OSX.

Installing Brew

Simply open a new terminal and execute the following command:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@preslavrachev
preslavrachev / hamcrest-cheatsheet.md
Last active February 5, 2016 12:08
Hamcrest Cheatsheet

Hamcrest Cheatsheet

Collection Matchers

Check if a collection contains a single item

assertThat(collection, hasItem("item1"));
assertThat(collection, not(hasItem("item2")));
@preslavrachev
preslavrachev / DateUtil.java
Last active December 9, 2016 10:27
A simple utility class for converting Date to Java 8's LocalDate and vice versa. Via: http://stackoverflow.com/questions/22929237/convert-java-time-localdate-into-java-util-date-type
public class DateUtil {
public static Date asDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
public static Date asDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
@preslavrachev
preslavrachev / kotlin-gradle-executable-jars.md
Created December 10, 2016 07:29
Kotlin Basics: Create Executable Kotlin JARs, using Gradle

Kotlin Basics: Create Executable Kotlin JARs, using Gradle

Kotlin is great for creating small command-line utilities, which can be packaged and distributed as normal JAR files. This short tutorial will show you how to:

  • Set up a Gradle project that supports Kotlin
  • Add a starting function
  • Configure your build to call this function when you execute your JAR.

Setting up Kotlin dependencies

// src/index.ts
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
ViewStyle,
TextStyle
} from 'react-native';

Daily Idea: Use CNNs to Categorize Apps, Based on Their App Store Screenshots

The idea is rather simple and feasible, but as of this moment, not really useful. It just popped up in my mind, and I decided to write it down in case someone is looking for a ML challenge to work on. The idea is very simple:

  1. Use the iTunes Search API to download app screenshots and categorize them by folders, corresponding to the names of categories that those apps have been featured in.
  2. Teach a simple convolutional neural network (CNN) to categorize apps based on screenshots provided
  3. Try and evaluate the NNs capabilities using screenshots that are not present in the model.
@preslavrachev
preslavrachev / Readme.MD
Last active January 2, 2021 07:30
A Simple Grayscale Filter in Golang

This is a simple grayscale filter implementening image.Image. It can be used in place where an image.Image is expected.

img, err := loadImage("input.jpg")
// check error

err := saveImage(&GrayscaleFilter{img})
//check error