Skip to content

Instantly share code, notes, and snippets.

$.each(State.stores, function(e,i) { State.stores[e] = 1000000000; })
OR
var high = 100000
var checkAll = setInterval(function() {
var bn = [
'attack',
'attack_bolas',
'attack_bone-spear',
@tborychowski
tborychowski / global-protect.sh
Created October 16, 2023 12:43 — forked from kaleksandrov/global-protect.sh
Simple script that starts and stops GlobalProtect.app on Mac OSX.
#!/bin/bash
case $# in
0)
echo "Usage: $0 {start|stop}"
exit 1
;;
1)
case $1 in
start)
@tborychowski
tborychowski / get_week_number.js
Created October 11, 2012 14:14
JS :: Get Week Number (ISO 8601)
//Returns ISO 8601 week number and year
Date.prototype.getFullWeek = function(){
var jan1, w, d = new Date(this);
d.setDate(d.getDate()+4-(d.getDay()||7)); // Set to nearest Thursday: current date + 4 - current day number, make Sunday's day number 7
jan1 = new Date(d.getFullYear(),0,1); // Get first day of year
w = Math.ceil((((d-jan1)/86400000)+1)/7); // Calculate full weeks to nearest Thursday
return {y: d.getFullYear(), w: w };
};
//Returns ISO 8601 week number
Date.prototype.getWeek = function(){
@tborychowski
tborychowski / img2datauri
Created November 29, 2021 11:14
JS :: convert image to data url with javascript
console.clear();
var img = new Image();
img.src = 'img/img.png';
img.onload = function () {
var canvas = document.createElement('canvas'), context = canvas.getContext('2d');
canvas.width = img.width;
canvas.height = img.height;
context.drawImage(img, 0, 0, img.width, img.height);
console.log(canvas.toDataURL('image/png'));
@tborychowski
tborychowski / fuzzy.js
Created August 22, 2014 12:51
JS :: fuzzy search
String.prototype.fuzzy = function (s) {
var hay = this.toLowerCase(), i = 0, n = -1, l;
s = s.toLowerCase();
for (; l = s[i++] ;) if (!~(n = hay.indexOf(l, n + 1))) return false;
return true;
};
('a haystack with a needle').fuzzy('hay sucks'); // false
('a haystack with a needle').fuzzy('sack hand'); // true
@tborychowski
tborychowski / utils.js
Last active September 13, 2018 15:53
JS :: Utils - helper library
/**
* https://gist.github.com/tborychowski/3799025
*/
var UTILS = {
/*jshint maxlen: 500, onevar: false */
isTouch : (/iPhone|iPod|iPad/ig).test(navigator.userAgent),
/**
* Modified & lintified version of https://gist.github.com/527683
@tborychowski
tborychowski / animated-dialog.html
Created July 13, 2018 07:33
html dialog with animation
<!DOCTYPE html>
<head>
<meta charset=UTF-8>
<title>Dialog demo</title>
<style>
.dialog {
border: none;
border-radius: 3px;
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
}
@tborychowski
tborychowski / form-validation.html
Last active November 21, 2017 10:10
form-validation.html
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="css/style.css">
<style>
html { height: 100%; }
body {
font-family: sans-serif;
font-weight: 300;
@tborychowski
tborychowski / yt-downloader.user.js
Last active October 7, 2016 12:34
JS :: yt downloader monkey script
// ==UserScript==
// @name Download YouTube Videos as MP4
// @description Adds a button that lets you download YouTube videos.
// @homepageURL https://github.com/gantt/downloadyoutube
// @author Gantt
// @version 1.8.8
// @date 2016-09-02
// @namespace http://googlesystem.blogspot.com
// @include http://www.youtube.com/*
// @include https://www.youtube.com/*
@tborychowski
tborychowski / js-number-format.js
Created October 11, 2013 10:39
JS :: format number as currency
(2500).toLocaleString("en-GB", {style: "currency", currency: "GBP", minimumFractionDigits: 2})