Skip to content

Instantly share code, notes, and snippets.

View janbaykara's full-sized avatar
Fighting the general election of everyday life

Jan Baykara janbaykara

Fighting the general election of everyday life
View GitHub Profile
@janbaykara
janbaykara / Cookie.js
Last active August 29, 2015 14:13
LIB / COOKIE
@janbaykara
janbaykara / stickyElement.js
Last active August 29, 2015 14:13
LIB / JQUERY STICKY_ELEMENT
/* {
$element: $("selector"),
sidebarInitY: 0,
parentH: 0,
containerH: 0,
containerY: 0,
headerHeight: 0,
newHeight: 0
} */
var stickyScroller = function (config) {
@janbaykara
janbaykara / .htaccess
Last active August 29, 2015 14:14
Simple error page
ErrorDocument 400 /errors.php
ErrorDocument 401 /errors.php
ErrorDocument 402 /errors.php
ErrorDocument 403 /errors.php
ErrorDocument 404 /errors.php
ErrorDocument 500 /errors.php
@janbaykara
janbaykara / CanvasFont.js
Created January 31, 2015 23:37
Simple middle-man class for manipulating the HTML5 Canvas font property
function CanvasFont(obj) {
this.weight = obj.weight || 400;
this.size = obj.size || "12px";
this.family = obj.family.name || "sans-serif";
this.fallback = obj.fallback; // array
}
CanvasFont.prototype.set = function(obj) {
for(var prop in obj) { this[prop] = obj[prop]; }
}
CanvasFont.prototype.toString = function() {
@janbaykara
janbaykara / popup.js
Created March 14, 2015 20:05
Little function create a plain, centered popup window.
/*
// Usage
var w = popupWindow("","_blank",400,600);
w.document.write(html);
var retrieveData = w.opener.data;
w.close();
*/
function popupWindow(url, title, w, h) {
var left = (screen.width/2)-(w/2);
@janbaykara
janbaykara / Chrome.storage.js
Created April 13, 2015 10:43
A little class for syncing and accessing chrome.sync() data functionally.
// Class for simultaneously pushing/retrieving from foreign chrome.sync and local object.
var Storage = function() {
this.set = function(property,value,cb) {
this[property] = value
chrome.storage.sync.set(
{property: value},
function sentToStorage(storage) {
console.log("Set new "+property+" = "+value)
if(typeof cb === 'function') cb()
}
@janbaykara
janbaykara / socialSharing.js
Last active August 29, 2015 14:20
Facebook/twitter sharing popup functions
/* // USAGE
tweetIntent({
url: window.location.href,
text: "Some message"
related: "OptionalAdvertisedTwitterUser"
})
facebookShare({
url: window.location.href,
function strToHSL(input) {
return intToHSL(getHashCode(input));
function intToHSL(int) {
var shortened = int % 360;
return "hsla(" + shortened + ",70%,40%,0.4)";
};
function getHashCode(str) {
var hash = 0;
@janbaykara
janbaykara / Piranhas.js
Last active October 8, 2018 10:39
Organise batch operations on an array by Web Workers, in conjunction with workerize-loader (or any other promise-ified Web Worker implementation!)
/**
* Handles multithread processing on an array through promise-ified Web Workers
* (through workerize-loader https://github.com/developit/workerize-loader)
*
* @example
* const piranhas = new Piranhas(
* Worker,
* // Listens for messages from workers
* e => { e.data.type === 'INCREMENT' && someIncrementer() }
* )
@janbaykara
janbaykara / cloudSettings
Last active March 12, 2020 16:14
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-03-12T16:14:34.251Z","extensionVersion":"v3.4.3"}