Skip to content

Instantly share code, notes, and snippets.

View vojtajina's full-sized avatar

Vojta Jina vojtajina

View GitHub Profile
@vojtajina
vojtajina / fetch-git-pr.bash
Created May 8, 2013 04:19
Bash script for fetching a pull request from github...
# fetching a single pull request from github
# put it into ~/.profile or ~/.bashrc
function fetch_pr() {
PR=$1
BRANCH=$2
if [ -z $PR ]; then
echo "Missing pull request number"
return 1
fi
@vojtajina
vojtajina / bench.js
Created October 19, 2012 05:18
async.forEach vs. sync forEach (very lame)
var async = require('async');
var fs = require('fs');
var files = [];
while(files.length < 100000) {
files.push('/some/file' + files.length);
}
@vojtajina
vojtajina / Preferences.sublime-settings.json
Created September 14, 2012 05:55
Sublime Text - preferences
{
"auto_complete_commit_on_tab": true,
"close_windows_when_empty": true,
"color_scheme": "Packages/User/Monokai Vojta.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 12.0,
"highlight_line": true,
"hot_exit": false,
"ignored_packages":
[
@vojtajina
vojtajina / sublime.sh
Created September 14, 2012 04:34
Shell script to start Sublime Text
#!/bin/sh
# Shell script to start Sublime
# @author Vojta Jina <vojta.jina@gmail.com>
if [ -z $@ ]; then
# no arguments, try to find project
# TODO(vojta): traverse up to find projects in parent directories
PROJECT=`ls *.sublime-project 2>/dev/null`
@vojtajina
vojtajina / all-templates.html
Created August 15, 2012 00:00
AngularJS: load all templates in one file
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>
@vojtajina
vojtajina / grunt.js
Created August 14, 2012 08:17
Grunt script for inlining AngularJS templates
module.exports = function(grunt) {
grunt.initConfig({
inline: {
'index.html': ['tpl/*.html']
}
});
grunt.registerMultiTask('inline', 'Inline AngularJS templates into single file.', function() {
var SCRIPT = '<script type="text/ng-template" id="<%= id %>"><%= content %></script>\n';
@vojtajina
vojtajina / get-last-modified-fixed.js
Created August 7, 2012 09:14
Example of predictableNextTick
var fs = require('fs');
var getLastModified = function(files, done) {
var timestamps = new Array(files.length);
var pending = files.length;
files.forEach(function(file, idx) {
fs.stat(file, function(err, stat) {
timestamps[idx] = stat.mtime;
@vojtajina
vojtajina / app.js
Created March 30, 2012 02:44 — forked from ggoodman/app.js
Plunker + AngularJS
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
@vojtajina
vojtajina / e2e-tests.js
Created February 15, 2012 23:41
Angular: Scenario runner explanation
// simple dsl just wrapping angular's dsl, just providing higher abstraction
angular.scenario.dsl('submitMessage', function() {
return function(message) {
// these dsl already register futures (add fn into the queue),
// so you don't wrap them into addFutureAction
input('modelValue').enter(message);
element('button.submit').click();
};
});
@vojtajina
vojtajina / 12.json
Created February 11, 2012 01:57
Angular: 0.9.19 resource example
)]}',
[{
"name": "one"
}, {
"name": "two"
}]