Skip to content

Instantly share code, notes, and snippets.

View iamrommel's full-sized avatar

Rommel C. Manalo iamrommel

View GitHub Profile
mongoimport --host localhost:3001 --db meteor --collection pickups --file pickup.json --drop
@iamrommel
iamrommel / Backupscript
Created April 9, 2014 06:00
Create a stored procedure that will backup all selected database in sql server
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Parameter1: databaseName, setting null backup all databases
-- Parameter2: backupType F=full, D=differential, L=log
@iamrommel
iamrommel / oncollectionchange
Created September 16, 2013 03:15
On collection changed, trap the added item and put some logic and set value for it
partial void Plants_Changed(NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
var addedItem = e.NewItems[0] as HaulerPlant;
if (addedItem == null) return;
addedItem.IsActive = true;
}
@iamrommel
iamrommel / SQLServerTricks
Created August 26, 2013 10:54
Delete duplicate records, convert the datetime to date part only, update the master table by using the aggregate function for child table, update a record using joins with other table, and check duplicates
BEGIN TRAN
--This is a sample to delete a duplicate ticket
--Assuming the duplicates are just maximum count as 2
--But if it, more than two run this check several times, because it gets only the MIN value
DELETE FROM dbo.TicketDetails
WHERE Id IN (
SELECT
MIN(t.Id) as Id
FROM dbo.TicketDetails t
@iamrommel
iamrommel / Keyboard Shortcut
Last active September 14, 2019 03:48
Creating a keyboard shortcuts for Lightswitch application
partial void Tickets_Created()
{
this.FindControl("ScreenLayout").ControlAvailable += Tickets_ControlAvailable;
}
void Tickets_ControlAvailable(object sender, Microsoft.LightSwitch.Presentation.ControlAvailableEventArgs e)
{
var screenLayout = e.Control as System.Windows.Controls.Grid;
if (screenLayout == null) return;
@iamrommel
iamrommel / Generic Equality comparer
Created June 28, 2013 16:45
Generic Equality comparer that can be used of linq
using System;
using System.Collections.Generic;
namespace LightSwitchApplication
{
/// <summary>
/// Generic Equality comparer that can be used of linq
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T>
body
{
background: url(TMMSCM.jpg) center bottom fixed;
background-repeat: no-repeat;
height: 100%;
width: 100%;
background-size: cover;
}
@iamrommel
iamrommel / PremiumComponentFactory
Created June 18, 2013 03:06
Using the Microsoft.LightSwitch.ExportProvider.dll to utilize the MEF in LightSwitch
using System;
using LightSwitchApplication.UserCode.Constants;
using Microsoft.VisualStudio.ExtensibilityHosting;
using System.Linq;
namespace LightSwitchApplication.UserCode.Premium
{
/// <summary>
/// To centralize the method selection use this factory
/// So in the future it will not be cluttered