Skip to content

Instantly share code, notes, and snippets.

View magicznyleszek's full-sized avatar
🤦‍♂️
Watching my hand

Leszek Pietrzak magicznyleszek

🤦‍♂️
Watching my hand
View GitHub Profile
<?php
function obrazki($tag) {
$dir = './images/foto';
if (is_dir($dir)) {
if ($dir_open = opendir($dir)) {
while ($file = readdir($dir_open)) {
if ($file == "." || $file == "..") continue;
$file_tag = substr($file,0,strlen($file)-7);
if ($file_tag == $tag) $tab[] = $file;
}
@magicznyleszek
magicznyleszek / shuffle-fisher-yates.js
Last active August 29, 2015 14:02
Fisher-Yates shuffle algorithm
// Fisher-Yates shuffle algorithm: http://bost.ocks.org/mike/shuffle/
function shuffle(array) {
var m = array.length, t, i;
// while there remain elements to shuffle
while (m) {
// pick a remaining element
i = Math.floor(Math.random() * m--);
// and swap it with the current element
t = array[m];
array[m] = array[i];
@magicznyleszek
magicznyleszek / human-emotions.md
Last active August 29, 2015 14:02
Human emotions -- scientific categorization

Human emotions

Scientific categorization with basic descriptions

HUMAINE

HUMAINE proposal for EARL (Emotion Annotationand Representation Language)

  • Negative and forceful
@magicznyleszek
magicznyleszek / random-non-overlapping-position.js
Last active April 11, 2022 21:37
JavaScript -- get random non-overlapping position
// declarations
var positions = [];
// Returns a random integer between min (included) and max (excluded)
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
// generate random positions
@magicznyleszek
magicznyleszek / ntc.js
Created July 31, 2014 09:19
Name that Color by Chirag Mehta
/*
+-----------------------------------------------------------------+
| Created by Chirag Mehta - http://chir.ag/projects/ntc |
|-----------------------------------------------------------------|
| ntc js (Name that Color JavaScript) |
+-----------------------------------------------------------------+
All the functions, code, lists etc. have been written specifically
for the Name that Color JavaScript by Chirag Mehta unless otherwise
@magicznyleszek
magicznyleszek / free-safe-mail.md
Created August 12, 2014 09:39
Free safe mail providers

Free safe mail providers

It hides your computer IP in the email headers, SSL connection, virtual keyboard to thwart keyloggers when you access your email in public computers, and a pledge to erase all connection logs after 3 months. Their servers are located in the Netherlands.

@magicznyleszek
magicznyleszek / multiply-blending-mode-to-png.md
Created August 20, 2014 11:27
Multiply blending mode to PNG in Photoshop
  1. copy your image (Ctrl+A and Ctrl+C)
  2. make a new document-sized pure-black layer behind it
  3. group the black layer and yor image together
  4. add mask to the group
  5. enter mask edit mode (alt+click on the mask icon/thumbnail)
  6. paste your image in the mask (b/w) and then invert it.
  7. save it as a 24-bit transparent PNG
@magicznyleszek
magicznyleszek / comprowssor.html
Last active August 29, 2015 14:06
Comprowssor
<table data-comprowssor>
<caption>Middle Jurassic sections</caption>
<thead>
<tr>
<th>Name</th>
<th>Period <small>[Mya]</small></th>
<th>Duration <small>[My]</small></th>
<th>Species</th>
</tr>
</thead>
@magicznyleszek
magicznyleszek / hex-to-rgb.js
Last active August 22, 2022 11:42
Hex to RGB
function hexToRgb(hex) {
// Expand shorthand form ("#FFF") to full form ("#FFFFF")
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
// return hex values
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),