Skip to content

Instantly share code, notes, and snippets.

@ttntm
ttntm / terminal-cheat-sheet.txt
Created December 10, 2023 16:31 — forked from cferdinandi/terminal-cheat-sheet.txt
Terminal Cheat Sheet
# Terminal Cheat Sheet
pwd # print working directory
ls # list files in directory
cd # change directory
~ # home directory
.. # up one directory
- # previous working directory
help # get help
-h # get help

This gist is a simple no-brainer description of the 3 ways (actually 2.5) the Web handle events.

<tag onclick />

The declarative inline HTML event listener is mostly an indirection of DOM Level 0 events, meaning this simply uses the equivalent of tag.onclick = listener behind the scene.

Example

click me
@ttntm
ttntm / Y-Combinator_test.js
Last active April 12, 2023 11:53
Y-Combinator, Fibonacci 10, 177 passes
const t = []
function yFib(n) {
return (function(fn) {
return fn(fn, n)
})(function(fn, n) {
t.push(n)
if (n <= 1) {
return n
} else {
@ttntm
ttntm / SFMC-AMPscript-exclusion-script-content-block.amp
Created December 22, 2022 12:42 — forked from wvpv/SFMC-AMPscript-exclusion-script-content-block.amp
Exclusion Script Content Block - Prevent duplicates
%%[
var @contextInsertDate
set @contextInsertDate = AttributeValue("YOUR_TSD_DE_INSERT_DATE")
set @contextInsertDate = format(@contextInsertDate,"yyyyMMddhhmmss")
var @exclude
set @exclude = 0
@ttntm
ttntm / UpdateQuery.js
Created November 9, 2022 13:18 — forked from eliotharper/UpdateQuery.js
Updates SFMC Query Activity with Auto-Suppression list as target Data Extension
<script language="javascript" runat="server">
// Author: Eliot Harper <eliot@eliot.com.au>
// Revision date: January 31, 2021
// DISCLAIMER
// While due care has been taken in the preparation of this
// supplied code example, no liability is assumed for incidental
// or consequential damages in connection with or arising out its
// use. Example code is provided on an "as is" basis and no
// expressed or implied warranty of any kind is made for the
@ttntm
ttntm / scroll-to-top.js
Created March 20, 2020 11:21
Vanilla JS scroll to top
scrollTo = (el) => {
window.scroll({
behavior: 'smooth',
left: 0,
top: el.offsetTop
});
}
document.getElementById("btt").addEventListener('click', () => {
scrollTo(document.getElementById("top"));
@ttntm
ttntm / osm-scroll_zoom_handler.html
Last active March 2, 2020 11:03
OpenStreetMap iFrame - click to activate mousewheel zoom
### example based on Tailwind CSS
### demo: https://codepen.io/ttntm/full/eYNRQYz
----
<div class="map_canvas relative">
<div class="map_overlay absolute top-0 left-0 flex flex-col justify-center">
<span class="self-center text-center text-2xl text-petrolblue">Click to activate this map</span>
</div>
<iframe class="map no_scroll" width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=16.35138720273972%2C48.19426099352119%2C16.354927718639377%2C48.19583796732457&amp;layer=mapnik&amp;marker=48.19504948648988%2C16.353157460689545"></iframe>
</div>
<style>
@ttntm
ttntm / ESC-handler.js
Created January 17, 2020 12:12
JavaScript ESC key listener
// document is necessary; window context requires a click into the page body for it to work (at least in Chrome)
document.addEventListener('keydown', function(e){
if((e.key=='Escape'||e.key=='Esc'||e.keyCode==27)){ // if necessary: target specific node with: && (e.target.nodeName=='BODY')
// if necessary: e.preventDefault();
// do something with the ESC button press, i.e. close modal/NAV/lightbox etc.
}
}, true);