Skip to content

Instantly share code, notes, and snippets.

@katylava
katylava / git-selective-merge.md
Last active February 27, 2024 10:18
git selective merge

Update 2022: git checkout -p <other-branch> is basically a shortcut for all this.

FYI This was written in 2010, though I guess people still find it useful at least as of 2021. I haven't had to do it ever again, so if it goes out of date I probably won't know.

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.

@dshaw
dshaw / min_jquery_version.js
Created October 29, 2010 03:42
Determine if a page has the minimum jQuery version you need to do what you're doing.
function minVersion(version) {
var $vrs = window.jQuery.fn.jquery.split('.'),
min = version.split('.');
for (var i=0, len=$vrs.length; i<len; i++) {
console.log($vrs[i], min[i]);
if (min[i] && $vrs[i] < min[i]) {
return false;
}
}
return true;
using System;
using System.Collections.Specialized;
using System.ComponentModel;
namespace ThomasJaworski.ComponentModel
{
public abstract class ChangeListener : INotifyPropertyChanged, IDisposable
{
#region *** Members ***
protected string _propertyName;
@garyharan
garyharan / _mixins.scss
Created May 5, 2011 15:46
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@SamBenson
SamBenson / gist:1219630
Created September 15, 2011 15:52
Our .htaccess boilerplate
ExpiresActive On
RewriteEngine on
RewriteBase /
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
@dantuck
dantuck / TransactionManagement.sql
Created September 16, 2011 14:52
TSQL Transaction Management
DECLARE @ERRORCODE INT
BEGIN TRANSACTION
-- do action
-- check for errors after each transaction if desired
SELECT @ERRORCODE = @@ERROR
IF (@ERRORCODE <> 0) GOTO PROBLEM
@Swizec
Swizec / paragraph_counter.js
Created September 16, 2011 14:52
Simple script to see how far users scroll on a website
(function ($) {
$.waypoints.settings.scrollThrottle = 30;
try {
mpmetrics = new MixpanelLib("<api_key>");
} catch(err) {
var null_fn = function () {};
mpmetrics = {
track: null_fn,
track_funnel: null_fn,
@geuis
geuis / json.js
Created November 15, 2011 16:01
Better error handling for JSON.parse (javascript)
(function(){
var parse = JSON.parse;
JSON = {
stringify: JSON.stringify,
validate: function(str){
@border
border / mgoExample.go
Created August 27, 2012 15:33
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@lancew
lancew / gist:4001624
Created November 2, 2012 14:19
xmonad natural scrolling
echo "pointer = 1 2 3 5 4 7 6 8 9 10 11 12" > ~/.Xmodmap && xmodmap ~/.Xmodmap