Skip to content

Instantly share code, notes, and snippets.

View Driptap's full-sized avatar

Sinan Güçlü Driptap

View GitHub Profile
@Driptap
Driptap / package.json
Last active July 25, 2018 09:48
Simple stylus plugin that uses Staticfy replace paths to replace static asset paths in compiled css
{
"name": "stylus-staticify",
"version": "0.1.0",
"main": "stylus-staticify.js",
"peerDependencies": {
"staticify": "^3.0.0",
}
}
{
"name": "sequlize_user_model",
"version": "0.1.0",
"main": "sequlize_user_model.js"
}
@Driptap
Driptap / Node.js CORS
Created June 13, 2018 01:56 — forked from nilcolor/Node.js CORS
Node.js cross-origin POST. You should response for OPTIONS request first. Something like this.
if (req.method === 'OPTIONS') {
console.log('!OPTIONS');
var headers = {};
// IE8 does not allow domains to be specified, just the *
// headers["Access-Control-Allow-Origin"] = req.headers.origin;
headers["Access-Control-Allow-Origin"] = "*";
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
headers["Access-Control-Allow-Credentials"] = false;
headers["Access-Control-Max-Age"] = '86400'; // 24 hours
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept";
@Driptap
Driptap / test_helpers.js
Created May 22, 2018 08:59
Faker.js and Rosie.js helpers
const randomIntBetween = (min, max, string = false) => {
let int = Faker.random.number() % max + min;
return string ? String(int) : int;
};
@Driptap
Driptap / Iterator prototype extensions
Last active March 21, 2018 16:52
Inspired by rails
Object.defineProperty(Array.prototype, 'findAll', {
enumerable: false,
writable: false,
value: condition => this.reduce((col, el, i) =>
condition(el, i, this) ? [...col, el] : col, [])
});
Object.defineProperty(Array.prototype, 'exists', {
enumerable: false,
writable: false,
@Driptap
Driptap / index.html
Created March 3, 2018 14:00
Serving templates from static files
<html>
<head>
<script src="/rendered_statics/script.js"></script>
</head>
<body>
</body>
</html>
import pdb; pdb.set_trace()
import ipdb; ipdb.set_trace()
@Driptap
Driptap / spider.html
Created June 2, 2017 14:36
Spider thing
<html>
<head>
</head>
<body style="background: black; position: fixed; top:0; left:0; right: 0; bottom: 0;">
<canvas id='demo-canvas'></canvas>
<div id='large-header'></div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenLite.min.js" integrity="sha256-Y7X151r2Tk9/N3WcxW1qQn/phEPJ9mY8uOxqaI4AWW4=" crossorigin="anonymous"></script>
@Driptap
Driptap / deep_clone.js
Last active April 13, 2020 11:24
ES6 Implementation of lodash's cloneDeep function using underscore
/**
* Creates a deep clone of an object using underscore.
*/
import {clone, each, isObject} from 'underscore';
const deepClone = (_obj) => {
let _clone = clone(_obj);
each(_clone, (_val, _key) => {
if (isObject(_val))
@Driptap
Driptap / web_workers.js
Last active December 15, 2016 23:10
Simple web workers
var App = App || {};
/* ===================================== WEB WORKERS LISTENER ========================*/
App.workers = function(options) {
"use strict";
var that = {},
_storage = localStorage,
_storedConfig = _storage.getItem('workers_config'),
_config = (_storedConfig) ? _storedConfig : {