Skip to content

Instantly share code, notes, and snippets.

View amitrahav's full-sized avatar

Amit Rahav amitrahav

  • HourOne
  • Tel-Aviv Israel
View GitHub Profile
// Listen for messages
sse.addEventListener("channel-name", function(e) {
console.log(e.data)
})
// Listen for messages
socket.addEventListener("channel-name", function (event) {
console.log("Message from server", event.data);
});
// addEventListener version
evtSource.addEventListener("open", (e) => {
console.log("The connection has been established.");
});
// onopen version
evtSource.onopen = (e) => {
console.log("The connection has been established.");
};
// Connection opened
socket.addEventListener("open", (event) => {
const sse = new EventSource('/api/v1/sse');
const socket = new WebSocket('ws://localhost:8080/api/v1/socket');
@amitrahav
amitrahav / pm.auth0.collection.pre-request
Last active May 2, 2023 10:57
Postman Auth0 pre-request auth script with Collection level variables. Define collection Auth to BearerToken with {{oidc_bearer_token}}
// collection pre-request script
// obtain parameters from collection configuration
const domain = pm.environment.get("auth0_domain");
const client_id = pm.environment.get("auth0_client_id");
const audience = pm.environment.get("auth0_audience");
const client_secert = pm.environment.get("auth0_client_secret");
const username = pm.environment.get("username");
const password = pm.environment.get("password");
#!/usr/bin/env bash
if [ -z ${WPCONFIG+x} ]; then WPCONFIG=/Users/amit/.wpconfig; fi
THEMENAME="${PWD##*/}"
getDefualtValues(){
echo "getting defualt values..."
if [ -f "$WPCONFIG" ]; then
source "$WPCONFIG"
else
echo "Please create and set your WPCONFIG file on ${WPCONFIG} or change path by WPCONFIG varible"
<?php get_header(); ?>
<?php
global $post;
$slug;
if (is_front_page()) {
$slug = "front";
} else if (file_exists(locate_template('partials/content-' . $post->post_name . '.php'))) {
$slug = $post->post_name;
} else {
(function($) {
// define easeInOutQuint
$.easing.jswing = $.easing.swing;
$.extend($.easing, {
easeInOutQuint: function(x, t, b, c, d) {
if ((t /= d / 2) < 1) return (c / 2) * t * t * t * t * t + b;
return (c / 2) * ((t -= 2) * t * t * t * t + 2) + b;
}
@amitrahav
amitrahav / code.gs
Last active April 7, 2019 21:54
googleAppScript for updating sheets at giveback (by headstart) donations data
var ss = SpreadsheetApp.getActiveSheet();
var lastRow = ss.getLastRow();
// my table col where: timestemp, amount, diff, donorsNum, donors name
var MONEYCOL = 2;
var DonorsCOL = 4;
function parseHtml(searchString){
var url = ''; //this is the roject URL. tested on www.giveback.co.il, should probebly work on https://headstart.co.il/ with minor changes
var html = UrlFetchApp.fetch(url).getContentText();
@amitrahav
amitrahav / S3FixExistingMedia.php
Last active August 13, 2018 12:24 — forked from akira28/S3FixExistingMedia.php
roots.io/bedrock require path
<?php
/* ======================================================
This script is NOT FULLY TESTED (not tested on Windows Server either)
USE AT YOUR OWN RISK - development environment Ubuntu Linux 14.04.3 LTS
The purpose of this script is for small websites and blogs
to have their existing media to work through Amazon S3
There's a great plugin, WP Offload S3, that we'll be tapping
into...it works great for new media, but this is a quick
@amitrahav
amitrahav / wpcli-creating-plugins-json
Created March 30, 2017 01:43
creating plugins.json file using bash script
#! /bin/bash
wpCLI=`wp`
if [ "$wpCLI" = "" ]
then
echo "WP-cli does not exist on this system."
# exit 1
fi
wp plugin list | tr -d '|' | grep 'active' | cut -f 1,4 | awk ' BEGIN { ORS = ""; print "plugins: {"; } { print "\/\@"$1"\/\@" " : " "\/\@"$2"\/\@"; } END { print "},"; }' | sed "s^\"^\\\\\"^g;s^\/\@\/\@^\",\"^g;s^\/\@^\"^g" > pluginss.json