Skip to content

Instantly share code, notes, and snippets.

View jackfranklin's full-sized avatar

Jack Franklin jackfranklin

View GitHub Profile
var foo = function() {
return 2;
}
var x = foo;
var y = foo();
// now x is a reference to the foo function
// whereas with y we called (or "invoked") foo, meaning y is set to foo's return value, 2.

Often I jump from Vim -> Command Line by backgrounding Vim with Ctrl-Z, doing my CLI stuff, and then going back to Vim with vi (which is just aliased to vim).

Sometimes though, I'll forget about my backgrounded Vim, and end up having another Vim process running.

How can I make my vi alias work such that:

  • if there is a Vim process backgrounded, just foreground into that
  • if there is not, load up vim as normal.

Thanks in advance!

@jackfranklin
jackfranklin / gist:8029454
Last active December 31, 2015 18:49
ES5 Getters and Setters
var person = {};
Object.defineProperty(person, 'firstName', {
get: function() { return firstName; },
set: function(newName) { firstName = newName; },
enumerable: true
});
Object.defineProperty(person, 'lastName', {
get: function() { return lastName; },
gulp.task("concat", function() {
var stream = gulp.src("./src/*.js")
.pipe(concat("concat.js"))
.pipe(gulp.dest("./tmp/"));
return stream;
});
gulp.task("uglify", ["concat"], function() {
gulp.src("./tmp/concat.js")
.pipe(uglify())
I'd like to write a small shell script that takes the output of the `jobs` command, which looks like so:
[1] - suspended vim
[2] + suspended less foo.txt
And have it return a string like:
(1:vim 2:less foo.txt)
So I can add that to my PROMPT.
// I have this code for downloading a URL to a file
var stream = request(url).pipe(fs.createWriteStream(fileDestination))
// I can bind to "close" for when the file is completely downloaded, which works fine
stream.on("close", function() {...});
// is there an event I can bind to that will be fired whenever data is receieved (so not that the file is 100% done, but that a bit more of the file has been downloaded?
stream.on("???", function() {...});
foos_with_bar_name = Foo.all.select { |foo|
foo.bar.name == "thing"
}
# I've got a hash of things, that all contain an object with in them that has a score property.
# how to pull out the one with the highest score?
things = {
:foo => {
:score => 50
# other props
},
:bar => {
:score => 30
var Player = function(name) {
this.name = name;
this.hand = [];
this.handTotal = 0;
}
Player.prototype.calculateHandTotal = function() {
this.handTotal = 0;
for (var i = 0; i < this.hand.length; i++) {
this.handTotal += (this.hand[i].value > 10) ? 10 : this.hand[i].value;
@jackfranklin
jackfranklin / gist:5695029
Created June 2, 2013 21:23
sync clipboard from terminal vim to OS
if system("uname") == "Darwin\n"
set clipboard=unnamed
endif