Skip to content

Instantly share code, notes, and snippets.

@segore
segore / gist:bab1141da550799fce61e656b644bf9e
Created April 17, 2022 10:36 — forked from EvanHahn/gist:2587465
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
"Encrypt" like this:
caesarShift('Attack at dawn!', 12); // Returns "Mffmow mf pmiz!"
And "decrypt" like this:
@segore
segore / 01-simple.test.js
Created October 23, 2020 10:22 — forked from a-h/01-simple.test.js
Testing styled Material UI components with Enzyme
import React from 'react';
import { shallow } from 'enzyme';
const Item = text => <p>Item {text}</p>;
const Composition = ({ showB }) => (
<p>
<Item text="A" />
{showB && <Item text="B" />}
</p>);
@segore
segore / LegoSetImage.js
Created September 11, 2020 14:42
Redux useSelector and useDispatch hook test example
import React, { FunctionComponent } from "react";
import { useSelector, useDispatch } from "react-redux";
import { selectCurrentSet, zoomImage } from "../dataLayer";
export const LegoSetImage: FunctionComponent = () => {
const set = useSelector(selectCurrentSet);
const dispatch = useDispatch()
const zoomHandler = () => dispatch(zoomImage(set.set_img_url))
return (
<div className="legoSetImageContainer">
@segore
segore / redux-actions.ts
Created September 7, 2020 16:39 — forked from milankorsos/redux-actions.ts
Correct TypeScript typing example for Redux Thunk actions
import {Action, ActionCreator, Dispatch} from 'redux';
import {ThunkAction} from 'redux-thunk';
// Redux action
const reduxAction: ActionCreator<Action> = (text: string) => {
return {
type: SET_TEXT,
text
};
};
@segore
segore / HTMLElementPlus.js
Created June 11, 2020 17:11 — forked from AdaRoseCannon/HTMLElementPlus.js
HTML Element Plus for Web Components
'use strict';
class HTMLElementPlus extends HTMLElement {
static defaultAttributeValue() {
/* the name of the attribute is parsed in as a parameter */
return;
}
static parseAttributeValue(name, value) {
@segore
segore / azure-pipelines.yml
Created June 3, 2020 12:03 — forked from zanechua/azure-pipelines.yml
Azure Pipeline + Laravel + MySQL + PHPUnit + Laravel Dusk
# PHP
# Test and package your PHP project.
# Add steps that run tests, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/php
pool:
vmImage: 'Ubuntu 16.04'
variables:
phpVersion: 7.2
@segore
segore / px
Created April 21, 2020 14:53 — forked from b1zantine/px
Shell Script to set proxy in Ubuntu
#!/bin/sh
_DOMAIN="proxy.ssn.net"
_PORT=8080
_IGNORE_PROXY="'*.ssn.net'"
_ENV_FILE_PATH="/etc/environment"
_APT_FILE_PATH="/etc/apt/apt.conf"
_MODE_MANUAL="manual"
_MODE_NONE="none"