Skip to content

Instantly share code, notes, and snippets.

View malipetek's full-sized avatar
🏠
Working from home

muhammet ali petek malipetek

🏠
Working from home
View GitHub Profile
@MartinMuzatko
MartinMuzatko / config.js
Last active April 27, 2024 05:31
Vuepress open graph metadata
let ogprefix = 'og: http://ogp.me/ns#'
let title = 'Wire Up Your Front-End'
let description = 'Get your personal guide to finally piece together the missing puzzles to communicate with your server'
let color = '#f42525'
let author = 'Martin Muzatko'
module.exports = {
title,
description,
serviceWorker: true,
@basselin
basselin / escapeSelector.js
Last active October 29, 2020 23:43
escapeSelector.js
// https://code.jquery.com/jquery-3.3.1.js
var escapeSelector = function(sel) { // $.escapeSelector()
var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g;
var fcssescape = function(ch, asCodePoint) {
if (asCodePoint) {
// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
if (ch === "\0") {
return "\uFFFD";
}
// Control characters and (dependent upon position) numbers get escaped as code points
@bmodena
bmodena / shopify-clearcart.js
Last active September 21, 2022 19:19
Shopify Clear Cart Cookie on logout
/*
@require
Jquery: https://jquery.com/
*/
function delete_cookie(name) {
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
// logout link
@timdown
timdown / trim_canvas.js
Created July 26, 2017 16:15
Returns a copy of a canvas element with surrounding transparent space removed
var trimCanvas = (function() {
function rowBlank(imageData, width, y) {
for (var x = 0; x < width; ++x) {
if (imageData.data[y * width * 4 + x * 4 + 3] !== 0) return false;
}
return true;
}
function columnBlank(imageData, width, x, top, bottom) {
for (var y = top; y < bottom; ++y) {
@jkoelker
jkoelker / gist:1d7fa2d85ca342998ff7948268379102
Last active December 12, 2019 17:32
Gmail Message Dark
/*Message Background*/ .Bk, .Bu {
background: #111 !important;
}
/*Message Background*/ .Bk {
background: #111 !important;
}
.kQ .Bk .G2 {
background: #111 !important;
@chriscoyier
chriscoyier / index.html
Created September 23, 2015 18:21
Difference Between Inline SVG reference and External reference
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.icon {
width: 100px;
height: 100px;
}
@tyteen4a03
tyteen4a03 / gist:3420a9e121d13b091343
Last active November 13, 2022 14:35
Shopify handleize function in JavaScript
// from https://github.com/Shopify/liquid/blob/63eb1aac69a31d97e343822b973b3a51941c8ac2/performance/shopify/shop_filter.rb#L100
Shopify.handleize = function (str) {
str = str.toLowerCase();
var toReplace = ['"', "'", "\\", "(", ")", "[", "]"];
// For the old browsers
for (var i = 0; i < toReplace.length; ++i) {
str = str.replace(toReplace[i], "");
}
@heycarsten
heycarsten / bounce.js
Created August 29, 2012 03:21
Underscore's debounce and limit as Function prototypes.
// These are yoinked from Underscore.js but are added to the function prototype
// so that we can ruin the world.
(function() {
var debounce, throttle;
debounce = function(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};
@remy
remy / trim-canvas.js
Last active June 21, 2024 09:07
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,