Skip to content

Instantly share code, notes, and snippets.

@hkan
hkan / README.md
Last active August 29, 2015 14:02
Filter Out Empty Strings of Array

Filter Empty Values

Returns a new array without the empty strings.

Usage

var myArray = [ "hakan", "", "0", 0, false ];

myArray = myArray.filterEmpty();
@hkan
hkan / getDotNotated
Created June 13, 2014 11:15
Object Prototype
Object.defineProperty(Object.prototype, "getDotNotated", {
value: function (dotNotation) {
var arrayOfNames = dotNotation.split('.');
var tmp = this;
for (var i in arrayOfNames) {
if (arrayOfNames.hasOwnProperty(i)) {
tmp = tmp[arrayOfNames[i]];
}
}
@hkan
hkan / setDotNotated
Created June 13, 2014 11:16
Object Prototype
Object.defineProperty(Object.prototype, "setDotNotated", {
value: function (dotNotation, value) {
var arrayOfNames = dotNotation.split('.');
var last = arrayOfNames.pop();
var tmp = this;
for (var i in arrayOfNames) {
if (!arrayOfNames.hasOwnProperty(i))
continue;
@hkan
hkan / remove-dotted-border-from-focus-in-firefox.css
Created November 6, 2015 10:23
Firefox'taki *dotted border* problemini çözen hede
:focus, :active {
outline: 0 !important;
}
@hkan
hkan / composers.php
Last active November 6, 2015 10:24
Reproduce routes for other languages in the application. (Laravel 4)
// I composed them into my layout file
View::composer('layout', function($view)
{
// Current route object
$route = Route::getCurrentRoute();
// Take out first part of route (the locale key)
$routeWithoutLang = implode('.', array_slice(explode('.', $route->getName()), 1));
// You should probably put this in a foreach loop
@hkan
hkan / MigrateAutoCommand.php
Last active December 30, 2015 15:39
Laravel Artisan Auto Migration Command
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class InstallCommand extends Command {
/**
* The console command name.
@hkan
hkan / app__Console__Commands__CheckSessionForNodeSocket.php
Last active May 18, 2016 09:13
Socket.io + Laravel 5.1 (Late edit: This is shit. Do not use. Use JWT instead.)
<?php
namespace App\Console\Commands;
use App\User;
use Illuminate\Console\Command;
class CheckSessionForNodeSocket extends Command
{
/**
@hkan
hkan / SomeComponent.vue
Last active May 18, 2016 09:33
[Socket.io] Define events and connect later at will
<template>
<div class="some-class">
{{ someVariable }}
</div>
</template>
<script>
export default {
data() {
return {
@hkan
hkan / light.css
Last active April 18, 2018 23:11
Light content theme for indiehackers.com
html {
background: #f5f5f5;
}
/* CONTENT PAGE */
.forum .forum-thread {
background: none;
}
@hkan
hkan / macro.php
Last active March 8, 2019 21:06
TestResponse::assertViewHasDeep assertion
<?php
use PHPUnit\Framework\Assert as PHPUnit;
use Illuminate\Support\Arr;
use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Database\Eloquent\Model;
TestResponse::macro('assertViewHasDeep', function ($key, $value = null) {
$this->ensureResponseHasView();