Skip to content

Instantly share code, notes, and snippets.

@mlynarczyk
mlynarczyk / pan-scrollwheel.tsx
Created February 14, 2024 17:04 — forked from edge-rps/pan-scrollwheel.tsx
Pan using scroll wheel with react-zoom-pan-pinch library
const Component = () => {
const transformComponentRef = useRef<ReactZoomPanPinchRef | null>(null);
const zoomToImage = () => {
if (transformComponentRef.current) {
const { zoomToElement, setTransform, instance } =
transformComponentRef.current;
zoomToElement("large", 1);
// centerView(0.3);
@mlynarczyk
mlynarczyk / letsencrypt_2017.md
Created May 10, 2018 02:14 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@mlynarczyk
mlynarczyk / import-directory.js
Created April 14, 2018 23:58
webpack import components directory
const viewsContext = require.context('./views', false, /\.vue$/);
let views = {};
viewsContext.keys().forEach((key) => {
const name = viewsContext(key).default.name;
views[name] = viewsContext(key).default;
});
@mlynarczyk
mlynarczyk / state-helpers.js
Last active July 5, 2018 12:22
Vue/Vuex collection helpers
export default {
mergeWithItemBy (collection, item, attr) {
const foundIndex = collection.findIndex(obj => obj[attr] === item[attr]);
if (collection && (foundIndex !== -1)) {
const newObj = Object.assign({}, collection[foundIndex], item)
collection.splice(foundIndex, 1, newObj)
} else {
collection.push(item)
}
@mlynarczyk
mlynarczyk / mongo-autostart-osx.md
Last active November 10, 2015 11:03
autostart mongo @osx
brew update
brew install mongodb
ln -s /usr/local/Cellar/mongodb/2.6.3/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/
@mlynarczyk
mlynarczyk / scrollPoints.js
Created August 11, 2012 20:35
define an array of points that are x pixels from top and scroll between those points using keyboard arrows
$(function(){
//array of points that are x pixels from top
var scrollPoints = ['0', '850', '2100', '2950', '4400', '5280', '7000', '7850', '8600', '9450', '10290'];
//$.browser is going to be removed with jQuery 1.9
if ($.browser.webkit === true) {
var one = two = 'body';
} else if ($.browser.opera === true) {