Skip to content

Instantly share code, notes, and snippets.

View acro5piano's full-sized avatar
🏠
Working from home

Kay Gosho acro5piano

🏠
Working from home
View GitHub Profile
import React from "react";
import { Location } from "@reach/router";
let scrollPositions = {};
class ManageScrollImpl extends React.Component {
componentDidMount() {
try {
// session storage will throw for a few reasons
// - user settings
@cameronblandford
cameronblandford / knexPostgresFullTextSearch.js
Last active November 8, 2023 07:35
Implement full text search using Knex + Objection
// Because we're using an ORM (Objection), it's a pain to add a tsvector when inserting,
// since tsvectors and FTS aren't supported by Objection. Instead, I've added a hook that
// fires on insert which auto-generates the tsvector field for each newly inserted entry.
// This is an example knex migration file for said behavior.
const addUserIndex = `
ALTER TABLE public.user ADD "document" tsvector;
CREATE FUNCTION my_trigger_function()
RETURNS trigger AS $$
@glyons
glyons / epaper154YouTube.ino
Created May 13, 2018 12:22
Waveshare e-Paper Display 1.54" red/black YouTube Statistics
// mapping suggestion from Waveshare SPI e-Paper to Wemos D1 mini
// BUSY -> D2, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V
#include <GxEPD.h>
// select the display class to use, only one
#include <GxGDEW0154Z04/GxGDEW0154Z04.cpp> // 1.54" b/w/r 200x200
#include GxEPD_BitmapExamples
// FreeFonts from Adafruit_GFX
@azu
azu / AlminとFluxやReduxの違い?.md
Last active September 17, 2020 15:51
AlminとFluxやReduxの違い?

AlminとFB FluxやReduxの違い?

Almin

最低限のコンポーネントを並べると他のライブラリとあまり変わらないです。 ただレイヤーを意識して実装してみると、他のライブラリのチュートリアル通りの実装比較では実装量が増えると思います。 ただし、その場合も増えているのはAlminに依存した部分ではなく、自分で実装しないといけないDomainやInfra(Repository)などといったレイヤーになります。 これは責務をレイヤーで分離する考え方から来ているので、他のライブラリでも同じようなレイヤーを実装すると同じようにコード量が増えると思います。(登場人物が多く見える)

@wicharek
wicharek / getAllClassMethods.js
Created March 21, 2018 14:21
JavaScript: get all method names of the provided object
const getAllClassMethods = (obj) => {
let keys = []
let topObject = obj
const onlyOriginalMethods = (p, i, arr) =>
typeof topObject[p] === 'function' && // only the methods
p !== 'constructor' && // not the constructor
(i === 0 || p !== arr[i - 1]) && // not overriding in this prototype
keys.indexOf(p) === -1 // not overridden in a child
@tstrohmeier
tstrohmeier / bitbucket-pipelines.yml
Last active June 21, 2024 16:23
AWS ECS: Script for creating a new revision of a task definition and update a service
# enable Docker for your repository
options:
docker: true
pipelines:
branches:
development:
- step:
# python image with aws-cli installed
@emmiep
emmiep / puppeteer-demo1.js
Created March 3, 2018 15:29
Use puppeteer to get coordinates of an element
const Puppeteer = require('puppeteer');
(async () => {
const browser = await Puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
const header = await page.$('h1');
const rect = await page.evaluate((header) => {
const {top, left, bottom, right} = header.getBoundingClientRect();
package utils
import org.w3c.dom.HTMLElement
@JsName("grecaptcha")
external object GoogleRecaptcha {
fun render(element: HTMLElement, options: RecaptchaOptions)
}
class RecaptchaOptions(val sitekey: String, val callback: String, val size: String)
@artizirk
artizirk / index.html
Last active November 5, 2024 16:04
Python asyncio websockets http static file server, aka http and websocket server on the same port: python-websockets/websockets#116
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebSocket demo</title>
</head>
<body>
<script>
var ws = new WebSocket("ws://127.0.0.1:8765/"),
messages = document.createElement('ul');
@paivaric
paivaric / 1.google-analytics-proxy-nginx.conf
Last active January 30, 2024 17:21
Google Analytics Proxy using Nginx to bypass Adblock and other blockers
server {
listen 80;
server_name your.domain.com;
location = /analytics.js {
# you have to compile nginx with http://nginx.org/en/docs/http/ngx_http_sub_module.html (this is not default)
# and http://nginx.org/en/docs/http/ngx_http_proxy_module.html (it's a default module)
proxy_set_header Accept-Encoding "";