Skip to content

Instantly share code, notes, and snippets.

View ozanmuyes's full-sized avatar

Ozan Müyesseroğlu ozanmuyes

View GitHub Profile
@ozanmuyes
ozanmuyes / mergesort.c
Created October 18, 2014 13:30
Merge Sort
#include <stdio.h>
#include <stdlib.h>
#define LEN 10000
#define INF 30000 /* Larger than all other elements .*/
// Use "$ time ./mergesort" command to measure execution time.
void merge(int *A, int p, int q, int r) {
int i, j, k, n1, n2, *L, *R;
@ozanmuyes
ozanmuyes / hash_table.c
Last active May 2, 2016 03:36 — forked from tonious/hash.c
A quick hashtable implementation in 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
@ozanmuyes
ozanmuyes / Concatenator.js
Last active June 13, 2017 13:05
Concatenator
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
};
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
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!
});
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
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);
}]));
}]));
@ozanmuyes
ozanmuyes / index.js
Last active February 19, 2019 16:04
A proper application code to start the server and a service to connect to the database
// index.js
const http = require('http');
const kernel = require('@rezeus/kernel');
require('./services_database');
kernel.on('error', (err) => {
// TODO Handle error
@ozanmuyes
ozanmuyes / gulpfile.js
Last active October 17, 2019 00:17
gulpfile for Gulp 4 to ease development of website with Twig, SCSS and Babel
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 July 24, 2019 11:48 — forked from jchandra74/openssl.MD
HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

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