Skip to content

Instantly share code, notes, and snippets.

💭
Always looking for a way to Spread the Code

Mosh Feu moshfeu

💭
Always looking for a way to Spread the Code
Block or report user

Report or block moshfeu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@moshfeu
moshfeu / index.js
Created Sep 8, 2019
Get the most quality downloadable video url in youtube
View index.js
// run it in the console
JSON.parse(ytplayer.config.args.player_response).streamingData.formats.sort((a, b) => a.width - b.width).pop().url
@moshfeu
moshfeu / index.html
Created Sep 1, 2019
Polling data from the server and show notification if there a new data
View index.html
<button onclick="sendMessage('start')">Start Listen</button>
<button onclick="sendMessage('stop')">Stop Listen</button>
<script>
let se;
navigator.serviceWorker.register('/sw.js').then(data => {
se = data.active;
console.log('se ready!');
});
function sendMessage(message) {
if (!se) {
@moshfeu
moshfeu / index.html
Last active Sep 1, 2019
Show notification from the service worker
View index.html
<button onclick="sendMessage('start')">Start Listen</button>
<button onclick="sendMessage('stop')">Stop Listen</button>
<button onclick="sendMessage('notification')">Send a Notification</button>
<script>
let se;
navigator.serviceWorker.register('/sw.js').then(data => {
se = data.active;
console.log('se ready!');
});
function sendMessage(message) {
@moshfeu
moshfeu / index.html
Created Aug 31, 2019
Start / Stop interval on Service Worker
View index.html
<button onclick="sendMessage('start')">Start Listen</button>
<button onclick="sendMessage('stop')">Stop Listen</button>
<script>
let se;
const registration = navigator.serviceWorker.register('/sw.js').then(data => {
se = data.active;
console.log('ready');
});
function sendMessage(message) {
@moshfeu
moshfeu / index.html
Created Aug 30, 2019
Send data to the Service Worker
View index.html
<button onclick="sendMessage()">Send message</button>
<script>
let se;
const registration = navigator.serviceWorker.register('/sw.js').then(data => {
se = data.active;
console.log('ready');
});
function sendMessage() {
@moshfeu
moshfeu / final-code.js
Created Mar 30, 2019
AJV + Jest - gits #7
View final-code.js
const validateSecuredUrl = function (schema, uri) {
validateSecuredUrl.errors = [{keyword: 'secured', message: 'avatar url must be "https" schema', params: {keyword: 'secured'}}];
return uri.indexOf('https://') === 0;
};
ajv.addKeyword('securedUrl', {
validate: validateSecuredUrl,
errors: true
});
View use-custom-keyword.js
const validateSecuredUrl = function (schema, uri) {
return uri.indexOf('https://') === 0;
};
ajv.addKeyword('securedUrl', {
validate: validateSecuredUrl,
errors: true
});
it(`should user's schema be valid`, () => {
View meaningful-message-custom-matcher.js
expect.extend({
toBeValid(isValid, errorMessage) {
return {
message: () => isValid ? '' : errorMessage,
pass: isValid
}
}
});
it(`should user's schema be valid`, () => {
View wrap-validation-with-it.js
it.only(`should user's schema be valid`, () => {
const schema = {
"type": "array",
"items": {
"type": "object",
"properties": {
"fullname": {
"type": "string",
"minLength": 2
},
View basic-validation.js
import users from './users.json';
const shema = {
"type": "array",
"items": {
"type": "object",
"properties": {
"fullname": {
"type": "string",
"minLength": 2
You can’t perform that action at this time.