Skip to content

Instantly share code, notes, and snippets.

View mahmut-gundogdu's full-sized avatar

Mahmut Gundogdu mahmut-gundogdu

View GitHub Profile
@mahmut-gundogdu
mahmut-gundogdu / useStateWithDep.ts
Created June 8, 2021 19:30
useState initial value changed when initialValue changed
import {useEffect, useState} from 'react';
export function useStateWithDep(defaultValue: any) {
const [value, setValue] = useState(defaultValue);
useEffect(() => {
setValue(defaultValue);
}, [defaultValue]);
return [value, setValue];
}
moment.lang("tr")
var mainElement = $("#ctl00_ctl60_g_86ee7db6_7073_42c5_9737_7005e352da4c .container" )[0]
var result = [];
$(mainElement.children).each(function(a,b){
var row = []
$(b.children).each(function(x,y){
row.push(y.innerText)
});
var domains = {
"wikipedia.org":1,
"spotify.com":1
}
var proxy = "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT;";
var direct = 'DIRECT;';
function FindProxyForURL(url, host) {
<div class="flex">
<div class="kutu"> </div>
<div class="kutu"> </div>
</div>
<div class="flex">
<div class="kutu"> </div>
@mahmut-gundogdu
mahmut-gundogdu / server.js
Last active May 18, 2018 10:45
"Bildiğim kadarıyla yemeksepetinde belirli bir restorandan sipariş vermek istediğimizde eğer restoranımız yoğunsa, müsaitlik durumunu ara ara kendimiz kontrol etmemiz gerekiyor, bunun için herhangi bir bildirim göndermiyorlar." Kaynak: https://forum.donanimhaber.com/yemeksepeti-restoran-yogunluk-kontrol-programi-phantomjs--132909481 sahibi: Dh v…
//Code Start
'use strict';
var fs = require('fs');
var content = fs.read('restoran.txt');
//console.log('read data:', content);
var kontrol=false;
var page = require('webpage').create();
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36';
@mahmut-gundogdu
mahmut-gundogdu / QueryableExtensions
Created December 23, 2017 10:38
abp boilerplate deki QueryableExtensions.cs dosyasına orderby if eklenmiş hali. kısaca kodun işlevi verilen şart geçerli ise where kosulunu queryable ekliyor.
using System;
using System.Linq;
using System.Linq.Expressions;
using System.ServiceModel.Channels;
namespace KYGM.Framework.Core.Utilities.Helpers
{
/// <summary>
/// Some useful extension methods for <see cref="IQueryable{T}"/>.
/// </summary>
@mahmut-gundogdu
mahmut-gundogdu / ILogService
Last active December 1, 2017 11:25
Log kütüpanesi soyutlama için bir örnek.
using System;
namespace KYGM.Web.UI.Infrastructure
{
//Kaynak: https://blog.tonysneed.com/2011/10/09/using-nlog-with-dependency-injection/
//Amaç: Decouple from logger framework
public interface ILogService
{
bool IsDebugEnabled { get; }
bool IsErrorEnabled { get; }
@mahmut-gundogdu
mahmut-gundogdu / Create.cshtml
Last active September 21, 2017 10:50
Editorfor için default cssClass ataması ve ek property verip aynı zamanda üstviewden parametre gönderebilmeye örnek.
<!-- Kullanıma Örnek -->
@Html.EditorFor(model => model.StartDate, "Datetime", new { @params = new { ng_model = "vm.startDate" } })
@mahmut-gundogdu
mahmut-gundogdu / javascript.js
Created September 12, 2017 08:27
asp.net mvc de form içerisinde form açamıyoruz. bazen gerekiyor. Bu kod url verilen html getirip içerisindeki formu ajax ile ele almayı(handle) sağlıyor
function getDataFromPartialbyAjax(url, mainPanel, callbackFn) {
function getModalData(response) {
if (response.data != undefined) {
//it is json
callbackFn(response.data);
mainPanel.empty();
} else {
//it is html
mainPanel.html(response);
@mahmut-gundogdu
mahmut-gundogdu / IBussinessExtension.cs
Last active August 9, 2017 12:19
iki listedeyi senkron etme. var olanı güncelle , olmayanı sil, yeni olanı ekle. source : https://stackoverflow.com/a/24643014/3928982
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using AutoMapper;
using KYGM.Framework.Core.Abstracts.BusinessLayer;
namespace KYGM.Web.UI.Helper
{
public static class IBusinessExtension