- https://github.com/enochtangg/quick-SQL-cheatsheet - A quick reminder of all relevant SQL queries and examples on how to use them.
- https://dbdiagram.io/ - A free and simple tool to draw ER diagrams by just writing code.
| HttpContextBase wrapper = new HttpContextWrapper(HttpContext.Current); | |
| UmbracoBackOfficeIdentity user = wrapper.GetCurrentIdentity(true); | |
| bool isLoggedIn = user != null; |
| foreach (var prop in Model.Properties) | |
| { | |
| <p>@prop.Alias + " - " + @prop.Value()</p> | |
| } |
| SELECT STRAIGHT_JOIN categories.id, categories.title, categories.game_count, categories.display_order FROM `categories` INNER JOIN `category_namespaces` ON `category_namespaces`.`category_id` = `categories`.`id` WHERE `categories`.`type` IN ('ClickJogos::GameCategory') AND `categories`.`published` = 1 AND (category_namespaces.namespace = 'jgo') ORDER BY | |
| CASE | |
| WHEN categories.id LIKE '447%' THEN 1 | |
| WHEN categories.id LIKE '448%' THEN 2 | |
| ELSE 3 | |
| END, categories.game_count DESC; |
| // 4.0 | |
| var lineCount = File.ReadLines(@"C:\file.txt").Count(); | |
| // pre-4.0 | |
| var lineCount = File.ReadAllLines(@"C:\file.txt").Length; | |
| // pre-4.0 (more efficient) | |
| var lineCount = 0; |
| protected static T? GetValueFromConfiguration<T>(String key) where T : struct | |
| { | |
| T? returnValue = null; | |
| if (System.Configuration.ConfigurationManager.AppSettings[key] != null) | |
| { | |
| returnValue = System.Configuration.ConfigurationManager.AppSettings[key] | |
| .ConvertTo<T>(); //MY AWSOME CONVERTTO METHOD!!11 | |
| } | |
| return returnValue; |
| -- https://stackoverflow.com/questions/10637976/how-do-you-check-if-identity-insert-is-set-to-on-or-off-in-sql-server | |
| SELECT OBJECTPROPERTY(OBJECT_ID('MyTable'), 'TableHasIdentity'); | |
| -- when using an API wrapper, one can reduce the entire check to just checking for rows. For instance when using C#'s SqlDataReaders property HasRows and a query construct like: | |
| SELECT CASE OBJECTPROPERTY(OBJECT_ID('MyTable'), 'TableHasIdentity') WHEN 1 THEN '1' ELSE NULL END | |
| -- more flexibility but needs column name | |
| SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('MyTable', 'U') AND name = 'MyTableIdentityColumnName'; |
| CREATE PROC SearchAllTables | |
| ( | |
| @SearchStr nvarchar(100) | |
| ) | |
| AS | |
| BEGIN | |
| CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630)) | |
| SET NOCOUNT ON |
| class Code { | |
| public static bool ContainsAll<T>(this IEnumerable<T> actual, IEnumerable<T> expected) { | |
| return actual.All(a => expected.Contains(a)); | |
| } | |
| } |
| # List Current Version | |
| $PSVersionTable.PSVersion | |
| Example 1: Send output to a file | |
| Get-Process | Out-File -filepath C:\Test1\process.txt | |
| # Example 2: How to retrieve recursively any files with a specific extensions in PowerShell? | |
| # https://stackoverflow.com/questions/31049454/how-to-retrieve-recursively-any-files-with-a-specific-extensions-in-powershell |