Skip to content

Instantly share code, notes, and snippets.

View alpercitak's full-sized avatar

Alper Çıtak alpercitak

  • Amsterdam, Netherlands
View GitHub Profile
@alpercitak
alpercitak / init.sh
Last active June 2, 2022 13:47
init code style packages
#!/bin/sh
while getopts f flag; do
case "${flag}" in
f) force='true';;
esac
done
gitignoreFile=".gitignore"
@alpercitak
alpercitak / test.js
Created March 6, 2022 16:18
intercept function - call another function with original result & parameters
const add = (key, fn) => {
fn = (() => {
let original_fn = fn;
return (...params) => {
const original_result = original_fn.apply(this, params);
return another_func(...original_result);
};
})();
};
var db = require('./db'),
util = require('util'),
max = 2;
var ormify = function (o, base) {
if (!o) return {};
var r = {};
var traverse = function (t, arr) {
if (arr.length == 1) return;
var s = arr[0];
var Promise = require('bluebird'),
mysql = require('mysql'),
using = Promise.using;
Promise.promisifyAll(require("mysql/lib/Connection").prototype);
Promise.promisifyAll(require("mysql/lib/Pool").prototype);
var env = (process.env.NODE_ENV == 'production') ? 'prod': 'dev';
var pools = {};
var base = {
@alpercitak
alpercitak / gist:0862b3926b370197a019
Created March 25, 2015 09:51
angularjs lazy image loading directive
var module = angular.module('ng-lazy', []);
module.directive("ngLazy", function() {
return {
link : function(scope, element, attrs) {
var img, loadImage;
img = null;
loadImage = function() {
element[0].src = attrs.ngLazyPlaceholder;
img = new Image();
img.src = attrs.ngLazy;
@alpercitak
alpercitak / gist:21579538220cca80e51c
Last active August 29, 2015 14:17
angularjs infinite scroll directive
var mod = angular.module('ng-infinite', []);
mod.directive('ngInfinite', [ '$window', '$timeout', function($window, $timeout) {
return {
link : function(scope, elem, attrs) {
scope.$on('$destroy', function() {
return container.off('scroll', handler);
});
var calculate = function() {
var body = $('body');
var clientHeight = document.documentElement.clientHeight;