Skip to content

Instantly share code, notes, and snippets.

@yasinkuyu
yasinkuyu / Sift3.cs
Last active February 18, 2019 11:41
Super Fast and Accurate string distance algorithm: Sift3 in C#
// @yasinkuyu
// 27/04/2014
public static float Sift3(string s1, string s2, int maxOffset)
{
if (string.IsNullOrEmpty(s1))
return ((string.IsNullOrEmpty(s2)) ? 0 : s2.Length);
if (string.IsNullOrEmpty(s2))
@yasinkuyu
yasinkuyu / Distance.cs
Created April 27, 2014 19:03
C# distance between two points (c# ile mesafe hesaplama)
// @yasinkuyu
// 27/04/2014
public static double Distance(double lat1, double lon1, double lat2, double lon2, char unit)
{
Func<double, double> deg2Rad = (x) => (x * (Math.PI / 180));
Func<double, double> rad2Deg = (x) => (x / Math.PI * 180.0);
var theta = lon1 - lon2;
@yasinkuyu
yasinkuyu / get_mem.cs
Last active August 31, 2016 17:27
C# WMI memory usage
// @yasinkuyu
// 06/05/2014
public dynamic get_mem()
{
dynamic returndata = new ExpandoObject();
var search = new ManagementObjectSearcher("root\\CIMV2", "Select TotalVisibleMemorySize, FreePhysicalMemory from Win32_OPeratingSystem");
foreach (var x in search.Get())
@yasinkuyu
yasinkuyu / foursquare.py
Created May 15, 2014 10:38
Foursquare categories recursive MySQL Database insert with Python
# @yasinkuyu
# 15/05/2014
import json
import MySQLdb
# First dump foursquare-categories.json ----> https://gist.github.com/janosgyerik/2906942
# CREATE TABLE `category` (
# `CatId` int(11) NOT NULL AUTO_INCREMENT,
# `ParentId` int(11) DEFAULT NULL,
@yasinkuyu
yasinkuyu / foursquare.cs
Last active August 29, 2015 14:01
Foursquare categories recursive MySQL Database insert with C#
// @yasinkuyu
// 15/05/2014
using System;
using System.IO;
using MySql.Data.MySqlClient;
using Newtonsoft.Json.Linq;
namespace FoursquareCategories
{
@yasinkuyu
yasinkuyu / languageCodes.cs
Last active August 29, 2015 14:01
Get All Language Codes
// @yasinkuyu
// 15/05/2014
string code = "";
string name = "";
foreach (CultureInfo lang in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
try
{
code = CultureInfo.CreateSpecificCulture(lang.Name).Name.Replace("-", "_");
@yasinkuyu
yasinkuyu / units.js
Last active August 29, 2015 14:03
CSS/HTML/JS Units of Measure Parsing
/*
@ CSS/HTML/JS Units of Measure Parsing
@ Regular Expressions (RegEx / RegExp) Pattern
@ Test http://www.regexr.com/39424
@ Pattern RegExp(/(\d*\.?\d+)\s?(px|em|ex|%|in|cm|mm|pt|pc+)/igm)
Yasin Kuyu - twitter.com/yasinkuyu */
#Comments
@yasinkuyu
yasinkuyu / codemirror-prism-okaidia.css
Last active May 31, 2016 02:49
prism.js Okaidia Dark theme for CodeMirror
@charset "UTF-8";
/**
*
* prism.js Okaidia dark for JavaScript, CSS and HTML
* @author Yasin Kuyu
* http://code.insya.com
*
*/
@yasinkuyu
yasinkuyu / turkish-letter-frequency.js
Created January 12, 2016 15:12
Turkish letter frequency
// @yasinkuyu
// https://tr.wikipedia.org/wiki/T%C3%BCrk_alfabesindeki_harflerin_kullan%C4%B1m_s%C4%B1kl%C4%B1klar%C4%B1
// Türk alfabesindeki harflerin kullanım sıklıkları
var alfabe = {
'A': 11.92,
'B': 2.844,
'C': 0.963,
'Ç': 1.156,
'D': 4.706,
'E': 8.912,
@yasinkuyu
yasinkuyu / turkish_ordinal.js
Last active August 29, 2018 13:31
Türkçe sıra sayıları / Ordinal Numbers
// Türkçe sıra sayıları / Ordinal Numbers
for (var i = 1; i < 32; i++) {
if (i == 2) { var suffix = "nci"; }
else if (i == 3 || i == 4 || i == 13 || i == 14 || i == 23 || i == 24) { var suffix = "üncü"; }
else if (i == 6 ) { var suffix = "ncı"; }
else if (i == 9 || i == 10 || i == 19 || i == 29 || i == 39) { var suffix = "uncu"; }
else { var suffix = "inci"; }
console.log( i + '\'' + suffix);