Skip to content

Instantly share code, notes, and snippets.

View marcusshepp's full-sized avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / remote_pop.sh
Created May 30, 2019 12:10
pop last commit from remote
# pop one commit from remote master
# '+' pushes with force
git push origin +HEAD^:master
@marcusshepp
marcusshepp / ref.cs
Created May 8, 2019 15:22
Passing a var by reference in C#
using System;
public class Program
{
public static void Main()
{
bool foo = false;
Console.WriteLine("foo 1: ");
Console.WriteLine(foo);
changeFoo(ref foo);
@marcusshepp
marcusshepp / mqu.css
Created March 15, 2019 16:27
media query for height and between two widths
@mixin mobile-only--height {
@media (max-height: 635px) and (min-width: 642px) and (max-width: 1440px) { @content; }
}
@marcusshepp
marcusshepp / js_notes.js
Last active December 17, 2017 13:23
Javascript Arrays
// javascript's foreach is cool
let arr = new Array();
for (let i = 0; i < 5; i++){
arr.push(i);
}
arr.foreach(function(item){
console.log(item);
});
@marcusshepp
marcusshepp / git_add_rm_files.sh
Last active December 7, 2017 14:57
staging deleted files by listing them then sending the list into git rm
git rm $(git ls-file --deleted);
@marcusshepp
marcusshepp / vim.md
Last active December 6, 2017 20:57
My Vim Cheat Sheet

Edit

  • replace current file with new file: :e path/to/file
  • undo: u
  • redo: ctrl r
  • increment/decrement number: CTRL A, CTRL X
  • change case: ~
  • change case of full word: viw~
  • join two lines: J
  • fix line indent: ==
  • indent/unindent block (vis m): &gt;/&lt;/5&lt;
@marcusshepp
marcusshepp / grep.sh
Last active November 21, 2017 18:48
grep
grep "4294" -B 3 -A 3
grep -r "foo" .
# -H causes the filename to be printed (implied when multiple files are searched)
# -r does a recursive search
# -n causes the line number to be printed
# -I ignore binary files (complement: -a treat all files as text)
# -F treat search term as a literal, not a regular expression
# -i do a case-insensitive search
@marcusshepp
marcusshepp / chown.sh
Last active November 9, 2017 15:32
changing the permissions level of a folder
sudo chown -R $USER ~/projects/kaa-api/log
@marcusshepp
marcusshepp / rails_queries.rb
Last active September 14, 2017 15:23
Rails Queries
# rails 2.3.5
p = Promotion.find(:first, :conditions => ["subdomain = ?", "foobar"])
# to find based on multiple conditions based on multiple associations
User.find(:all, :include => [:contact, :promotion], :conditions => ['contacts.email = ? and promotions.id = ?', 'marcuss@hesonline.com', 22])
# to find last record in old rails apps, rails 2
p = Promotion.find(:all, :order => "id desc", :limit => 1) # newest first
# and in ascending order
p = Promotion.find(:all, :order => "id asc", :limit => 1) # oldest first
@marcusshepp
marcusshepp / ruby_env.sh
Last active September 8, 2017 13:51
Notes on Ruby Environment
# to install diff Ruby verison
rvm install ruby-1.8.7-head
# to force RVM to use a diff Ruby version by default
rvm --default use 1.8.7
# to create a new rvm enviornment
rvm use 1.8.7@foo --create
# to install the package that will interate over