Skip to content

Instantly share code, notes, and snippets.

View gabrielizalo's full-sized avatar
🇨🇴

Gabriel Porras gabrielizalo

🇨🇴
View GitHub Profile
@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,
@gabrielizalo
gabrielizalo / BreadcrumbStylePageTitles.php
Created July 24, 2017 09:19
Wordpress - Breadcrumb Style Page Titles
// Taken from: https://speckyboy.com/wordpress-snippets-secondary-navigation/
/*
This snippet will check to see if the current page has a parent. If so, the parent page’s link and title are displayed within the H1 tag at the top of the page. An arrow character is also displayed between the parent and current page title to complete the breadcrumb look.
Note that this breadcrumb effect only goes one level deep. So you’ll have to adjust the code if you want to link to multiple levels (Parent » Level 1 » Level 2).
*/
<h1 class="entry-title">
<?php
// Conditional Statement to Check for a Parent Post
if($post->post_parent) {
$parent_title = get_the_title($post->post_parent);