Skip to content

Instantly share code, notes, and snippets.

View ozanmuyes's full-sized avatar

Ozan Müyesseroğlu ozanmuyes

View GitHub Profile
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 October 21, 2021 14:26
Mac OSX 'open' equivalent for Debian
#!/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
@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
};
@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 / 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;