Skip to content

Instantly share code, notes, and snippets.

View keith9820's full-sized avatar

Keith Harris keith9820

  • automotiveMastermind
  • San Francisco, CA
View GitHub Profile
@keith9820
keith9820 / RepoCache.cs
Last active December 24, 2015 05:49
C# caching object
using System;
using System.Runtime.Caching;
namespace Application.Caching
{
public static class RepoCache
{
static ObjectCache cache = MemoryCache.Default;
public static bool UseCache
@keith9820
keith9820 / bookmark.js
Created October 1, 2013 20:55
This bookmarklet code adds a Facebook app to a page.
javascript:function p(d){return d.selection?d.selection.createRange().text:d.getSelection();} s=p(document); for(i=0;i<frames.length&&!s;i++)s=p(frames[i].document);if(!s||s=='')s=prompt('Enter Facebook AppId:','');if(s){open('https://www.facebook.com/dialog/pagetab?display=popup&next=http://www.facebook.com&app_id='+encodeURIComponent(s));}
@keith9820
keith9820 / link mac libraries.txt
Last active July 29, 2016 19:03
To link SVN & libraries on Mavericks
@keith9820
keith9820 / gist:8867955
Last active August 29, 2015 13:56
Trace git command
GIT_TRACE=1 git status
GIT_CURL_VERBOSE=1 git pull origin master
@keith9820
keith9820 / gist:93de292999c0ee47b9a2
Last active August 29, 2015 14:04
Get the larget tag number from a git repo
git ls-remote --tags origin | tail -n1 | cut -d "/" -f3
@keith9820
keith9820 / RandomPassword.sql
Last active July 13, 2016 21:19
Generate a random password in T-SQL
declare @idx as int
declare @randomPwd as nvarchar(64)
declare @rnd as float
select @idx = 0
select @randomPwd = N''
select @rnd = rand((@@CPU_BUSY % 100) + ((@@IDLE % 100) * 100) +
(DATEPART(ss, GETDATE()) * 10000) + ((cast(DATEPART(ms, GETDATE()) as int) % 100) * 1000000))
while @idx < 64
begin
select @randomPwd = @randomPwd + char((cast((@rnd * 83) as int) + 43))
@keith9820
keith9820 / .gitignore.curl
Last active August 16, 2016 21:00
Fetch .gitignore file
curl curl -L https://gist.githubusercontent.com/keith9820/969e98649155c07b083ace6cd004c729/raw/996e638a881a4be4c79c0e1920797a44f71f572c/.gitignore > .gitignore
-or-
Invoke-RestMethod -Uri https://gist.githubusercontent.com/keith9820/969e98649155c07b083ace6cd004c729/raw/996e638a881a4be4c79c0e1920797a44f71f572c/.gitignore | Out-File -Encoding ascii .gitignore
@keith9820
keith9820 / GitColors.url
Last active July 13, 2016 21:18
Link to configuring git colors
http://nathanhoad.net/how-to-colours-in-git
@keith9820
keith9820 / Eval.cs
Created July 13, 2016 21:16
C# Eval method
private static object Eval(string __code)
{
var csc = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } });
var p = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll" }, null, true);
p.GenerateInMemory = true;
p.GenerateExecutable = false;
CompilerResults r = csc.CompileAssemblyFromSource(p, "using System; class p {public static object c(){"+__code+"}}");
if (r.Errors.Count > 0)
{
r.Errors.Cast<CompilerError>().ToList().ForEach(error => Console.WriteLine(error.ErrorText));
@keith9820
keith9820 / CachingGitPassword.md
Created July 13, 2016 21:20
How to cache your git password

https://help.github.com/articles/caching-your-github-password-in-git/#platform-all

WINDOWS

If you're cloning repositories using HTTPS, you can use a credential helper to tell Git to remember your username and password every time it talks to the server.

If you clone repositories using SSH, then you authenticate using SSH keys instead of a username and password. For help setting up an SSH connection, see Generating SSH Keys.

Tip: You need Git 1.7.10 or newer to use the credential helper.