Skip to content

Instantly share code, notes, and snippets.

@papsl
papsl / Backbone-Tutorials-Model.js
Last active August 29, 2015 14:00
Backbone Tutorials - Model
Person = Backbone.Model.extend({
// default values of attributes
defaults:{
age:0,
children: []
},
// validation
validate: function(attributes){
if(attributes.age<0){
console.log("Validation error, person can't be negative age!");
@papsl
papsl / UpdateChocolateyNuget
Created May 12, 2014 12:41
How to update NuGet client in Chocolatey
C:\cd C:\Chocolatey\chocolateyInstall
C:\Chocolatey\chocolateyinstall>nuget.exe update -self
Checking for updates from https://nuget.org/api/v2/.
Currently running NuGet.exe 2.1.0.
Updating NuGet.exe to 2.8.2-beta.
Update successful.
@papsl
papsl / designer.html
Created July 21, 2014 19:24
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
<!DOCTYPE html>
<html>
<head>
<title>Simple SVG "pipe"</title>
</head>
<body>
<canvas id='canvas' width='1024' height='800'></canvas>
<script>
var ctx = document.getElementById("canvas").getContext("2d");
@papsl
papsl / MSSQLRemoteServerQuery.sql
Created March 3, 2015 07:55
How can I query remote Microsoft SQL Server without setting up linked server
-- Using OPENROWSET
SELECT m.name, m.database_id
FROM OPENROWSET('SQLNCLI', 'Server=RemooteServerName;Trusted_Connection=yes;','SELECT * FROM master.sys.databases') AS m
-- Using OPENDATASOURCE
SELECT name, database_id
FROM OPENDATASOURCE('SQLNCLI','Data Source=RemooteServerName;Integrated Security=SSPI').master.sys.databases
@papsl
papsl / CatchWillFailWhenUsedInProcedure.sql
Last active August 29, 2015 14:16
Example Improper error handling with SQL try catch
-- This procedure will fail twice, first time in main TRY block and second time in CATCH statement because of converting ERROR_MESSAGE to INT
CREATE PROCEDURE dbo.SomeWork
AS
BEGIN TRY
-- let's do something
-- ...
-- Exception happens
PRINT 0/0
END TRY
@papsl
papsl / CreateTemporaryTable.sql
Created March 6, 2015 10:03
Example of improper creation of temporary table with Primary key (Microsoft SQL Server)
-- 1.) Problematic way
-- This example will fail on a second execution (when first table not dropped, even in case it is executed in different connection or user context).
-- PK_SomeTable will already exist in tempdb
CREATE TABLE #SomeTable
(
Id INT IDENTITY(1, 1) ,
[Name] [varchar](255) NULL ,
CONSTRAINT [PK_SomeTable] PRIMARY KEY CLUSTERED ( [Id] ASC )
)
-- Output:
@papsl
papsl / gist:7f499e4690a58e885319
Created August 17, 2015 12:06
Azure - Open PowerShell session to Azure Virtual Machine (complete with publish settings)
#Download file
Get-AzurePublishSettingsFile
#Import Publishing file
Import-AzurePublishSettingsFile -PublishSettingsFile "publishsettingsfile.publishsettings"
#List all profiles
Get-AzureSubscription
#Select active AzureSubscription
@papsl
papsl / EmulatorRun.cmd
Created August 25, 2015 15:00
How can I run Visual Studio Android emulator from Command line
%programfiles(x86)%\Microsoft Emulator Manager\1.0\emulatorcmd launch /sku:Android /id:0076019F-F03D-41CC-984F-D92FCBD52648
@papsl
papsl / 0_reuse_code.js
Created October 2, 2015 10:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console