Skip to content

Instantly share code, notes, and snippets.

View dyaa's full-sized avatar

Dyaa dyaa

View GitHub Profile
@dyaa
dyaa / offline-analytics.js
Created April 25, 2019 20:10 — forked from jeffposnick/offline-analytics.js
Standalone offline analytics code
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@dyaa
dyaa / check.js
Created September 30, 2013 15:02
Check if jplayer is playing
$("#jquery_jplayer_1").jPlayer({
swfPath: "http://www.jplayer.org/latest/js/Jplayer.swf",
ready: function () {
$(this).jPlayer("setMedia", { mp3: "http://77.68.106.224:8018/;stream/1" });
},
supplied: "mp3"
});
setInterval(function () {
var isPaused = $('#jquery_jplayer_1').data().jPlayer.status.paused;
@dyaa
dyaa / react-router-queyry-utils.js
Created June 18, 2018 15:05 — forked from DimitryDushkin/react-router-queyry-utils.js
React router utility functions to add and remove queries
import { browserHistory } from 'react-router';
/**
* @param {Object} query
*/
export const addQuery = (query) => {
const location = Object.assign({}, browserHistory.getCurrentLocation());
Object.assign(location.query, query);
browserHistory.push(location);
};
@dyaa
dyaa / FirebaseToFirestore.js
Last active May 3, 2018 20:34 — forked from JoeRoddy/FirebaseToFirestore.js
Convert Firebase Database JSON to Firestore Collections
var db = firebase.firestore();
var content = require("./sourceData.json");
content &&
Object.keys(content).forEach(contentKey => {
const nestedContent = content[contentKey];
if (typeof nestedContent === "object") {
Object.keys(nestedContent).forEach(docTitle => {
firebase
.firestore()
@dyaa
dyaa / index.html
Last active April 18, 2018 15:16
Auto Search from the Chrome's Address Bar. - Example from caniuse.com
<link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Can I use"/>
@dyaa
dyaa / compose.js
Created April 17, 2018 10:26 — forked from WaldoJeffers/compose.js
JavaScript one-line compose (ES6)
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)))
// Usage : compose functions right to left
// compose(minus8, add10, multiply10)(4) === 42
//
// The resulting function can accept as many arguments as the first function does
// compose(add2, multiply)(4, 10) === 42
@dyaa
dyaa / jplayer.js
Created September 30, 2013 14:38
#jplayer display the current song name in the main box
var myPlaylist = new jPlayerPlaylist({
//then this will capture the current song's title:
//myPlaylist.playlist[myPlaylist.current].title
//For instance, I used this to capture the current song's title and insert it into a div on my page with id 'current-track':
var myPlaylist = new jPlayerPlaylist({ the playlist });
$("#jquery_jplayer_1").bind($.jPlayer.event.play, function(event) {
@dyaa
dyaa / Challenge.md
Created December 19, 2017 09:16 — forked from rewop/Challenge.md
Test task

Task

Implement a page with a multi-step form, where each step shows when you have completed the previous one. In other words, we're not looking for previous/next buttons, but the next step should appear automatically.

Steps

  1. Two checkboxes with labels A1 and A2. Both are unchecked by default. Next step is available after at least one of them is checked.
  2. Two toggle buttons with labels B1 and B2. One button untoggles another (same as radio buttons behavior). Both are inactive by default. Next step is available when any option has been chosen.
  3. Text field with button Check. When button is pressed a value of the field will be send. Next step is available if a response from API is fine.
  4. Selectbox with C1, C2, C3 options. It is empty by default. Next step is available when any option has been chosen.
@dyaa
dyaa / jquery.preload.js
Created October 18, 2017 16:18 — forked from mathiasbynens/jquery.preload.js
JavaScript preload() function
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
@dyaa
dyaa / inview.js
Created September 27, 2017 09:16
Check if a particular element is in view.
// Let me show approch without JQuery. Simple JS function:
function isVisible(elem) {
var coords = elem.getBoundingClientRect();
var topVisible = coords.top > 0 && coords.top < 0;
var bottomVisible = coords.bottom < shift && coords.bottom > 0;
return topVisible || bottomVisible;
}
// Short example how to use it: