Skip to content

Instantly share code, notes, and snippets.

View SeriousM's full-sized avatar
🌟
Focusing

Bernhard Millauer SeriousM

🌟
Focusing
View GitHub Profile
@SeriousM
SeriousM / OnOffModelBinder.cs
Created May 9, 2014 07:40
Custom C# ModelBinder
using System.Web.Mvc;
/// <summary>
/// This model binder converts the value "on" to true.
/// It's necessary for form-checkboxes (bootstrap) that sends "on" instead a boolean value
/// </summary>
public class OnOffModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
@SeriousM
SeriousM / parameterDirections.sql
Created May 12, 2014 11:58
Sql Example of parameter directions in combination with C#
if exists(select * from sys.procedures where name = 'test_proc')
begin
drop procedure test_proc
end
go
create procedure test_proc
@in int,
@out int output,
@inout int output
@SeriousM
SeriousM / dump_restore.md
Last active August 29, 2015 14:03
Dump / Restore Meteor Mongo DB

DUMP

HOST=yournal.meteor.com
CMD=`meteor mongo $HOST --url | tail -1 | sed 's_mongodb://\([a-z0-9\-]*\):\([a-f0-9\-]*\)@\(.*\)/\(.*\)_mongodump -u \1 -p \2 -h \3 -d \4_'`
$CMD -o /path/to/dump

RESTORE

@SeriousM
SeriousM / readme.md
Last active August 29, 2015 14:04
Fixing Meteor/Meteorite Updates

removing meteor (usually not needed!)

# user settings
sudo rm /usr/local/bin/meteor

#meteor installation
rm -rf ~/.meteor

removing meteorite

@SeriousM
SeriousM / readme.md
Created August 6, 2014 11:26
Unix Symbolic Link

To create a symbolic link, the syntax of the command is similar to a copy or move command: existing file first, destination file second. For example, to link the directory /export/space/common/archive to /archive for easy access, use:

ln -s /export/space/common/archive /archive

To link the runtime control script /etc/init.d/httpd to /etc/rc2.d/S77httpd, use:

cd /etc/rc2.d ln -s ../init.d/httpd S77httpd
@SeriousM
SeriousM / readme.md
Last active August 29, 2015 14:04
Debugging / Fixing Meteor Packages
@SeriousM
SeriousM / readme.md
Created August 8, 2014 11:28
Extract Generic Type Definition in C#
void Main()
{
	GetTypeFromList(new List<string>()).Dump();
	GetTypeFromFunc((string s, int i) => true).Dump();
}

public Type GetTypeFromList<TType>(IEnumerable<TType> dummy)
{
	return typeof(TType);
@SeriousM
SeriousM / 2012-and-later.sql
Created August 13, 2014 13:37
TSQL Rethrow Exception
BEGIN TRY
...
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION;
THROW;
END CATCH
@SeriousM
SeriousM / gist:ed5a0dc0ed5d9a8e09b9
Created April 14, 2015 12:51
VS2013+ magic/pseudo variables
in the watch window or quickwatch:
"$exception": the current exception that is currently available. it has a much better debug experience in the quickwatch because it can look into the exception's type
"{num}#": eg "1#". this is a reference to an object with ObjectId. it acts as a weak-reference and does not affect the GC'ability of the object. http://blogs.msdn.com/b/zainnab/archive/2010/03/04/make-objectid-vstipdebug0015.aspx
"$ReturnValue": contains the return value from the last exited method. The autos-window contains a much better display of that. http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx
"$user": displays the information about the current user - eg to check for permissions, impersonations, etc
"{number-variable},h": displays the variable as hex
"{number-variable},d": displays the variable as decimal/number
@SeriousM
SeriousM / gist:28c8142fe38a3550f76c
Created April 16, 2015 21:56
Installing ungit on ubuntu (-like) os
nodejs is called differently on ubunto (for whatever reason) - https://github.com/FredrikNoren/ungit/issues/401
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo -H npm install -g ungit