Skip to content

Instantly share code, notes, and snippets.

View metinsaylan's full-sized avatar
🤘
rocking on!

Metin Şaylan metinsaylan

🤘
rocking on!
View GitHub Profile
<?php
function shailan_filter_terms( $exclusions, $args ){
// IDs of terms to be excluded
$exclude = "3,257"; // CHANGE THIS TO IDs OF YOUR TERMS
// Generation of exclusion SQL code
$exterms = wp_parse_id_list( $exclude );
foreach ( $exterms as $exterm ) {
@metinsaylan
metinsaylan / generate_tag_pages.py
Created September 21, 2017 22:17
Python script to generate tag archive indexes for Jekyll blog http://metinsaylan.com/python/2017/09/21/tag-index-generator-for-jekyll/
import os, frontmatter, re, unicodedata
tag_page_dir='_pages/tag' # set correct directory
cur_path = os.path.dirname(os.path.realpath(__file__))
tags = []
def slugify(value):
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^\w\s-]', '', value.replace('.','-')).strip().lower()
@metinsaylan
metinsaylan / loop.html
Created September 21, 2017 22:14
Jekyll loop component to loop posts of a given tag
<ul class="post-loop">
{% assign post_exp = "post.tags contains '" | append: include.tag | append: "'" %}
{% assign posts = site.posts | where_exp: "post", post_exp %}
{% for post in posts %}
<li><a class="post-title" href="{{ site.baseurl }}{{ post.url }}">{{ post.title }} <small class="post-date">{{ post.date | date_to_string }}</small></a></li>
{% endfor %}
</ul>
@metinsaylan
metinsaylan / 404-error-tracking.html
Created August 9, 2017 06:33 — forked from pwenzel/404-error-tracking.html
Track 404 errors as events with Google Universal Analytics, capturing the referrer as well.
<script type="text/javascript">
// Track 404 errors with Universal Analytics
if($('body').hasClass('error404')) {
ga('send', 'event', 'error', '404', 'page: ' + document.location.pathname + document.location.search + ' ref: ' + document.referrer, {'nonInteraction': 1});
}
</script>
@metinsaylan
metinsaylan / meta.php
Created August 9, 2017 06:33
Wordpress meta tags without a plugin
<?php
/**
* @link Escape post content in META Attributes, http://codex.wordpress.org/Data_Validation
* @link Complete List of HTML Meta Tags, https://gist.github.com/kevinSuttle/1997924
* @example get_template_part('meta');
*/
?>
<meta name="twitter:card" content="summary">
<!--<meta name="twitter:site" content="@YOUR_TWITTER_HANDLE">-->
Imports System.Globalization
Imports System.Runtime.CompilerServices
Public Module StringExtensions
''' <summary>
''' This extension function converts a string to TitleCase.
''' </summary>
''' <param name="inputString">String to convert.</param>
''' <returns>Converted string.</returns>
<Extension()>
@metinsaylan
metinsaylan / geomet.out.template
Created November 17, 2016 07:52
PDStrip Geometry File Template
nse sym tg
x(ise) nof(ise) ngap gap(1:ngap)
yof(ise,1:nof(ise))
zof(ise,1:nof(ise))
@metinsaylan
metinsaylan / pdstrip.inp.template
Created November 17, 2016 07:49
PDStrip Input File Template
npres lsect ltrans lsign
text
g rho zwl zbot zdrift
nmu angles(nmu)
geometry_filename
ls
mass(is),xg(is),yg(is),zg(is),thxx,thyy,thzz,thxy,thyz,thxz
(iab(ise),ise=1,nse)
@metinsaylan
metinsaylan / GenerateSlug.vb
Created June 27, 2016 12:03
String extension for GenerateSlug capability
<Extension()>
Public Function GenerateSlug(ByVal this As String)
Dim str As String = this.RemoveAccent().ToLower()
' invalid chars
str = Regex.Replace(str, "[^a-z0-9\s-]", "", RegexOptions.IgnoreCase)
' convert multiple spaces into one space
str = Regex.Replace(str, "\s+", " ", RegexOptions.IgnoreCase).Trim()
' cut And trim
str = str.Substring(0, IIf(str.Length <= 45, str.Length, 45)).Trim()
str = Regex.Replace(str, "\s", "-", RegexOptions.IgnoreCase) ' hyphens
@metinsaylan
metinsaylan / DataHelper.vb
Created June 27, 2016 12:00
Convert DataTable to HTML
Public Shared Function ConvertDataTableToHTML(ByVal dt As DataTable, Attributes As String, Optional IncludeHeaders As Boolean = True) As String
Dim TableStart As String = "<table " & Attributes & ">"
Dim TableHeader As String =
<thead>
<tr>
<%=
From col As DataColumn In dt.Columns.Cast(Of DataColumn)()
Select <th><%= col.ColumnName %></th>
%>
</tr>