Skip to content

Instantly share code, notes, and snippets.

@oriadam
oriadam / colorValues.js
Last active February 9, 2024 16:01
javascript convert any color to array of rgba values
// return array of [r,g,b,a] from any valid color. if failed returns undefined
function colorValues(color)
{
if (!color)
return;
if (color.toLowerCase() === 'transparent')
return [0, 0, 0, 0];
if (color[0] === '#')
{
if (color.length < 7)
@oriadam
oriadam / coda.rtl.user.js
Last active April 25, 2022 15:41
support rtl in coda
// ==UserScript==
// @name support rtl in coda
// @namespace http://tampermonkey.net/
// @version 8
// @author Oria
// @match https://coda.io/*
// @grant GM_addStyle
// ==/UserScript==
(function() {
@oriadam
oriadam / GetZipErrMessage.php
Last active March 16, 2022 09:22
ZipArchive error code to string
function GetZipErrMessage($errno)
{
if ($errno===true) return '';
switch($errno)
{
case 0: return 'No error'; //ZIP_ER_OK
case 1: return 'Multi-disk zip archives not supported'; //ZIP_ER_MULTIDISK
case 2: return 'Renaming temporary file failed'; //ZIP_ER_RENAME
case 3: return 'Closing zip archive failed'; //ZIP_ER_CLOSE
case 4: return 'Seek error'; //ZIP_ER_SEEK
@oriadam
oriadam / hdmi_audio.desktop
Created February 19, 2022 18:20
linux mint set audio output to hdmi
[Desktop Entry]
Version=1.0
Type=Application
Name=hdmi audio
Comment=
Exec=pactl set-card-profile 0 output:hdmi-stereo
Icon=
Path=
Terminal=false
StartupNotify=false
@oriadam
oriadam / isAssocArrayBench.php
Last active May 19, 2021 10:43 — forked from Thinkscape/isAssocArrayBench.php
A benchmark of several methods for checking if PHP array is associative
<?php
$iterations = $argv[1] ?: 10000;
/**
* Arrays to check
*/
$tests = array(
array(array(
'foo' => 'bar',
)),
array(array(
@oriadam
oriadam / exercise item list.txt
Last active February 11, 2021 13:27
simple PHP mission
1. create a mysql db with the following tables:
items
item_id name category_id
categories
category_id name
2. add some initial categories and items.
3. create an html page that displays the items grouped by category (any interpretation is fine).
4. add a way to add new items. the item should also be added to the page instantly (ajax/SPA).
@oriadam
oriadam / tremp.user.js
Last active May 9, 2020 16:24
tremp tel hai user script
// ==UserScript==
// @name לוח טרמפים בלי חפשנים
// @namespace https://www.facebook.com
// @version 3
// @author You
// @match https://www.facebook.com/groups/198031415602/*
// @grant unsafeWindow
// @updateURL http://softov.org/tremp.user.js
// @downloadURL http://softov.org/tremp.user.js
// ==/UserScript==
picture codenames:
https://codenames.dport.me/
enter this url below
https://gist.github.com/oriadam/3b77af6f9c5e941f9586b0ff0e698acd/raw/b4a75b0ce6597ee0eef63ee68b730525e596f79f/links-to-images.txt
go to options and set 'strech' off, 'expand' on
word codenames:
https://www.horsepaste.com
turn off the english dictionary then turn on the hebrew one
@oriadam
oriadam / onandnow.jquery.js
Created October 20, 2019 16:24
add jQuery functionality `onAndNow` to add event listener and execute it once.
// call the handler now and on events
jQuery.fn.extend({
onAndNow: function(events, func) {
// TODO: Support the data object
return this.each(func).on(events, func);
}
});