Skip to content

Instantly share code, notes, and snippets.

View preslavrachev's full-sized avatar

Preslav Rachev preslavrachev

View GitHub Profile
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 / 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>
@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.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 / 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 / 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 / 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
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());
<!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">