Skip to content

Instantly share code, notes, and snippets.

monyskynet

Block or report user

Report or block monyskynet

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
@monyskynet
monyskynet / new_gist_file
Created Jul 26, 2013
Get executing time
View new_gist_file
Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); Thread.Sleep(10000); stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine("RunTime " + elapsedTime);
View new_gist_file
.SetSortOrder(SortBy.Descending("PropertyName"))
@monyskynet
monyskynet / new_gist_file
Created Jul 26, 2013
Object's Properties to Dictionary
View new_gist_file
public class PropertyBag : DynamicObject { private object _source; public PropertyBag(object source) { _source = source; } public object GetProperty(string name) { var type = _source.GetType(); var property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return property.GetValue(_source, null); } public override bool TryGetMember(GetMemberBinder binder, out object result) { result = GetProperty(binder.Name); return true; } public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { result = GetProperty((string)indexes[0]); return true; } }
@monyskynet
monyskynet / new_gist_file
Created Jul 26, 2013
Date Range, storing seperate date compnent
View new_gist_file
{$and:[{SiteId:ObjectId('516f33ab317fa76d0839b3d3')},{Year:2013,Month:1,Day:{$gte:1,$lte:10}}]} {$and:[{SiteId:ObjectId('516f33ab317fa76d0839b3d3')},{'Year':2013},{$or:[{Month:1,Day:{$gte:30}},{Month:2},{Month:3,Day:{$lte:10}}]}]} {$and:[ {SiteId:ObjectId('516f33ab317fa76d0839b3d3')}, {$or:[ {Year:2011,Month:10,Day:{$gte:30}}, {Year:2011,Month:{$gt:10}}, {Year:{$gt:2011,$lt:2013}}, {Year:2013,Month:{$lt:1}}, {Year:2013,Month:1,Day:{$lte:10}} ]} ]}
View new_gist_file
var array = new List<int>() {3, 4};
var query = Query.All("SomeArray", BsonArray.Create(array));
collection.Find(query);
//The result of Query.All will all documents thats have nested array SomeArray with values 3 and 4.
//If you want 3 or 4 use
Query.In("SomeArray", BsonArray.Create(array))
@monyskynet
monyskynet / new_gist_file
Created Jul 26, 2013
Convert string to upper case
View new_gist_file
System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase
@monyskynet
monyskynet / new_gist_file
Created Jul 26, 2013
Get Row in Date range
View new_gist_file
AND ClickedDate BETWEEN '01/03/2012' AND '12/03/2013'
-- OR
AND DATEADD(DAY, DATEDIFF(DAY, 0, ClickedDate), 0) BETWEEN '01/03/2012' AND '12/03/2013'
--OR
AND ClickedDate >= '01/03/2012' AND ClickedDate <= '12/03/2013'
View new_gist_file
delay(time)
E.g.
$('query').fadeIn(5000).delay(5000).fadeOut(5000);
@monyskynet
monyskynet / new_gist_file
Created Jul 26, 2013
Display scroll position
View new_gist_file
var isHintShown = false; $(document).on('scroll', function(e) { var doc = $(this); if (!isHintShown && (doc.scrollTop() >= Math.round(doc.height() / 2))) { console.log('Middle'); isHintShown = true; } } );
@monyskynet
monyskynet / new_gist_file
Created Jul 26, 2013
Get element's attached events
View new_gist_file
$._data(document.getElementById(''), 'events')
You can’t perform that action at this time.