Skip to content

Instantly share code, notes, and snippets.

View preslavrachev's full-sized avatar

Preslav Rachev preslavrachev

View GitHub Profile
@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 / 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) {
/**
* 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:
*
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>PhoneGap Events Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.0.9.5.js"></script>
<script type="text/javascript" charset="utf-8" src="tts.js"></script>
<script type="text/javascript" charset="utf-8">
@preslavrachev
preslavrachev / app.js
Last active August 29, 2015 14:18 — forked from raddeus/app.js
Basic Express 4.0 Setup with connect-flash
var express = require('express');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var flash = require('connect-flash');
var app = express();
app.use(cookieParser('secret'));
app.use(session({cookie: { maxAge: 60000 }}));
app.use(flash());
@preslavrachev
preslavrachev / Permissions.java
Created April 10, 2015 07:15
Obtain a list of installed applications' permissions fromwithin an Android app: From http://stackoverflow.com/questions/7937794/how-to-get-installed-applications-permissions
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo applicationInfo : packages) {
Log.d("test", "App: " + applicationInfo.name + " Package: " + applicationInfo.packageName);
try {
PackageInfo packageInfo = pm.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS);
//Get Permissions
@preslavrachev
preslavrachev / app.js
Created March 22, 2015 07:14
Setting up a different binding delimiter in AngularJS. From http://stackoverflow.com/questions/12923521/angular-js-custom-delimiter
var myApp = angular.module('myApp', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
@preslavrachev
preslavrachev / gulpfile.js
Created March 18, 2015 07:39
How to make nodemon and browserSync work together in a Gulp setup. From http://denbuzze.com/post/5-lessons-learned-using-gulpjs/
gulp.task('nodemon', function(cb) {
var nodemon = require('gulp-nodemon');
// We use this `called` variable to make sure the callback is only executed once
var called = false;
return nodemon({
script: 'server.js',
watch: ['server.js', 'server/**/*.*']
})
.on('start', function onStart() {
@preslavrachev
preslavrachev / index.js
Created March 12, 2015 07:49
Keystone.js: Sending a template-based email using Mandrill from: https://gitter.im/keystonejs/keystone/archives/2015/01/15
//1. Set up your Mandrill credentials
keystone.init({
// ...
'mandrill api key': 'YOUR_API_KEY_HERE',
// ...
'emails': 'templates/emails',
});
//or alternatively, you can set the key later
keystone.set('mandrill api key', 'YOUR_API_KEY_HERE');