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
@malipetek
malipetek / get_parenthesis_containing_a_word.regexp
Last active February 14, 2018 05:54
Get parenthesis and inside content if it contains a word inside.
/(\(.*some_word_here.*[\)]*)\)/gi
function cloneCvsToImg(cvs, img){
cvs.toBlob(function(blob){
img.src = URL.createObjectURL(blob);
}, 'png');
}
@malipetek
malipetek / plswait.js
Created July 21, 2018 08:39
jQuery pls wait
$.fn.plswait = function(command, arg1){
this.each(function(){
function loadingBtnOverlay(el) {
this.element = $(el);
this.overlay = null;
return this;
}
loadingBtnOverlay.prototype.start = function (btn){
if(!$('body > #sclupndown-anim').is('*')){
@malipetek
malipetek / osym_anahtar_indir.js
Created July 30, 2018 13:55
ÖSYM KPSS cevap anahtarı indirme
// OSYM aday girişi yaptıktan sonra başvurularım-> temel kitapçık görüntüle sayfasında yürütmeniz gerek.
// Bunu konsola kopyalayıp yapıştırabilirsiniz ya da snippet olarak kaydedip yürütebilirsiniz
/*!
* html2canvas 1.0.0-alpha.12 <https://html2canvas.hertzen.com>
* Copyright (c) 2018 Niklas von Hertzen <https://hertzen.com>
* Released under MIT License
*/
!function(A,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.html2canvas=e():A.html2canvas=e()}(this,function(){return function(A){var e={};function t(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return A[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=A,t.c=e,t.d=function(A,e,r){t.o(A,e)||Object.defineProperty(A,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(A){var e=A&&A.__esModule?function(){return A.default}:function(){return A};return t.d(e,"a",e),e},t.o=function(A,e){return Object.prototype.hasOwnProp
// just give me a array
function arrayify(htmlcollection){
var arr = [];
for(var i=0; i<htmlcollection.length; i++){
arr.push(htmlcollection[i]);
}
return arr;
}
@malipetek
malipetek / oneByOne.js
Created December 22, 2018 22:13
sequentially do something and wait if there is a promise to wait
Array.prototype.oneByOne = function(action){
var arr = this;
return new Promise(function(resolve, reject){
var results = [];
var act = function (i) {
// action expexted to return a promise but otherwise should still work
var actionResult = action.call(arr[i], arr[i], i);
if(!actionResult || actionResult.constructor != Promise){
actionResult = new Promise(function (res, rej){
res(actionResult);
@malipetek
malipetek / toDataURLwithLimit.js
Last active January 2, 2019 04:01
export canvas after shrinking to a size
/**
* @param {!HTMLCanvasElement} canvas
* @param {!Number|('b'|'kb'|'mb'|'gb')} targetSize
* @param {?{type: ('image/png'|'image/jpeg'), jpegQuality: Number, shrinkPercentOfOriginal: Number}} options
*/
function toDataURLwithLimit(canvas, targetSize, options){
options = options || {};
options.type = options.type || 'image/jpeg';
options.jpegQuality = options.jpegQuality || .75;
options.shrinkPercentOfOriginal = options.shrinkPercentOfOriginal || 10;
@malipetek
malipetek / beeline_replica.js
Created January 9, 2019 19:55
Beeline replicator. *this may be working only in chrome.
var d = document.createElement('div')
d.innerHTML += `
<style>
.grdnt {
-webkit-text-fill-color: transparent;
background: -webkit-gradient(linear, left top, right bottom, from(#26BDA6), to(#FF5722));
-webkit-background-clip: text;
background-size: 100% 1.5em;
}
</style>`
@malipetek
malipetek / svg_transform_fix.js
Last active March 26, 2019 12:43
Fix By Ikaros
function transformSVGPath(pathStr) {
const DIGIT_0 = 48, DIGIT_9 = 57, COMMA = 44, SPACE = 32, PERIOD = 46,
MINUS = 45;
const DEGS_TO_RADS = Math.PI/180.0;
var path = new THREE.Shape();
var idx = 1, len = pathStr.length, activeCmd,
x = 0, y = 0, nx = 0, ny = 0, firstX = null, firstY = null,