Skip to content

Instantly share code, notes, and snippets.

@gaborsomogyi
gaborsomogyi / db_clean.sql
Created July 21, 2016 13:40
clean a sql server database if dropping is not an option
-- based on http://blog.falafel.com/t-sql-drop-all-objects-in-a-sql-server-database/
declare @stmt nvarchar(max)
-- procedures
select @stmt = isnull( @stmt + '', '') + 'drop procedure '+ quotename(schema_name(schema_id)) + '.'+ quotename(name) from sys.procedures
-- check constraints
select @stmt = isnull( @stmt + '', '') + 'alter table '+ quotename(schema_name(schema_id)) + '.' + quotename(object_name( parent_object_id ))
+ ' drop constraint '+ quotename(name) from sys.check_constraints
@gaborsomogyi
gaborsomogyi / agDropDownEditor.js
Created November 3, 2015 16:06
modified dropdown editor for ag-grid to create multiple dropdowns in a grid; depends on lodash
function agDropDownEditor(params, optionsName, optionsList) {
_.set(params.$scope, optionsName+'.optionsList', optionsList);
var html = '<span style="width:100%; display:inline-block" ng-show="!'+optionsName+'.editing" ng-click="'+optionsName+'.startEditing()">{{data.'+params.colDef.field+'}}</span> ' +
'<select style="width:100%" ng-blur="'+optionsName+'.editing=false" ng-change="'+optionsName+'.editing=false" ng-show="'+optionsName+'.editing" ng-options="item for item in '+optionsName+'.optionsList" ng-model="data.'+params.colDef.field+'">';
// we could return the html as a string, however we want to add a 'onfocus' listener, which is not possible in AngularJS
var domElement = document.createElement("span");
domElement.innerHTML = html;
@gaborsomogyi
gaborsomogyi / MoveCursor.vba
Created August 24, 2015 08:52
A simple script to move the mouse cursor a bit - every 120 seconds
'Written by Gabor Somogyi 2015
'External declarations
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
'Declare the custom variable for GetCursorPos
Private Type POINTAPI
X As Long