Skip to content

Instantly share code, notes, and snippets.

View michaelminter's full-sized avatar

Michael Minter michaelminter

View GitHub Profile
@michaelminter
michaelminter / mac_terminal_keys
Last active August 29, 2015 13:59
Mac terminal shortcut keys #console
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
@michaelminter
michaelminter / linux_memory.md
Created April 25, 2014 18:43
Free Memory on Linux

Very often I used to find that my Linux box(s), Fedora & Ubuntu both started reserving more RAM over a period of time since its boot. And the actual RAM left free was less.

I knew it was holding some caches for itself so that it could find the programs loading “quickly” and something like that.

The most common way to free up RAM is Rebooting! But I wanted to avoid it, so did a little “Googling” and I came up with an interesting solution – Tell linux to flush all the caches.

# Flush file system buffers by executing
sync;

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

def parse_diff(changes)
# [["~", "name", "original name", "updated name"]] => {:name => ['original_name', 'updated_name', 'Modify']}
parsed_diff = {}
changes.each do |change|
unless change[1].match(/updated_at/) || change[1].match(/.id/) || change[1].match(/.created_at/)
if change[1].match(/line_items/) || change[1].match(/site_lists/) || change[1].match(/zip_code_lists/)
change[1].gsub!(/\d+/, Random.rand(1000).to_s)
end
type = if change[0] == "+"
"Add"
@michaelminter
michaelminter / insist.rb
Created May 29, 2014 17:27
Ruby method for looping number of attempts
def insist(max_attempts: 3, &block)
attempts = 0
begin
yield
rescue SomeException => e
attempts += 1
retry if attempts < max_attempts
end
end
@michaelminter
michaelminter / string_reggy.rb
Created May 30, 2014 16:56
String extraction with RegEx -- replaces match
str = "GB is not Great Britain"
matches = str.match /(Great.*)/
matches[1]
# => "Great Britain"
str[/(Great.*)/, 1]
# => "Great Britain"
@michaelminter
michaelminter / gist:1d125fba09a7c37b2414
Created September 24, 2014 18:12
Terminal command that emulates The Matrix encoded output
echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|awk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
@michaelminter
michaelminter / Responsive-Mail-UI.markdown
Created October 3, 2014 04:23
A Pen by Captain Anonymous.

Responsive Mail UI

Credit for design goes to Vivek Venkatraman: http://dribbble.com/shots/1455744-Email-Concept/

Check it out in full view to see it's responsiveness. It's responsive until pretty darn small but i haven't actually tested it on mobile devices. Tested in IE9+, latest Chrome and Firefox.

I've noticed the message (slide-in section) is some times visible on page load. If that's the case just reload the page, that's a browser bug.

Forked from Nicklas Sandell's Pen Responsive Mail UI.

@michaelminter
michaelminter / Binary-Clock.markdown
Created October 3, 2014 04:24
A Pen by Paulo Viana.
@michaelminter
michaelminter / index.html
Created October 3, 2014 04:24
A Pen by Eric.
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/dat-gui/0.5/dat.gui.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/stats.js/r11/Stats.min.js"></script>
<div id="Stats-output">
</div>