Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ian Ker-Seymer ianks

🏠
Working from home
View GitHub Profile
View hidden-with-state.js
export const UserAvatar = () => {
const [isHidden, setHidden] = React.useState(false);
// Will instantly hide the component, causing a jarring UX
if (isHidden) {
return null;
}
return (
<>
View typed.rb
def sum_price(items: Enumerable<RespondTo[price: Integer]>
# ...
end
View with-class.jsx
export class UserList extends React.Component {
handleClick = (item) => console.log('You clicked ', this.props.group);
render() {
return (
<HugeListOfItems
group={group}
handleClick={this.handleClick}
/>
);
View complicated-state-form.jsx
// Overly complicated search form which uses custom state management 👎
function SearchBox() {
const [queryParams, setQueryParams] = useState({ showAllResults: false });
const handleSearchChange = (ev) => {
const eventValue = ev.target.value;
setQueryParams({ ...queryParams, q: eventValue });
}
@ianks
ianks / current-lead-source-analysis.md
Created Apr 21, 2020
Current Lead Source Analysis
View current-lead-source-analysis.md

Current Values

leadSource Count
"" 892
Direct 4939
Directory 1063
Friends and Family 1
Google Ad Words 2
Google PPC 7233
View ff-pixel-update.md

On all of the FF websites, we currently have a pixel installed with this code:

<script src="https://cdn.flooringstores.com/js/floorforce-analytics.min.js"></script>

It needs to be replaced with this new code, so it points to the new home of the pixel:

<script src="https://www.floorlytics.broadlu.me/floorforce/scitylana.min.js"></script>
View tty_markdown_highlight_bug.rb
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'tty-markdown'
end
print TTY::Markdown.parse <<~MSG
```ruby
def test
View Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
gem "puma", "~> 3.12"
gem "guard-puma", "~> 0.5.0"
@ianks
ianks / docker-compose.yml
Last active Jun 6, 2018
Threads in google-cloud-pubsub
View docker-compose.yml
---
version: '3.6'
services:
pubsub:
image: adhawk/google-pubsub-emulator
ports:
- 8085:8085
@ianks
ianks / slugify.sql
Last active Oct 9, 2020
Generating Slugs in Postgres
View slugify.sql
CREATE EXTENSION IF NOT EXISTS "unaccent";
CREATE OR REPLACE FUNCTION slugify("value" TEXT)
RETURNS TEXT AS $$
-- removes accents (diacritic signs) from a given string --
WITH "unaccented" AS (
SELECT unaccent("value") AS "value"
),
-- lowercases the string
"lowercase" AS (
You can’t perform that action at this time.