Skip to content

Instantly share code, notes, and snippets.

View aozisik's full-sized avatar

Ahmet Özışık aozisik

View GitHub Profile
@aozisik
aozisik / macos-mojave-php72-v8js.sh
Last active June 14, 2023 12:28
Installing PHP v8js on Ubuntu 18.04 Bionic or Mac OS Mojave (brew)
# This will retrieve v8 7.4.288.25 when installled
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/0a6171330678879285f2c566db9349da421d6f62/Formula/v8.rb
brew install v8.rb
brew list v8
# You will see this:
# /usr/local/Cellar/v8/7.4.288.25/bin/d8
# /usr/local/Cellar/v8/7.4.288.25/libexec/include/ (21 files)
# /usr/local/Cellar/v8/7.4.288.25/libexec/ (7 files)
@aozisik
aozisik / HasMoneyFields.php
Created February 14, 2018 20:22
If you are using moneyphp in Laravel, you may find this trait useful for your Eloquent models.
<?php
namespace App\Concerns;
use Money\Money;
use Money\Currency;
trait HasMoneyFields
{
public function getAttributeValue($key)
{
@aozisik
aozisik / CountryTableSeeder.php
Created July 10, 2015 11:14
Country Table Seeder for Laravel
<?php
use Illuminate\Database\Seeder;
class CountryTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
@aozisik
aozisik / ideal_text_color.js
Last active August 29, 2015 14:15
Ideal Text Color
/*
* Finds the ideal text color for legibility on the background color provided
* Example i/o: idealTextColor('#000000') -> #ffffff
*/
function idealTextColor(background) {
var r = background.substring(1, 3);
var g = background.substring(3, 5);
var b = background.substring(5, 7);
@aozisik
aozisik / slugify.js
Created July 8, 2014 10:14
Slugify Javascript Function
// creates valid slugs from strings. replaces turkish characters correctly.
function slugify(string) {
var letters = { "İ":"i", "I":"i", "ı":"i", "Ş":"s", "ş":"s", "Ğ":"g", "ğ":"g", "Ü":"u", "ü":"u", "Ö":"o", "ö":"o", "Ç":"c", "ç":"c" };
string = string.replace(/[İIıŞşĞğÜüÇçÖö]/g, function(letter){ return letters[letter]; })
.toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -