Skip to content

Instantly share code, notes, and snippets.

View MarioBinder's full-sized avatar
:octocat:
.

Mario Binder MarioBinder

:octocat:
.
View GitHub Profile
@MarioBinder
MarioBinder / cast_as_date_as_time.sql
Created February 15, 2018 07:16
sql - select where date or time
cast([timeStamp] as date) = '2018-02-16' and
cast([timeStamp] as time) >= '06:00:00.000' and cast([timeStamp] as time) <= '07:00:00.000'
@MarioBinder
MarioBinder / EscapeUnderscoreIn.sql
Created January 4, 2018 15:24
Escape Underscore In MSSQL
select*
FROM TABLE
WHERE username like '%\_del' ESCAPE '\'
@MarioBinder
MarioBinder / connect_API.js
Created December 17, 2017 14:12
How to connect a REST API with JavaScript
var request = new XMLHttpRequest();
request.open('GET', 'https://api_deepli.nk', true);
request.onload = function () {
// Begin accessing JSON data here
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400) {
data.forEach(movie => {
@MarioBinder
MarioBinder / sqlupdate_innerjoin.sql
Created December 14, 2017 06:42
SQL Update with Inner Join
UPDATE s
SET s.IsFreezed = 1
FROM [DBNAME].[dbo].[COLUMN] AS s
INNER JOIN [DBNAME].[dbo].[COLUMN] AS m
ON s.Id = m.StatusId
WHERE m.Subject = 'xxxxx'
AND s.HasSent = 0;
@MarioBinder
MarioBinder / replace_in_SQL.sql
Last active December 14, 2017 06:44
replace in sql
-- replaced the first old characters with new signs
update [DATABASE].[dbo].[TABLE] set COLUMN = stuff(COLUMN, 1, 12, 'E:\Daten\LIVE\')
@MarioBinder
MarioBinder / set_database_offline_online.sql
Last active December 14, 2017 06:44
set database offline-online
--offline
USE master
GO
ALTER DATABASE dbname
SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
--online
USE master
GO
@MarioBinder
MarioBinder / drop_mssql_database.sql
Last active September 13, 2019 10:18
Drop Database
Use dbname;
ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
Use master;
DROP DATABASE dbname;
@MarioBinder
MarioBinder / rename ms-sql database
Last active September 13, 2019 10:19
Rename Database
ALTER DATABASE [dbname] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE [dbname] MODIFY NAME = [dbname_new]
GO
ALTER DATABASE [dbname_new] SET MULTI_USER;
GO
@MarioBinder
MarioBinder / Controller.cs
Last active August 22, 2017 09:27
ForceDownload Ajax, ASP.NET MVC
public ActionResult Export(ViewModel model)
{
var fileData = _repo.GetFile(model...);
var serializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue, RecursionLimit = 100 };
var dataJson = new DownloadAjaxResult(true)
{
File = fileData,
Filename = model.Filename
};
return new ContentResult()
@MarioBinder
MarioBinder / serializeObject
Created August 22, 2017 07:23
serializeObject
//https://stackoverflow.com/a/17488875/119109
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}