Skip to content

Instantly share code, notes, and snippets.

Avatar

Nate Murray jashmenn

View GitHub Profile
View git-selective-merge.md

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

On master:

> git co -b temp
@jashmenn
jashmenn / pr.md
Created Mar 9, 2017 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

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:

@jashmenn
jashmenn / github-operator-mono-dark.css
Last active Mar 9, 2018
Stylish Chrome Extension for Github Operator Mono Dark Theme
View github-operator-mono-dark.css
.markdown-body .highlight pre,
table.highlight,
.blob-code-inner {
font-family: "Operator Mono";
font-weight: 400;
line-height: 1.5em;
font-size: 14px;
}
.markdown-body .highlight pre,
table.highlight {
@jashmenn
jashmenn / ng-book-rc.4.diff
Created Jul 1, 2016
ng-book 2 code diff between rc.2 and rc.4 - https://www.ng-book.com/2
View ng-book-rc.4.diff
diff --git a/manuscript/code/advanced_components/app/ts/app.ts b/manuscript/code/advanced_components/app/ts/app.ts
index 6db6693..830beb2 100644
--- a/manuscript/code/advanced_components/app/ts/app.ts
+++ b/manuscript/code/advanced_components/app/ts/app.ts
@@ -13,10 +13,10 @@ import {
import { bootstrap } from '@angular/platform-browser-dynamic';
import {
ROUTER_DIRECTIVES,
- ROUTER_PROVIDERS,
- RouteDefinition,
View update-ng-rc1-paths.sh
#!/bin/bash -x
#
# Angular 2.0.0-rc.1 renamed a bunch of modules. This script can help you do a
# little bit of the dirty work for renaming those modules.
#
# As a bonus, this script will try to fix your template-local variables
# e.g. *ngFor="#thread of threads" becomes -> *ngFor="let thread of threads"
#
# 🦁 by Nate Murray nate@fullstack.io // https://ng-book.com/2
#
@jashmenn
jashmenn / self-eq-this-vs-bind.md
Last active Nov 1, 2020
Javascript var self = this; vs. .bind
View self-eq-this-vs-bind.md

The Problem

In Javascript this is bound in unexpected ways. Functions, in particular, create a new 'this' and so when you want to keep a reference to an "outer" object you sometimes see the pattern:

var self = this;

as in:

var self = this;
@jashmenn
jashmenn / RxPipe.ts
Created Aug 21, 2015
RxJS Support for Angular 2 Async Pipes - (angular-2.0.0.alpha-35 and above)
View RxPipe.ts
/// <reference path="../../typings/app.d.ts" />
//
// Creates a pipe suitable for a RxJS observable:
//
// @View({
// template: '{{ someObservable | rx}}'
// pipes: [RxPipe]
// })
//
// Originally written by @gdi2290 but updated for 2.0.0.alpha-35 and use AsyncPipe
View rename-file-and-buffer.el
;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
View annotation.rb
a = {
"annotations" => [
{
"x" => 19,
"y" => 20,
"w" => 50,
"h" => 50,
"predictions" => {
"green" => 0.2,
View dumb_graph.js
function sum (fn, xs) {
var toRet = 0;
for (var i = 0, ii = xs.length; i < ii; i++) {
toRet += fn(xs[i], i, xs);
}
return toRet;
}
function update(t, o) {
for (var k in o) {
You can’t perform that action at this time.