Skip to content

Instantly share code, notes, and snippets.

Tim Hobbs timhobbs

Block or report user

Report or block timhobbs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@timhobbs
timhobbs / gist:4d2751b1cbe6d9498692465a40cc9c77
Created Mar 13, 2019 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
View gist:4d2751b1cbe6d9498692465a40cc9c77
git fetch --all
git reset --hard origin/master
git pull origin master
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@timhobbs
timhobbs / gist:bb8a304a8d008d74fd29
Last active Nov 30, 2018
C# style String.Format for JS
View gist:bb8a304a8d008d74fd29
/* Examples:
* var test = "test {0} {1}, {2} - {0} {1} {2}".format('a', 'b', 'c');
* var test2 = "the {0} ate the {1}".format("cat", "canary");
*/
String.prototype.format = function () {
var self = this;
var re = /\{\d+\}/g;
var m = self.match(re);
var indexes = [];
@timhobbs
timhobbs / camelCase.js
Created Jun 6, 2018 — forked from johnsmith17th/camelCase.js
To convert string to camel case in javascript.
View camelCase.js
function toCamelCase(string) {
string = string.toLowerCase().replace(/(?:(^.)|([-_\s]+.))/g, function(match) {
return match.charAt(match.length-1).toUpperCase();
});
return string.charAt(0).toLowerCase() + string.substring(1);
}
View Boxstarter-script.txt
cinst fiddler4
cinst console-devel
cinst sublimetext2
cinst googlechrome
cinst windirstat
cinst sysinternals
cinst 7zip
cinst winmerge
cinst firefox
cinst nodejs
View FormHelpers.cs
namespace MySweetApp
{
using System;
using System.Linq.Expressions;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
public static class FormHelpers
@timhobbs
timhobbs / ConvertCsvToList.cs
Created May 24, 2013
Converts CSV file contents (as IList<string>) to a typed IList<T>
View ConvertCsvToList.cs
private IList<T> ConvertCsvToList<T>(IList<string> csv, string[] header) {
var list = new List<T>();
foreach (var row in csv) {
var columns = row.Split(',');
T obj = (T)Activator.CreateInstance(typeof(T));
for (int i = 0; i < columns.Length; i++) {
var h = Regex.Match(header[i].Replace("@", "_"), @"(?<="")(?:\\.|[^""\\])*(?="")").Value;
var c = Regex.Match(columns[i], @"(?<="")(?:\\.|[^""\\])*(?="")").Value;
var prop = typeof(Em.Schools.Data.Domain.Match).GetProperty(h);
View DynamicSqlQuery.cs
/// <summary>
/// Reads database schema from query, generates assembly in the memory, and returns dynamic object
/// </summary>
public static System.Collections.IEnumerable DynamicSqlQuery(this Database database, string sql, params object[] parameters)
{
TypeBuilder builder = DynamicMapper.createTypeBuilder(
"MyDynamicAssembly", "MyDynamicModule", "MyDynamicType");
using (System.Data.IDbCommand command = database.Connection.CreateCommand())
{
@timhobbs
timhobbs / Trolliminator! Bookmarklet.js
Last active Dec 15, 2015
Trolliminator! eliminates troll posts from Gigya comments. Simply add a comma-separated list of troll usernames to the trolls variable at the top, then save this js snippet as a bookmark. Whenever you want to trolliminate posts, just click the bookmark! All troll posts will be marked with a "Trolliminated!" string and a total count will be displ…
View Trolliminator! Bookmarklet.js
javascript: (function () {
var trolls = [
'troll', // <-- add troll names here
];
var el = document.createElement('div'),
b = document.getElementsByTagName('body')[0];
otherlib = false, msg = '';
el.style.position = 'fixed';
el.style.height = '32px';
@timhobbs
timhobbs / toggle-data.js
Created Nov 21, 2012
Select data- attribute on an input
View toggle-data.js
var d = $("input[data-toggle-class]");
$.each(d, function (idx, data) {
console.log(idx, data);
});
You can’t perform that action at this time.