Skip to content

Instantly share code, notes, and snippets.

View preslavrachev's full-sized avatar

Preslav Rachev preslavrachev

View GitHub Profile
@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');
@preslavrachev
preslavrachev / RmiClient.java
Created March 5, 2015 07:51
The following classes implement a simple client-server program using RMI that displays a message. Before running this example, we need to make a 'stub' file for the interface we used. For this task we have the RMI compiler - 'rmic' Note: we make a stub file from the '*.class' file with the implementation of the remote interface, not from the '*.…
import java.rmi.Naming;
public class RmiClient {
public static void main(String args[]) throws Exception {
RmiServerIntf obj = (RmiServerIntf)Naming.lookup("//localhost/RmiServer");
System.out.println(obj.getMessage());
}
}
@preslavrachev
preslavrachev / index.html
Last active August 29, 2015 14:16
This gist provides a simple and clean way to override the the default initialization of all Angular JS controllers, by using a decorator
<body data-ng-app="myApp">
<div ng-controller="myController">{{data}}</div>
</body>
cd /path/to/repo
#displays the raw lengths
git shortlog | grep -e '^ ' | sed 's/[[:space:]]\+\(.*\)$/\1/' | awk '{print length($0)}'
#or a text-based historgam
git shortlog | grep -e '^ ' | sed 's/[[:space:]]\+\(.*\)$/\1/' | awk '{lens[length($0)]++;} END {for (len in lens) print len, lens[len] }' | sort -n
@preslavrachev
preslavrachev / app.js
Last active July 11, 2017 15:48
Integrating browserify into an Ionic project
var customModule = require('./custom-module');
var app = angular.module('myApp', ['ionic']);
...
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.core.CoreContainer;
#!/usr/bin/env python
"""
Decrypting proxy for Snapchat
Based on mitmproxy + pysnap
https://github.com/mitmproxy/mitmproxy
https://github.com/martinp/pysnap
"""

Sexy transition between Activities (based on Twitter transition)

Looking at the officiel Twitter Android client I've noticed the slight cool & sexy transition between activities. I was curious to know how that worked so I had fun with android xml animations and ended up with that:

push_left_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
package com.aaplab.android.robird.utils;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@preslavrachev
preslavrachev / AppManifest.xml
Created September 4, 2013 15:03
Create a custom application class by subclassing the default Application class. According to the Android documentation, this is not a preferred way, as the Android guys consider a singleton with an access to an app-level Context a more modular approach. Nevertheless, it is worth knowing how to do it.
<application
android:name="com.you.yourapp.CustomApplication"