Skip to content

Instantly share code, notes, and snippets.

View yuvalkarmi's full-sized avatar

Yuval Karmi yuvalkarmi

  • Tel Aviv, Israel
View GitHub Profile
// MUI v5 Checkbox with a ripple effect that gets triggered when label is clicked
// Inspired by, and partially adapted from by this excellent StackOverflow answer:
// https://stackoverflow.com/questions/66888248/how-do-i-programatically-show-ripple-effect-with-mui
import { useRef, useState } from 'react';
import { Stack, Checkbox, Typography, Box } from '@mui/material';
import TouchRipple from '@mui/material/ButtonBase/TouchRipple';
const CheckboxWithLabelAndRipple = ({ label, checked, onChange }) => {
const checkboxRef = useRef(null);
@yuvalkarmi
yuvalkarmi / blockNextNavigation.js
Last active October 31, 2023 08:43
How to block a user from navigating away in NextJS when clicking on Link component
/*
In standard web apps, when users navigate away to a different page or website or attempt to refresh a page,
we can use the window event listener `beforeunload` to help users avoid losing the work.
However, when a user clicks on a native NextJS <Link> component, the navigation is not intercepted
because behind the scenes, no page changes are actually happening.
To intercept user navigation in a NextJS app, we can subscribe to the
router routeChangeError event and throw an error.
Note: we must throw an Error string - not a `new Error()` - which is why in the code below, we have
// eslint-disable-next-line no-throw-literal
// add this *before* you call actionbar.load("YOUR_CUSTOMER_ID");
actionbar.configure({
uuid: 'jane@example.com', // or anything you want to be the id of the user
user: {
name: 'Jane Smith',
email: 'jane@example.com'
}
})
window.actionbar = null;
!function(){var r=window.actionbar=window.actionbar||[];if(!r.initialize&&!r.invoked){r.invoked=!0,r.methods=["configure","identify","reset","ready","debug","off","on"],r.generator=function(t){return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(t),r.push(e),r}};for(var e=0;e<r.methods.length;e++){var t=r.methods[e];r[t]=r.generator(t)}r.load=function(e){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://cdn.simpo.io/actionbar.js",r.ucid=e;var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)},r.SNIPPET_VERSION="2.0.0"}}();;
actionbar.load("2730b6f8464b771dfc69abb32ee892ebe8b7ed691e");
// this script is meant to give a pretty good general idea of whether a VC is likely to invest in a seed round based on recent investments
// go to this url and paste into the javascript console (replace "founders-fund" with the appropriate VC)
// https://www.crunchbase.com/organization/founders-fund/investments
// to open the console you can right click anywhere, choose Inspect, and then click on the Console tab
// this outputs a tab separated list with:
// total -- total number of investments that appear on the page (for crunchbase by default this is 40 unless you scroll down the page to load more)
// seed -- total number of seed investments that appear on the page
@yuvalkarmi
yuvalkarmi / gist:3876ad27211e3071e99b24f25ba9b48c
Created November 1, 2016 14:08 — forked from birula/gist:9077748
Using SSL in your local rails environment
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@yuvalkarmi
yuvalkarmi / gist:6089975
Created July 26, 2013 15:50
CommentLuv & JetPack CSS Fix
<style>
/* COMMENTLUV */
input[name='doluv'], input[name='gasped'] {
box-shadow: 0 0 0;
width: auto!important;
}
#gasp_p {
margin-top: 10px;
@yuvalkarmi
yuvalkarmi / gist:3756965
Created September 20, 2012 16:38
Trace
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:368:in `execute'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:368:in `block in exec_stmt'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:357:in `exec_stmt'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:292:in `exec_query'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:430:in `select'
vendor/bundle/ruby/1.9.1/gems/activer
set :application, "myapp.com"
role :app, application
role :web, application
role :db, application, :primary => true
set :user, "myuser"
set :deploy_to, "/home/#{user}/#{application}"
set :use_sudo, false
set :scm, "git"
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
load 'deploy/assets'