Skip to content

Instantly share code, notes, and snippets.

View sergiogarciadev's full-sized avatar
I turn coffee into code (sometimes in bugs).

Sergio Garcia sergiogarciadev

I turn coffee into code (sometimes in bugs).
View GitHub Profile
@sergiogarciadev
sergiogarciadev / GinxCultureHelper.cs
Created July 15, 2011 00:46
Small class to help handling working with diferent locales in the same system.
public class GinxCultureHelper : IDisposable
{
private readonly CultureInfo _currentUiCulture;
private readonly CultureInfo _currentCulture;
public GinxCultureHelper(string cultureName)
{
_currentCulture = Thread.CurrentThread.CurrentCulture;
_currentUiCulture = Thread.CurrentThread.CurrentUICulture;
@sergiogarciadev
sergiogarciadev / Convert_Collations.sql
Created January 9, 2014 13:09
Alter the collation of all columns on a SQL Server database.
DECLARE
@collation_from VARCHAR(100),
@collation_to VARCHAR(100);
-- Define the collations here
SET @collation_from = 'SQL_Latin1_General_CP1_CI_AS'
SET @collation_to = 'Latin1_General_CI_AS'
@sergiogarciadev
sergiogarciadev / GetRecordCountForAllTables.sql
Last active February 15, 2018 05:05
Get the number of records for each table in the SQL Server database.
DECLARE @sql NVARCHAR(4000)
DECLARE @tableName VARCHAR(255);
CREATE TABLE #DatabaseTables (TableName VARCHAR (255), RecordCount INT);
DECLARE tables_cursor CURSOR FOR
SELECT name FROM sysobjects WHERE xtype = 'U' ORDER BY name
OPEN tables_cursor
@sergiogarciadev
sergiogarciadev / LocalDBHelper.cs
Created May 13, 2014 15:03
LocalDB Helper to create, drop and check localdb databases.
namespace LocalDBSample
{
using System;
using System.Data.SqlClient;
using System.IO;
using System.Reflection;
public class LocalDBHelper
{
public static string DataDirectory
@sergiogarciadev
sergiogarciadev / TransparentUnclickableForm.cs
Created May 15, 2014 02:41
A form that can't be clicked.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int GWL_EXSTYLE = -20;
const int WS_EX_TRANSPARENT = 0x20;
@sergiogarciadev
sergiogarciadev / StackOverflow_Sample.sql
Created May 15, 2014 19:46
Sample SQL for stack overflow
CREATE TABLE [dbo].[AccountBalanceByDate]
(
[Id] int NOT NULL,
[AccountId] int NOT NULL,
[Date] [datetime] NOT NULL,
[Balance] [decimal](19, 5) NOT NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
@sergiogarciadev
sergiogarciadev / StackOverflow_Sample.cs
Last active February 20, 2023 01:54
Entity Framework sample for stack overflow.
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EFSample
{
public class AccountBalanceByDate
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import httplib
import re
import sys
import base64
import subprocess
import urllib
import lxml.etree
@sergiogarciadev
sergiogarciadev / gist:337cda512e5daad22547
Created July 15, 2015 16:58
Detect HTML Window Focus
var focused = false,
focusedTimeout,
lastDate;
function anim() {
clearTimeout(focusedTimeout);
focused=true;
if (!lastDate) {
lastDate = new Date();
(function () {
var d = time(), frames = 0;
function time() {
return parseInt(new Date() / 1000);
}
function fpsCounter() {
if (d != time()) {
console.log(frames + ' fps');