Skip to content

Instantly share code, notes, and snippets.

View Gioni06's full-sized avatar
👨‍💻
Working from home

Jonas D. Gioni06

👨‍💻
Working from home
View GitHub Profile
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@Gioni06
Gioni06 / iPhoneChecker.js
Last active August 29, 2015 14:06
Check if Device is an Iphone or iPod
if(navigator.vendor != null && navigator.vendor.match(/Apple Computer, Inc./) && navigator.userAgent.match(/iPhone/i) || (navigator.userAgent.match(/iPod/i)))
{
// Device is an iPhone or iPod
}
@Gioni06
Gioni06 / removejscssfile.js
Created October 31, 2014 13:52
Remove CSS and JS Files
function removejscssfile(filename, filetype){
var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from
var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
var allsuspects=document.getElementsByTagName(targetelement)
for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)
allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
}
}
@Gioni06
Gioni06 / parseUrl.js
Last active October 27, 2015 11:56
Javascript Parse URLs
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function(){
@Gioni06
Gioni06 / AngularJS-ES6-Test-Skeleton
Created December 2, 2015 18:47 — forked from busypeoples/AngularJS-ES6-Test-Skeleton
AngularJS - Karma, Jasmine, Browserify, Stringify - ES6 Test Setup
We couldn’t find that file to show.
@Gioni06
Gioni06 / tmux-cheatsheet.markdown
Created November 10, 2016 20:58 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@Gioni06
Gioni06 / darkmode.js
Last active November 30, 2022 00:11
Enable Dark mode with css variables and js
function activateDarkMode() {
const rootElement = document.querySelector(':root')
const darkTheme = {
'--background-color': '#1e1e1e',
'--primary-color': '#157efb',
'--font-color': '#dedede',
'--subtle-primary-color': '#151513',
'--block-background-color': '#323232',
'--menu-item-color': '#dedede',
'--menu-item-hover-color': '#157efb',
@Gioni06
Gioni06 / darkmode.css
Last active May 1, 2020 07:14
dark mode with css
:root {
--background-color: #fff;
--page-width: 70em;
--primary-color: #151513;
--font-color: #151513;
--subtle-primary-color: #151513;
--block-background-color: #f1f3f4;
--menu-item-color: #000;
--menu-item-hover-color: #000;
--menu-item-alert-bg: #ffffff;
@Gioni06
Gioni06 / index.html
Last active September 10, 2019 14:53
jQuery "closest" vs vanilla "closest"
<nav id="test">
<li><a href="/1">1</a></li>
<li><a href="/2">2</a></li>
<li><a href="/3" id="qs1">3</a></li>
<li><a href="/4">4</a></li>
</nav>
<nav id="test2">
<li><a href="/1">1</a></li>
<li><a href="/2">2</a></li>
<li><a href="/3" id="qs2">3</a></li>
.logo {
display: block;
margin: 0;
width: 272px;
height: auto;
overflow: hidden;
text-decoration: none;
}
.logo img {