Skip to content

Instantly share code, notes, and snippets.

View alpenzoo's full-sized avatar

Narcis Iulian Paun alpenzoo

View GitHub Profile
@alpenzoo
alpenzoo / char_lo_up.php
Last active March 6, 2020 08:20
php upper lower for standard en chars
<?php
setlocale(LC_CTYPE, 'de_DE.UTF8');
function myUpper($char){
$lo = ord($char);
$up = $lo & 0x5f;
return $up;
}
function myLower($char){
$up = ord($char);
$lo = $up ^ 0x20;
@alpenzoo
alpenzoo / index.html
Created March 13, 2020 14:48 — forked from agarzon/index.html
My Html5 template with Jquery and Bootstrap from CDN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Project Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
@alpenzoo
alpenzoo / autocomplete-off.html
Created June 4, 2020 14:11
Major browsers and password managers ignore autocomplete=off and do not adhere to the standards. This is an workaround. At the moment it works
<form class="form-horizontal frm--ver-cnp" id="frmConfirmEmail">
<input autocomplete="false" name="hidden" type="text" style="display:none;">
<div id="frmErrorMsg" class="alert alert-danger text-left collapse" role="alert" style="display: none;"><span></span></div>
<div class="form-group row">
<div class="col-sm-12">
<input type="text" class="passInput" name="inputpin[]" maxlength="1" size="1" autocomplete="new-password" min="0" max="9" required="" pattern="\d{1}" autofocus="">
<input type="text" class="passInput" name="inputpin[]" maxlength="1" size="1" autocomplete="new-password" min="0" max="9" required="" pattern="\d{1}">
<input type="text" class="passInput" name="inputpin[]" maxlength="1" size="1" autocomplete="new-password" min="0" max="9" required="" pattern="\d{1}">
<input type="text" class="passInput" name="inputpin[]" maxlength="1" size="1" autocomplete="new-password" min="0" max="9" required="" pattern="\d{1}">
<input type="text" class="
@alpenzoo
alpenzoo / array_find.php
Created November 9, 2020 11:20
php function returns array filtered on multiple attributes values.
<?php
$arr= array(
array("an"=>2, 'fac'=>5000, 'sr'=>45),
array("an"=>4, 'fac'=>5001, 'sr'=>40),
array("an"=>2, 'fac'=>5000, 'sr'=>40),
array("an"=>2, 'fac'=>5001, 'sr'=>45)
);
$cond=array("an"=>2, 'fac'=>5001);
@alpenzoo
alpenzoo / sortMultidimensionalArray.php
Created November 12, 2020 23:23
Sort multidimensional array in PHP.
<?php
function sortMultidimensionalArray($arr, $attr){
// Comparison function
$compareTIME = function ($el1, $el2) use ($attr){
$datetime1 = strtotime($el1[$attr]);
$datetime2 = strtotime($el2[$attr]);
return $datetime1 - $datetime2;
};
@alpenzoo
alpenzoo / detect_interval_overlaps.sql
Last active November 24, 2020 14:54
Detect overlapping intervals generating ranges and usage rating. Contains a bunch of various code found online. Thank you.
WITH
activities AS (
SELECT * FROM (
VALUES
('D', '2018-01-09 11:00:00'::timestamp, '2018-01-09 11:10:00'::timestamp, 1),
('A', '2018-01-09 10:00:00'::timestamp, '2018-01-09 12:00:00'::timestamp, 1),
('X', '2018-01-09 10:05:00'::timestamp, '2018-01-09 10:11:00'::timestamp, 1),
('B', '2018-01-09 14:00:00'::timestamp, '2018-01-09 16:00:00'::timestamp, 1),
('C', '2018-01-09 10:10:00'::timestamp, '2018-01-09 10:30:00'::timestamp, 1)
) AS act ("name", "start", "end", "count")
@alpenzoo
alpenzoo / slugify.sql
Created February 3, 2022 20:30 — forked from ianks/slugify.sql
Generating Slugs in Postgres
CREATE EXTENSION IF NOT EXISTS "unaccent";
CREATE OR REPLACE FUNCTION slugify("value" TEXT)
RETURNS TEXT AS $$
-- removes accents (diacritic signs) from a given string --
WITH "unaccented" AS (
SELECT unaccent("value") AS "value"
),
-- lowercases the string
"lowercase" AS (
@alpenzoo
alpenzoo / LICENSE.txt
Created September 30, 2022 09:31 — forked from hillerstorm/LICENSE.txt
Swedish social security number validator
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 Johan Hillerström <https://github.com/hillerstorm>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
"/*@ sourceMappingURL=" source mapping URL declaration is deprecated, "/*# sourceMappingURL=" declaration should be used instead.
//@ sourceMappingURL=jquery.min.map
to
//# sourceMappingURL=jquery.min.map
//@ sourceURL=<url>
to
//# sourceURL=<url>
@alpenzoo
alpenzoo / webworldwind-example.html
Created November 1, 2022 22:40 — forked from emxsys/webworldwind-example.html
A complete 3D virtual globe example - HTML, JavaScript and CSS - using ESA-NASA Web WorldWind, Bootstrap and KnockoutJS featuring a 3D globe view, 2D map projections, markers and place name finder. Simply download and open this HTML file in your browser to run the app, or see http://worldwind.earth/sample-app.html for a preview and write-up.
<!DOCTYPE html>
<html lang="en">
<!--
A sample framework for the ESA-NASA WebWorldWind web applications.
Author: Bruce Schubert
License: MIT
See: https://worldwind.arc.nasa.gov/web/
-->
<head>
<meta charset="utf-8">