Skip to content

Instantly share code, notes, and snippets.

View ugurozpinar's full-sized avatar

Uğur Özpınar ugurozpinar

View GitHub Profile
@ugurozpinar
ugurozpinar / turkce_siralama.js
Created March 21, 2014 09:36
Javascript object array Turkish sorting. Türkçe Sıralama
var arr = [{id:3,title:"Ali"},{id:3,title:"Veli"},{id:3,title:"Vehbi"}];
arr.sort(turkcesiralama);
function turkcesiralama(a, b){
var atitle = a.title;
var btitle = b.title;
var alfabe = "AaBbCcÇçDdEeFfGgĞğHhIıİiJjKkLlMmNnOoÖöPpQqRrSsŞşTtUuÜüVvWwXxYyZz0123456789";
if (atitle.length === 0 || btitle.length === 0) {
return atitle.length - btitle.length;
}
@ugurozpinar
ugurozpinar / truncate.js
Created April 9, 2014 12:25
Javascript truncate text (middle)
truncate('Javascript ile metni ortadan bölme',10,'...');
// output : Java...lme
//unminified
var truncate = function (fullStr, strLen, separator) {
if (fullStr.length <= strLen) return fullStr;
separator = separator || '...';
var sepLen = separator.length,
@ugurozpinar
ugurozpinar / getUrlVars
Created November 28, 2014 08:37
javascript get parameters from url. querystring
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
@ugurozpinar
ugurozpinar / calculateDistance
Created December 10, 2014 08:27
javascript distance between two coordinates
function calculateDistance(lat1, lon1, lat2, lon2) {
var R = 6371;
var dLat = (lat2 - lat1) * Math.PI / 180;
var dLon = (lon2 - lon1) * Math.PI / 180;
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
if (d > 1)
@ugurozpinar
ugurozpinar / stopwords.json
Last active June 5, 2017 13:21
Stop words json (utf8) multi language. Turkish, Russian, Romanian, Portuguese (Portugal), Polish, Dutch, Italian, Indonesian, Hungarian, French (France), Finnish, Spanish (Spain), German, Bulgarian, Arabic
{
"zh": ["的", "一", "不", "在", "人", "有", "是", "为", "以", "于", "上", "他", "而", "后", "之", "来", "及", "了", "因", "下", "可", "到", "由", "这", "与", "也", "此", "但", "并", "个", "其", "已", "无", "小", "我", "们", "起", "最", "再", "今", "去", "好", "只", "又", "或", "很", "亦", "某", "把", "那", "你", "乃", "它", "吧", "被", "比", "别", "趁", "当", "从", "到", "得", "打", "凡", "儿", "尔", "该", "各", "给", "跟", "和", "何", "还", "即", "几", "既", "看", "据", "距", "靠", "啦", "了", "另", "么", "每", "们", "嘛", "拿", "哪", "那", "您", "凭", "且", "却", "让", "仍", "啥", "如", "若", "使", "谁", "虽", "随", "同", "所", "她", "哇", "嗡", "往", "哪", "些", "向", "沿", "哟", "用", "于", "咱", "则", "怎", "曾", "至", "致", "着", "诸", "自"],
"tr": ["acaba", "altmış", "altı", "ama", "ancak", "arada", "aslında", "ayrıca", "bana", "bazı", "belki", "ben", "benden", "beni", "benim", "beri", "beş", "bile", "bin", "bir", "birçok", "biri", "birkaç", "birkez", "birşey", "birşeyi", "biz", "bize", "bizden", "bizi", "bizim", "böyle", "böylece", "bu", "buna", "bunda", "bundan", "bunlar", "bunları", "bunların", "bunu", "bunun", "
@ugurozpinar
ugurozpinar / vbacolortorgb.sql
Last active June 15, 2017 10:48
Convert vba long color to rgb mssql functions
CREATE FUNCTION MODU ( @num int,@mod int)
RETURNS int
AS
BEGIN
DECLARE @numtmp int
IF @num<0
SET @numtmp = @num+(@mod*CEILING(ABS(CAST(@num AS FLOAT)/CAST(@mod AS FLOAT))))
ELSE
SET @numtmp = @num