Skip to content

Instantly share code, notes, and snippets.

View tundal45's full-sized avatar
👻
there is more to life than coding

Ashish Dixit tundal45

👻
there is more to life than coding
View GitHub Profile
(function() {
// Underscore methods that we want to implement on Array.
var methods = [
'all',
'any',
'compact',
'contains',
'countBy',
'detect',
'difference',
@jhirn
jhirn / BmodelGenerator.rb
Last active December 18, 2015 16:29
Generator for making a backbone model. Original author @daytonn
class BmodelGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
argument :url, type: :string, default: 'url-goes-here'
def generate_view
template "model.js.erb", File.join('app', 'assets', 'javascripts', 'models', "#{file_name}.js")
%x{echo //= require models/#{file_name} | pbcopy}
%x{#{ENV['EDITOR']} #{File.join('app', 'assets', 'javascripts', 'application.js')}}
end
@willurd
willurd / web-servers.md
Last active April 28, 2024 21:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@JEG2
JEG2 / struct.md
Created June 3, 2013 21:50
Thinking out loud about the merits and drawbacks of two different usages of Struct…

How Should We Use Struct?

The Choice

It's common in Ruby to see some code setup a Struct like this:

class Specialized < Struct.new(:whatever)
  # ... define custom methods here...
end

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@chrishunt
chrishunt / .gitconfig.sh
Last active December 17, 2015 02:28
Delete merged branches with `git bam`
[alias]
bam = "!source ~/.githelpers && delete_local_merged_branches"
bamr = "!source ~/.githelpers && delete_remote_merged_branches"
@steveklabnik
steveklabnik / test.txt
Created April 25, 2013 19:55
Lots of gems throw warnings!
$ rake test
/opt/rubies/2.0.0-p0/bin/ruby -I"lib:test" -w -I"/Users/steve/.gem/ruby/2.0.0/gems/rake-10.0.4/lib" "/Users/steve/.gem/ruby/2.0.0/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "test/map_stream_test.rb" "test/map_test.rb" "test/merge_test.rb" "test/mvp_test.rb" "test/on_value_test.rb" "test/select_test.rb"
/Users/steve/.gem/ruby/2.0.0/gems/simplecov-html-0.7.1/lib/simplecov-html.rb:57: warning: assigned but unused variable - title_id
/Users/steve/.gem/ruby/2.0.0/gems/coveralls-0.6.7/lib/coveralls.rb:66: warning: `&' interpreted as argument prefix
/Users/steve/.gem/ruby/2.0.0/gems/coveralls-0.6.7/lib/coveralls.rb:72: warning: `&' interpreted as argument prefix
/Users/steve/.gem/ruby/2.0.0/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:157: warning: assigned but unused variable - message
/Users/steve/.gem/ruby/2.0.0/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:167: warning: assigned but unused variable - message
/Users/steve/.gem/ruby/2.0.0/gems/rest-client-1.6.7/lib/restclient/response.
# whyspooler.rb
# mostly a translation of _why's OCaml script to Ruby
#
# polls whytheluckystiff.net for new printouts, converts to pdf, saves them into ./SPOOL, and prints them
#
# usage: `ruby whyspooler.rb http://whytheluckystiff.net`
#
# OS X install instructions:
# 1. `gem install open4`
# 2. download MacPCLtoPDF.zip from http://www.columbia.edu/~em36/pcltopdf.html
@robmiller
robmiller / .gitconfig
Last active May 20, 2020 13:45
Want to find out what changes were introduced by a particular merge commit? Hey, so do I! ALL THE TIME. These aliases will do that.
# `git merge-log` shows the commits that were introduced in a given merge
# `git merge-diff` shows the actual changes that were introduced by a given merge
# Both commands accept an optional commitish; if ommitted, the last merge commit is used
merge-span = "!f() { echo $(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f1)$1$(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f2); }; f"
merge-log = "!git log `git merge-span .. $1`"
merge-diff = "!git diff `git merge-span ... $1`"
merge-difftool = "!git difftool `git merge-span ... $1`"
@mislav
mislav / _readme.md
Last active March 28, 2024 00:47
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work: