Skip to content

Instantly share code, notes, and snippets.

View gabrielizalo's full-sized avatar
🇨🇴

Gabriel Porras gabrielizalo

🇨🇴
View GitHub Profile
@gabrielizalo
gabrielizalo / header.sql
Last active September 6, 2018 14:26
MS SQL - Header for SQL programs (views, functions, sps...)
-- =============================================
-- Author: <Author Name>
-- Create date: <Creation date>
-- Description: <Description>
-- Example: <Example code to execute>
-- History: <Modification date> > <Description of the modification>
-- <Modification date> > <Description of the modification>
-- =============================================
@gabrielizalo
gabrielizalo / DateTime.cs
Created July 8, 2017 00:07
DateTimeVariable.ToString("yyyyMMdd")
DateTimeVariable.ToString("yyyyMMdd")
@gabrielizalo
gabrielizalo / DateInternationalFormat.sql
Created July 8, 2017 00:16
MS SQL - Date in format YYYYMMDD as String
SELECT CONVERT ( VarChar(8), GETDATE(), 112)
@gabrielizalo
gabrielizalo / GetDateWithoutTime.sql
Created July 8, 2017 00:18
MS SQL - GetDate without time
SELECT CAST ( FLOOR ( CAST ( GETDATE() AS DECIMAL (12, 5) ) ) AS DATETIME )
@gabrielizalo
gabrielizalo / Promises.js
Created July 8, 2017 00:19
Javascript - Promises
// Definition
// ----------------
var p = new Promise(function(resolve, reject) {
// Do an async task async task and then...
if(/* good condition */) {
resolve('Success!');
}
else {
@gabrielizalo
gabrielizalo / jQueryExists.js
Created July 8, 2017 00:21
jQuery - Exists
// if element exists
if($('selector').length){ //do something }
// if element does not exist
if(!$('selector').length){ //do something }
@gabrielizalo
gabrielizalo / AntiClickJacking.html
Created July 8, 2017 00:22
.Net - Anti ClickJacking
<style>
body{display:none;}
</style>
<script>
if(self==top){
document.getElementsByTagName("body")[0].style.display="block";
}else{
top.location=self.location;
}
</script>
@gabrielizalo
gabrielizalo / NoCache.cs
Created July 8, 2017 00:24
.Net - No Cache Headers
// Http 1.1
getCurrentResponse().setHeader("Cache-Control", "no store, no-cache, must-revalidate");
// Http 1.0
getCurrentResponse().setHeader("Pragma", "no-cache");
// Prevents caching at the proxy server
getCurrentResponse().setDateHeader ("Expires", -1);
@gabrielizalo
gabrielizalo / functionCall.ts
Created July 8, 2017 00:25
Typescript - Call function from a JS Library
(<any>window).MyExternalFunction();
@gabrielizalo
gabrielizalo / EasilyNavigateWithinASectionOfPages.php
Created July 24, 2017 09:18
Wordpress - Easily Navigate Within a Section of Pages
// Taken from: https://speckyboy.com/wordpress-snippets-secondary-navigation/
/*
This code makes for a great secondary navigation menu that could be used, for example, within a sidebar. It automatically displays the pages within the current section you’re browsing.
As an example, let’s say your site has an About Us page, with subpages for History, Mission Statement and Staff. Users will be able to more easily navigate between the various pages within this section as a bulleted list of links.
*/
<?php
if ( $post->post_parent ) {
$children = wp_list_pages( array(
'title_li' => '',
'child_of' => $post->post_parent,