Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / remote_pop.sh
Created May 30, 2019
pop last commit from remote
View remote_pop.sh
# pop one commit from remote master
# '+' pushes with force
git push origin +HEAD^:master
@marcusshepp
marcusshepp / ref.cs
Created May 8, 2019
Passing a var by reference in C#
View ref.cs
using System;
public class Program
{
public static void Main()
{
bool foo = false;
Console.WriteLine("foo 1: ");
Console.WriteLine(foo);
changeFoo(ref foo);
View windowspowershell.md

powershell

create a new file with new-item

new-item -name 'foobar.txt' -itemtype file -path . -value 'foobarpop'

create a new directory with new-item

new-item -name 'foobar' -itemtype directory -path .

moving items with move-item

@marcusshepp
marcusshepp / mqu.css
Created Mar 15, 2019
media query for height and between two widths
View mqu.css
@mixin mobile-only--height {
@media (max-height: 635px) and (min-width: 642px) and (max-width: 1440px) { @content; }
}
@marcusshepp
marcusshepp / js_notes.js
Last active Dec 17, 2017
Javascript Arrays
View js_notes.js
// 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 Dec 7, 2017
staging deleted files by listing them then sending the list into git rm
View git_add_rm_files.sh
git rm $(git ls-file --deleted);
@marcusshepp
marcusshepp / vim.md
Last active Dec 6, 2017
My Vim Cheat Sheet
View vim.md

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): >/</5<
View grep.sh
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 Nov 9, 2017
changing the permissions level of a folder
View chown.sh
sudo chown -R $USER ~/projects/kaa-api/log
View rails_queries.rb
# 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
You can’t perform that action at this time.