Skip to content

Instantly share code, notes, and snippets.

Avatar

Ozan Müyesseroğlu ozanmuyes

View GitHub Profile
@ozanmuyes
ozanmuyes / gulpfile.js
Last active Oct 17, 2019
gulpfile for Gulp 4 to ease development of website with Twig, SCSS and Babel
View gulpfile.js
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const Mem = require('gulp-mem');
const data = require('gulp-data');
const JSON5 = require('json5');
const twig = require('gulp-twig');
const bs = require('browser-sync').create();
const sass = require('gulp-sass');
@ozanmuyes
ozanmuyes / openssl.MD
Created Jul 24, 2019 — forked from jchandra74/openssl.MD
HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window
View openssl.MD

HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

Overview

My main development workstation is a Windows 10 machine, so we'll approach this from that viewpoint.

Recently, Google Chrome started giving me a warning when I open a site that uses https and self-signed certificate on my local development machine due to some SSL certificate issues like the one below:

Self-Signed SSL Issue in Chrome

@ozanmuyes
ozanmuyes / index.js
Last active Feb 19, 2019
A proper application code to start the server and a service to connect to the database
View index.js
// index.js
const http = require('http');
const kernel = require('@rezeus/kernel');
require('./services_database');
kernel.on('error', (err) => {
// TODO Handle error
View korauter_issue_2-1.js
posts.scope('Post', '/:postId', compose([postMiddleware1, postMiddleware2, (post) => {
// get the 'postId' via `ctx.params`
post.get('ViewPost', '/', PostsController.view);
post.scope('Comments', '/comments', compose([postCommentMiddleware1, postCommentMiddleware2, (comments) => {
comments.get('Index', '/', compose([postCommentIndexMW, CommentsController.index]));
// also get the 'commentId' via `ctx.params`
comments.get('View', '/:commentId', CommentsController.view);
}]));
}]));
View mongoose-and-koa-with-ee.js
const EventEmitter = require('events');
const Koa = require('koa');
const mongoose = require('mongoose');
// Excerpted from https://nodejs.org/dist/latest-v8.x/docs/api/events.html#events_events
class MyEmitter extends EventEmitter {}
const myEmitter = new MyEmitter();
// Excerpted from https://mongoosejs.com/docs/index.html
View mongoose-and-koa-2.js
const Koa = require('koa');
const mongoose = require('mongoose');
// Excerpted from https://mongoosejs.com/docs/index.html
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
// we're connected!
app.listen(3000); // Start listening here
View mongoose-and-koa-1.js
const Koa = require('koa');
const mongoose = require('mongoose');
// Excerpted from https://mongoosejs.com/docs/index.html
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
// we're connected!
});
@ozanmuyes
ozanmuyes / install-open.sh
Last active Jun 17, 2017
Mac OSX 'open' equivalent for Debian
View install-open.sh
#!/bin/bash
# echoes '#!/bin/bash xdg-open "$1" &> $HOME/.xdg-open-error &' to /usr/sbin/open
echo -e "\043\041/bin/bash\n\nxdg-open \042\044\061\042 &> $HOME/.xdg-open-error &" > ozanmuyes-open
sudo mv ozanmuyes-open /usr/sbin/open
sudo chmod +x /usr/sbin/open
echo -e "\n# Mac OSX \047open\047 equivalent for Debian\nalias 'open'='/usr/sbin/open'" >> $HOME/.bashrc
. $HOME/.bashrc
View Concatenator.js
const EventEmitter = require('events');
const fs = require('fs');
const path = require('path');
const DEFAULT_OPTIONS = {
chunkSize: 0, // in bytes, may be omitted
filename: '', // only renames the file, will not move - this should be done via `destFilepath`
// `filename` has precedence over `destFilepath`, in other words it renames destination file, if defined
};
@ozanmuyes
ozanmuyes / hash_table.c
Last active May 2, 2016 — forked from tonious/hash.c
A quick hashtable implementation in c.
View hash_table.c
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include "hash_table.h"
// TODO Write necessary function from http://apr.apache.org/docs/apr/1.4/group__apr__hash.html
You can’t perform that action at this time.