Skip to content

Instantly share code, notes, and snippets.

View fcmendoza's full-sized avatar
💭
My future look cloud-y

Fernando Mendoza fcmendoza

💭
My future look cloud-y
View GitHub Profile
@fcmendoza
fcmendoza / Unique.sql
Created July 24, 2011 05:28
Unique Fields at Table Creation
CREATE TABLE [Clients]
(
ClientID int NOT NULL IDENTITY(1,1) CONSTRAINT [PK_Clients] PRIMARY KEY,
ServiceCode varchar(50) NOT NULL,
CONSTRAINT [UN_Clients_Unique] UNIQUE (ClientID, ServiceCode)
...
)
@fcmendoza
fcmendoza / Syntax.html
Created July 31, 2011 15:13
Syntax Highlighter
<pre class="brush:js; toolbar:false; auto-links:false;">
$.ajax({
url: "/Home/Index",
data: { email: email, username: username, etc: etc },
success: function (data) {
debugger; // remove debugger before check-in.
$("#somelabel").text(data.SomeText);
},
type: "POST",
dataType: 'json'
@fcmendoza
fcmendoza / example.cs
Created December 16, 2011 23:01
if and else if example for Moni
int myData = 20;
if(IsInTable(tableName: "A", data: myData)) {
print("data found in table A");
}
else if (IsInTable(tableName: "B", data: myData)) {
print("data found in table B");
}
else if (IsInTable(tableName: "C", data: myData)) {
print("data found in table C");
@fcmendoza
fcmendoza / alpha.cs
Created January 4, 2012 18:53
Dinamically set images to buttons (for Moni)
int n = 15;
for (int i = 1; i < n; i++) {
var button = GetButton(i);
buttton.Image = new Bitmap(@"..\..\Resources\DateButtons\" + buttton.Tag + ".png");
}
private Button GetButton(int number) {
// this code gets and returns the button especified by number from its container.
}
@fcmendoza
fcmendoza / failed_jobs.sql
Created February 21, 2012 18:47
SQL Server Script to Display Job History
declare @today datetime
set @today = CAST(convert(varchar, GETDATE(), 101) as datetime)
select
j.name as job_name,
run_datetime = CONVERT(DATETIME, RTRIM(run_date)) +
(run_time * 9 + run_time % 10000 * 6 + run_time % 100 * 10) / 216e4,
run_duration = RIGHT('000000' + CONVERT(varchar(6), run_duration), 6), *
from msdb..sysjobhistory h
inner join msdb..sysjobs j
@fcmendoza
fcmendoza / ternaryif.cs
Created May 2, 2012 23:01
Ternary IF for moni
// This:
item.PickupId = (item.PickupId == null) ? headerRecord.PickupId : item.PickupId;
// Is the same as this:
if(item.PickupId == null) {
item.PickupId = headerRecord.PickupId
} else {
@fcmendoza
fcmendoza / commands.t
Created January 22, 2013 20:43
IIS and app pools stuff. Open IIS from command line. Start and stop application pool
# Open IIS from command line
C:\Windows\system32>cd inetsrv
C:\Windows\System32\inetsrv>%systemroot%\system32\inetsrv\iis.msc
# Start and stop application pool
C:\Windows\System32\inetsrv>appcmd stop apppool /apppool.name:lorem-ipsum
"lorem-ipsum" successfully stopped
@fcmendoza
fcmendoza / evil_ifs.c
Last active December 12, 2015 10:19
Evil if
// Evil if:
if (x == 1) {
if (x == 1.1) {
print("lorem ipsum 1.1")
}
else if (x == 1.2) {
print ("lorem ipsum 1.2")
}
else if (x == 1.3) {
@fcmendoza
fcmendoza / reseed.sql
Last active December 16, 2015 04:09
Reseed tables
select t.full_name as table_name, c.column_name, case when c.system_type_id = 127 then 9223372036854775808/2 else 2147483648/2 end as seed_value
from sys_columns c
inner join sys_tables t on t.full_name = c.full_name
where c.is_identity = 1 and t.is_replicated = 1
order by t.full_name
select 'DBCC CHECKIDENT(''' + t.full_name + ''', reseed, ' + cast(cast(2147483648/2 as int) as varchar) + ')' as reseed_command
,t.full_name as table_name, c.column_name, cast(2147483648/2 as int) seed_value
from sys_columns c
inner join sys_tables t on t.full_name = c.full_name
@fcmendoza
fcmendoza / each.js
Last active August 29, 2015 14:12
jQuery samples
// This code gets all textboxes with the 'required' class and
// executes a method for those that don't have a value.
$(":text .required" ).each(function( index, element ) {
var self = this;
var labelText = $('label[for=' + self.id + ']').text();
if (element.val() == "") {
message("Please fill " + labelText, "#" + self.id);
return false;