Skip to content

Instantly share code, notes, and snippets.

🚁
Latam po mieście

Piotr Kowalski piecioshka

🚁
Latam po mieście
Block or report user

Report or block piecioshka

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@piecioshka
piecioshka / snippet.js
Last active Mar 11, 2019
[empty objects] #JavaScript
View snippet.js
/**
* TEST DATA
*/
var testData = [{}, {a:1}, new RegExp(), [], Object.create(null), [undefined]];
/**
* Check if param is Object?
* @param {*} o Checks value.
* @return {boolean}
*/
@piecioshka
piecioshka / getPeriod.js
Last active Mar 11, 2019
[periodic time]
View getPeriod.js
function getPeriod(period) {
var number, letter, letters, time;
if (typeof period !== "string") {
throw new Error("sorry, only string is correct, not " + typeof period);
}
/**
* Parse number from period.
* @type {number}
@piecioshka
piecioshka / undefined.js
Last active Dec 22, 2015
undefined is the same as undefined?
View undefined.js
// 1) simple check
console.log(undefined === undefined); // true
// 2) check undefined param in function
(function (undef) {
console.log(undef === undefined); // true
}());
// 3) unexists property
(function (obj) {
@piecioshka
piecioshka / getTextWidth.js
Last active Mar 11, 2019
[get text long in pxs] Uses canvas.measureText to compute and return the width of the given text of given font in pixels #Canvas
View getTextWidth.js
/**
* Uses canvas.measureText to compute and return the width of the given text of given font in pixels.
*
* @param {String} text The text to be rendered.
* @param {String} font The css font descriptor that text is to be rendered with (e.g. "bold 14px verdana").
*
* @see http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
*/
function getTextWidth(text, font) {
// if given, use cached canvas for better performance
@piecioshka
piecioshka / statuses.log
Last active Mar 11, 2019
Projects statuses
View statuses.log
REC - Recommendation
PR - Proposed Recommendation
CR - Candidate Recommendation
WD - Working Draft
ED - Editor's Draft
WIP - Worki In Progress
@piecioshka
piecioshka / snippet.js
Last active Mar 11, 2019
Shim for jQuery.not() #jQuery
View snippet.js
const element = $('.file-box:nth-child(2)')
const list = $$('.file-box')
function not($list, element) {
const list = Array.from($list);
const index = list.indexOf(element);
return list.slice(index);
}
Array.from(not(list, element))
@piecioshka
piecioshka / schema.json
Last active May 29, 2019
[schema: products]
View schema.json
{
"id": "products",
"type": "object",
"required": ["products"],
"properties": {
"products": {
"type": "array",
"minItems": 50,
"items": {
"type": "object",
@piecioshka
piecioshka / schema.json
Last active Jun 22, 2019
[schema: photos]
View schema.json
{
"id": "photos",
"type": "object",
"required": [
"photos"
],
"properties": {
"photos": {
"type": "array",
"minItems": 20,
@piecioshka
piecioshka / snippet.bash
Created Mar 11, 2019
[number of max processes]
View snippet.bash
# max user processes — linux, macos
ulimit -a
# max system processes — linux
cat /proc/sys/kernel/pid_max
View posts.schema.json
{
"id": "posts",
"type": "object",
"required": [
"posts"
],
"properties": {
"posts": {
"type": "array",
"minItems": 5,
You can’t perform that action at this time.