Skip to content

Instantly share code, notes, and snippets.

View semihkeskindev's full-sized avatar
🎉

Semih keskin semihkeskindev

🎉
View GitHub Profile
@semihkeskindev
semihkeskindev / UserRegistration.php
Last active December 4, 2019 10:35
serialization class
<?php
namespace klass\a;
class UserRegistrationJob implements \JsonSerializable
{
private $name;
private $surname;
public function __construct($name,$surname)
@semihkeskindev
semihkeskindev / array_flatten.php
Created March 16, 2020 19:46 — forked from SeanCannon/array_flatten.php
PHP array_flatten() function. Convert a multi-dimensional array into a single-dimensional array.
<?php
/**
* Convert a multi-dimensional array into a single-dimensional array.
* @author Sean Cannon, LitmusBox.com | seanc@litmusbox.com
* @param array $array The multi-dimensional array.
* @return array
*/
function array_flatten($array) {
if (!is_array($array)) {
@semihkeskindev
semihkeskindev / git_revert.sh
Created April 14, 2020 09:18 — forked from l1x/git_revert.sh
Using git checkout to revert to a certain commit hash
#http://stackoverflow.com/a/6457473/127508
git checkout 56e05fced -- .
git add .
git commit -m 'Revert to 56e05fced'
And to prove that it worked:
git diff 56e05fced
@semihkeskindev
semihkeskindev / import_export_gz.sql
Created April 16, 2020 10:22 — forked from rakeshtembhurne/import_export_gz.sql
MySQL: Import and export in gzip form
// Export database in gzip form
mysqldump -u user -p database | gzip > database.sql.gz
// Import database from gzip form
gunzip < database.sql.gz | mysql -u user -p database
@semihkeskindev
semihkeskindev / round_number_to_any_decimal_place.js
Last active August 10, 2020 15:58
Javascript function for Round to any decimal place
function roundNumber(num, precision = 0) {
let decimalPlace = Math.pow(10, precision);
return Math.round((num + Number.EPSILON) * decimalPlace) / decimalPlace;
}
@semihkeskindev
semihkeskindev / clear_all_values_without_delete_props.js
Last active August 10, 2020 15:58
Clear all values without delete properties in object
function clearAllValues(data, byTypeOf = false) {
let clearValuesTypeOf = {
boolean: false,
number: 0,
string: '',
}
// clear array if data is array
if (Array.isArray(data)) {
@semihkeskindev
semihkeskindev / nginx.conf
Created December 14, 2020 14:39
Nginx remove index.php
if ($request_uri ~ "^(\/)index\.php$") {
return 302 $1;
}
if ($request_uri ~ "^(\/)index\.php\?(.*)") {
return 302 $1?$2;
}
if ($request_uri ~ "^(\/)index\.php\/(.*)") {
return 302 $1$2;
@semihkeskindev
semihkeskindev / tor.sh
Created January 1, 2021 21:41
Tor Proxy Connection for MAC OS X
#!/usr/bin/env bash
# 'Wi-Fi' or 'Ethernet' or 'Display Ethernet'
INTERFACE=Wi-Fi
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@semihkeskindev
semihkeskindev / Html.php
Created March 28, 2021 11:40
HTML Add Style Link tag
<?php
class Html
{
const REL_STYLESHEET = 'stylesheet';
const REL_PRELOAD = 'preload';
/**
* style css link tagı return eder.
*/