Skip to content

Instantly share code, notes, and snippets.

View moshfeu's full-sized avatar
🇮🇱
Standing for

Mosh Feu moshfeu

🇮🇱
Standing for
View GitHub Profile
@moshfeu
moshfeu / index.html
Created August 30, 2019 15:50
Send data to the Service Worker
<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 / index.html
Created August 31, 2019 18:45
Start / Stop interval on Service Worker
<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
Last active September 1, 2019 05:07
Show notification from the service worker
<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 September 1, 2019 05:40
Polling data from the server and show notification if there a new data
<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.js
Created September 8, 2019 14:33
Get the most quality downloadable video url in youtube
// 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 / post.html
Created March 30, 2020 07:39
jekyll highlight code
{% highlight html linenos %}
<button>do alert</button>
<script>
document.querySelector('button').addEventListener('click', () => {
alert('clicked');
})
</script>
{% endhighlight %}
const App = () => {
const [isLoadgin, setIsLoading] = useState(true)
const [cardInfo, setCardInfo] = useContext(CardInfoContext)
useEffect(() => {
fetchData(result => {
setCardInfo(result);
setIsLoading(false);
})
}, [])
const select = $("#pipe_name" + j)
.select2({
placeholder: '-- Choose Pipe Name --',
theme: "bootstrap",
width: '100%'
})
.html('');
.append('<option value="">-- Choose Pipe Name --</option>');
$.ajax({
@moshfeu
moshfeu / iframe.html
Last active September 25, 2020 22:20
Corvid Analytics iframe's code
<!DOCTYPE html>
<html>
<body>
<script
type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"
></script>
<div id="chart_div"></div>
<siv id="loading">Loading...</siv>
@moshfeu
moshfeu / page.js
Last active September 25, 2020 22:28
Corvid Analytics page's code
import wixData from 'wix-data';
import _ from 'lodash';
$w.onReady(function () {
const getDataPromise = wixData.query('views').find();
// The iframe is ready
$w('#html1').onMessage(async ({ data }) => {
if (data.type === 'ready') {
const results = await getDataPromise;