Skip to content

Instantly share code, notes, and snippets.

View stevenselcuk's full-sized avatar
🦷
Un-teething now

Steven J. Selcuk stevenselcuk

🦷
Un-teething now
View GitHub Profile
@stevenselcuk
stevenselcuk / add-humantime.php
Created February 26, 2019 13:45
WordPress Filters & Some Functions etc.
/**
* Displays posts date modifing with human time.
*
* It looks like ( 22 hours ago ) or ( 7 years ago )
*
* @method yourprefix_get_humantime()
*
* @link https://codex.wordpress.org/Function_Reference/human_time_diff
*
* @uses human_time_diff()
@stevenselcuk
stevenselcuk / de_register-styling.php
Created February 27, 2019 14:47
De-Register a goddamn Styling file from enqueue (WordPress)
function de-reg-style() {
wp_dequeue_style('style-id-is-here');
wp_deregister_style('style-id-is-here');
}
add_action('wp_enqueue_scripts','de-reg-style');
@stevenselcuk
stevenselcuk / validate.js
Created November 5, 2019 18:33
Phone number validation
export function formatPhone(phone) {
const phoneWithoutSpaces = phone.replace(/ /g, '')
let finalPhone = ''
const offset = phoneWithoutSpaces.slice(0, 1) === '+' ? [3, 4, 8] : [1, 5]
for (const index in phoneWithoutSpaces) {
if (offset.includes(parseInt(index))) {
finalPhone = finalPhone.concat(' ')
}
finalPhone = finalPhone.concat(phoneWithoutSpaces[parseInt(index)])
}
@stevenselcuk
stevenselcuk / localStorage.js
Created December 21, 2019 19:19
Local Storage Util/Helper
const localStorage = window.localStorage;
export function set(key, value) {
value = JSON.stringify(value);
try {
localStorage.setItem(key, value);
} catch (e) {
console.log(e);
}
[
{
"aircraft_name": "Cessna 172",
"display_name": "C172",
"make": "Cessna",
"model": "172",
"year": "1972",
"json_url": "https://gist.githubusercontent.com/stevenselcuk/8a3841e09ac79f856ff2cc12bf3e159c/raw/584131656507a2ef0b1a8743ae69af11448d3211/master.json",
},
{
@stevenselcuk
stevenselcuk / anlatbakalim.json
Last active May 10, 2020 17:52
Anlat bakalım
[
{
"word_id": 23,
"word": "palamut",
"forbidden_words": [
"balık",
"deniz",
"olta"
]
},
@stevenselcuk
stevenselcuk / Localization Support with i18n
Created June 15, 2020 20:06
Snippet for React & React Native localization support
import i18n from 'i18next';
import {initReactI18next} from 'react-i18next';
import {NativeModules} from 'react-native';
import {Platform} from 'react-native';
import resources from '../translations';
function localeToLanguage(locale) {
return locale.replace('_', '-');
}
import React from 'react'
import { Table, Input, Button, Popconfirm, Form } from 'antd';
const EditableContext = React.createContext();
const EditableRow = ({ form, index, ...props }) => (
<EditableContext.Provider value={form}>
<tr {...props} />
</EditableContext.Provider>
);
@stevenselcuk
stevenselcuk / Localization.js
Created June 16, 2020 19:55
Localization Page
import React, { useEffect, useState, useCallback } from 'react';
import { connect } from 'react-redux';
import { useSelector, useDispatch } from 'react-redux';
import { Table, Input, Button, Popconfirm, Form, Modal, Select } from 'antd';
import { createStructuredSelector } from 'reselect';
import { makeSelectLocalizationStateSuccessfull } from '../../selectors';
import { setLocalizationState, getLocalizationState } from '../../actions';
import { getLanguageName } from '../../../../utils/languageHelpers';
const EditableContext = React.createContext();
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>
<style name="SplashScreen">
<item name="android:src">@drawable/splash</item>