Skip to content

Instantly share code, notes, and snippets.

View orhanveli's full-sized avatar

orhan orhanveli

  • Finbyte GmbH
  • Turkiye
  • 19:29 (UTC +03:00)
View GitHub Profile
@orhanveli
orhanveli / fb_share_modal.js
Created January 20, 2014 15:01
Facebook share modal dialog (inline not pop-up) with custom title, description and image
var FbShareWindow = function (url, title, description, img, reftext) {
if (typeof title !== "string") {
title = $("title").text();
}
if (typeof description !== "string") {
description = $("meta[name='description']").attr("content");
}
FB.ui(
@orhanveli
orhanveli / tr-il-ilce-enlem-boylam
Last active November 5, 2021 10:27
Türkiye il-ilçeleri ve enlem-boylam bilgileri
/*
Target Server Type : MYSQL
Target Server Version : 50505
File Encoding : 65001
Date: 2015-03-05 14:23:53
*/
SET FOREIGN_KEY_CHECKS=0;
@orhanveli
orhanveli / Alerts.cs
Last active October 4, 2020 05:23
ASP.NET MVC error and notification messages for after form submissions
public static class MyAlerts
{
public const string SUCCESS = "success";
public const string ATTENTION = "attention";
public const string ERROR = "error";
public const string INFORMATION = "info";
public static string[] ALL
{
get
@orhanveli
orhanveli / interview-question.js
Created September 23, 2020 13:55
The following recursive code will cause a stack overflow if the array list is too large. How can you fix this and still retain the recursive pattern?
var list = readHugeList();
var nextListItem = function() {
var item = list.pop();
if (item) {
// process the list item...
nextListItem();
}
};
@orhanveli
orhanveli / interview-question.js
Created September 23, 2020 13:52
Write a sum method which will work properly when invoked using either syntax below.
console.log(sum(2,3)); // Outputs 5
console.log(sum(2)(3)); // Outputs 5
@orhanveli
orhanveli / interview-question.js
Created September 23, 2020 13:50
What will the code below output? Explain your answer.
console.log(0.1 + 0.2);
console.log(0.1 + 0.2 == 0.3);
@orhanveli
orhanveli / interview-question.js
Created September 23, 2020 13:48
What will the code below output to the console and why?
(function(){
var a = b = 3;
})();
console.log("a defined? " + (typeof a !== 'undefined'));
console.log("b defined? " + (typeof b !== 'undefined'));
@orhanveli
orhanveli / email-verify.js
Last active March 4, 2020 13:39
email-verify with nodejs
const dns = require('dns');
const mailcheck = require('mailcheck');
const isDomainMXValid = (domain) => {
return new Promise((resolve, reject) => {
dns.resolveMx(domain, (err, mxs) => {
if (err) {
reject(err);
}
resolve(!!(mxs && mxs.length > 0 && mxs[0].exchange));
@orhanveli
orhanveli / makeReq.ts
Created November 26, 2019 17:16
make req with http module
export const makeReq = (url: string | undefined, data = '', headers: any = {}, timeout = 5000): Promise<string> => {
if (!url) {
throw 'url must be defined!';
}
const contentLength = Buffer.byteLength(data, 'utf-8');
headers['Content-Length'] = contentLength;
headers['Content-Type'] = 'text/xml; charset=utf-8';
headers['Connection'] = 'keep-alive';
@orhanveli
orhanveli / README.md
Last active September 27, 2019 10:04
react-native-webview auto height and link click handler via window.postMessage