Skip to content

Instantly share code, notes, and snippets.

View kafkadev's full-sized avatar
🏠
Working from home

Gokhan Celik kafkadev

🏠
Working from home
View GitHub Profile
@kafkadev
kafkadev / README.md
Created June 18, 2017 19:48 — forked from chrisjacob/README.md
Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Intro

Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Author: Chris Jacob @_chrisjacob

Tutorial (Gist): https://gist.github.com/833223

The Result

<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {
@kafkadev
kafkadev / php_delete_directory.php
Created June 16, 2017 19:44
php delete directory
<?php
function _delete_dir01($path) {
if (!is_dir($path)) {
throw new InvalidArgumentException("$path must be a directory");
}
if (substr($path, strlen($path) - 1, 1) != DIRECTORY_SEPARATOR) {
$path .= DIRECTORY_SEPARATOR;
}
$files = glob($path . '*', GLOB_MARK);
@kafkadev
kafkadev / zip-archive.php
Created June 16, 2017 19:42
php zip archive folder create
<?php
function zip($source, $destination)
{
if (!extension_loaded('zip') || !file_exists($source)) {
return false;
}
$zip = new ZipArchive();
if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
@kafkadev
kafkadev / ImageTools.es6
Created June 15, 2017 20:36 — forked from dcollien/ImageTools.es6
Resize Images in the Browser
let hasBlobConstructor = typeof(Blob) !== 'undefined' && (function () {
try {
return Boolean(new Blob());
} catch (e) {
return false;
}
}());
let hasArrayBufferViewSupport = hasBlobConstructor && typeof(Uint8Array) !== 'undefined' && (function () {
try {
@kafkadev
kafkadev / ngrxintro.md
Created June 15, 2017 11:05 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

import { Component, Input, AfterViewInit } from '@angular/core';
import { NgModel, DefaultValueAccessor, NgControl } from '@angular/forms';
import { Http, Headers, RequestOptions } from '@angular/http';
@Component({
selector: 'app-file-uploader',
template: '<input type="file" (change)="updated($event);">',
providers: [NgModel, DefaultValueAccessor]
})
export class FileUploaderComponent implements AfterViewInit {
@kafkadev
kafkadev / form-group.html
Created June 12, 2017 13:52
Basic Angular Group Form
<form #cfForm="ngForm" (change)="formState(cfForm);">
<fieldset class="content-group" ngModelGroup="body">
<div class="form-group">
<label class="control-label col-lg-2">Kampanya Adı</label>
<div class="col-lg-10">
<input name="name" type="text" class="form-control" placeholder="örn: ayakkabı sezonu" ngModel>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Kampanya Türü</label>
@kafkadev
kafkadev / cors.js
Created June 11, 2017 18:55 — forked from coolaj86/cors.js
CORS / XHR2 middleware for Node.js
/*
Here's some documentation on XMLHttpRequest Level 1 and 2 as per the
standard and as per implementation.
XHR
http://www.w3.org/TR/XMLHttpRequest/
http://developer.apple.com/internet/webcontent/xmlhttpreq.html
http://msdn.microsoft.com/en-us/library/ms535874%28VS.85%29.aspx
XHR2
@kafkadev
kafkadev / cors.js
Created June 11, 2017 18:54 — forked from slav123/cors.js
node.js express - allow CORS
app.use(function(req, res, next) {
var oneof = false;
if(req.headers.origin) {
res.header('Access-Control-Allow-Origin', req.headers.origin);
oneof = true;
}
if(req.headers['access-control-request-method']) {
res.header('Access-Control-Allow-Methods', req.headers['access-control-request-method']);
oneof = true;
}