Skip to content

Instantly share code, notes, and snippets.

View simple-async-component-for-react-router.js
##### Async.js
import React, {Component} from 'react';
import PropTypes from 'prop-types';
class Async extends Component {
constructor(props) {
super(props);
this.state = {
loader: true,
@hasangilak
hasangilak / owncloud.nginx,conf
Last active Apr 19, 2018
owncloud nginx conf with no ssl
View owncloud.nginx,conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;
load_module modules/ngx_http_dav_ext_module.so;
events {
worker_connections 2048;
multi_accept on;
View nginx-force-https.conf
server {
listen 443 ssl;
listen 80;
server_name filan.com www.filan.com;
root /var/www/samsung/public;
index index.php index.html index.htm;
if ($http_cf_visitor ~ '{"scheme":"http"}') {
return 301 https://$server_name$request_uri;
}
View nginx-laravel-ssl-default-server
# if using cloudeflare you should activate "full" ssl not "flexible" at all
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name folan.xyz;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl default_server;
View nginx-laravel-wordpress
server {
server_name folan.info www.folan.info;
return 301 https://www.folan.info$request_uri;
}
server {
listen 443 ssl;
server_name www.folan.info;
View raceOnTime.js
import {sync} from "./sync";
import {handleError} from "./catchError";
export function raceOnTime(generator, timeOut) {
return (new Promise((resolve, reject) => {
let _resolve;
const timer = setTimeout(() => {
reject({error: new Error('timeout')});
}, timeOut);
View citrusbyte
var crazyArray = [[1,2,[3]],4];
function flatten(crazyArray, items = []) {
var item;
while(crazyArray.length != 0){
item = crazyArray.pop();
if(Array.isArray(item)) {
flatten(item, items);
} else {
items.push(item);
View sync-generator-promises.js
function resolvePromise(promise, iterator) {
promise.then(
(response) => {
let result = iterator.next(response);
if (!result.done) {
sync(result.value, iterator);
}
},
error => {
let result = iterator.next(error);
@hasangilak
hasangilak / cloudflare-add-subdomain-client
Last active Jan 27, 2017
a php cloudflare client for adding subdomain. depends on guzzle >= v6
View cloudflare-add-subdomain-client
<?php
namespace App\Services\CloudFlare;
use GuzzleHttp\Client;
class CloudFlareClient
{
private $email;
private $key;
@hasangilak
hasangilak / master-and-slave.js
Created Oct 30, 2016
I want one master action to complete its job asynchronously and at the end of its job free its slaves so I wrote this tiny library.
View master-and-slave.js
let master = () => {
return new Promise( (resolve, reject) => {
setTimeout(() => { resolve('ok'); }, 3000);
});
}
let slaves = [
{
start: () => {
console.log("loading")
You can’t perform that action at this time.