Skip to content

Instantly share code, notes, and snippets.

View oscarandreu's full-sized avatar
💭
At work

Óscar Andreu oscarandreu

💭
At work
View GitHub Profile
@oscarandreu
oscarandreu / npmTrick1.js
Created February 1, 2016 10:51
node gyp error TRACKER : error TRK0005: Failed to locate: “CL.exe”. The system cannot find the file specified
//solve the problem:
//node gyp error TRACKER : error TRK0005: Failed to locate: “CL.exe”. The system cannot find the file specified
npm config set msvs_version 2013 --global
@oscarandreu
oscarandreu / sqlXmlInputParameters.sql
Last active February 5, 2016 14:13
SQL use xml input parameters
DECLARE @XML AS XML
SET @XML = '<root>
<row><Id>1855</Id><Count>2</Count></row>
<row><Id>1856</Id><Count>4</Count></row>
<row><Id>1857</Id><Count>1</Count></row>
</root>'
;WITH CTE AS
(
SELECT
@oscarandreu
oscarandreu / d3js.js
Created February 15, 2016 09:53
d3js example
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
font: 300 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
fill: #bbb;
}
.node:hover {
@oscarandreu
oscarandreu / dataReplace.sql
Created February 17, 2016 16:12
Replace part of a field and update the row
;WITH CTE AS
(
SELECT top 2
[Lab_ID] id
,replace(Lab_HtmlDefinition, 'data-pdnbind="src: resources/V1/products/{ean}_04;"', '') html
,CASE WHEN Lab_HtmlDefinition <> replace(Lab_HtmlDefinition, 'data-pdnbind="src: resources/V1/products/{ean}_04;"', '') THEN 1 ELSE 0 END WasReplaced
FROM [dbo].[Lab_Pricelabels]
WHERE --lab_customerId = 180211 and
Lab_ID = 560589
)
@oscarandreu
oscarandreu / xmlSerializeWithoutHeader.cs
Created February 22, 2016 14:58
Serialize XML without header
public static string XmlSerializeWithoutHeader<T>(T instance)
{
if (instance == null) return null;
XmlSerializer xmlSerializer = new XmlSerializer(instance.GetType());
StringBuilder sb = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(sb, new XmlWriterSettings() { OmitXmlDeclaration = true })) {
xmlSerializer.Serialize(writer, instance);
}
@oscarandreu
oscarandreu / xmlSerialize
Created March 4, 2016 14:14
Generate C# class from XML
D:\temp>xsd test.xml
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'D:\temp\test.xsd'.
D:\temp>xsd test.xsd /classes
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
@oscarandreu
oscarandreu / javascriptRedirect.js
Created March 8, 2016 08:11
Redirect to url parameter URL via javascript
function getQueryParams(qs) {
qs = qs.split('+').join(' ');
var params = {},
tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
@oscarandreu
oscarandreu / basicAjaxGet.js
Created March 8, 2016 08:12
Basic Ajax get using jquery
<script src="http://code.jquery.com/jquery-1.12.1.min.js"></script>
<script>
$.get( "ajax/test.html", function( data ) {
$( ".result" ).html( data );
alert( "Load was performed." );
});
</script>
@oscarandreu
oscarandreu / projfileModificationsCompilieTransforms.xml
Created April 13, 2016 14:54
Visual Studio -- project file modifications to apply transformations in config file during compile
<PropertyGroup>
<PostBuildEvent>$(MSBUILDBINPATH)\msbuild "$(ProjectPath)" /t:Transform /p:Configuration=$(ConfigurationName);Platform=AnyCPU
xcopy "$(ProjectDir)obj\$(ConfigurationName)\Web.Config" $(ProjectDir)\. /F /R /Y
</PostBuildEvent>
</PropertyGroup>
<Target Name="Transform">
<MakeDir Directories="obj\$(Configuration)" Condition="!Exists('obj\$(Configuration)')" />
<TransformXml Source="Web.Config" Transform="Web.$(Configuration).config" Destination="obj\$(Configuration)\Web.config" StackTrace="true" />
</Target>
@oscarandreu
oscarandreu / RFC 2119.html
Last active July 22, 2016 11:11
RFC 2119 Documentation Note.
Requirements language
The keywords "MUST," "MUST NOT," "REQUIRED," "SHALL," "SHALL NOT," "SHOULD," "SHOULD NOT," "RECOMMENDED," "MAY," and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.