Skip to content

Instantly share code, notes, and snippets.

@necolas
necolas / using-OnLayout.js
Last active September 23, 2020 09:16
React Pressable / OnLayout
/**
* OnLayout is built upon: View (and ResizeObserver), StyleSheet
*/
const elementBreakpoints = {
small: { minWidth: 200 },
medium: { minWidth: 300 }
large: { minWidth: 500 }
};
// In v2/3 you did this:
import ReactDOM from 'react-dom'
import { Router, browserHistory, Route } from 'react-router'
ReactDOM.render(
<Router>
<Route path="/about" component={About}/>
<Route path="/:username" component={User}/>
</Router>
)
@jtsaito
jtsaito / dynamodb_lambda.MD
Last active January 31, 2018 18:33
AWS DyndamoDB and Lambda

This code example briefly describes how to store data to and retrieve data from DynamoDB using two AWS Lambdas. In this example we assume a DynamoDB tale test-can-learn with String key user_uuid in region eu-west-1. As a bonus, we show how to make the read access available as RESTful resource with AWS' API Gateway.

1. Setup Lambdas

Skip Lambda templates and craete the Lambdas custom. Then assign the Basic with DynamoDB role to the Lambda.

2. Lambda writing to DynamoDB

var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({
  region: 'eu-west-1'
@stuntbox
stuntbox / gist:4557917
Last active March 23, 2023 03:32
Slightly smarter filtering to remove hard-coded width and height attributes from *all* images in WordPress (post thumbnails, images inserted into posts, and gravatars). Handy for responsive designs. Add the code below to the functions.php file in your theme's folder (/wp-content/themes/theme-name/ ). Remember to rename the function as needed to …
/**
* Filter out hard-coded width, height attributes on all images in WordPress.
* https://gist.github.com/4557917
*
* This version applies the function as a filter to the_content rather than send_to_editor.
* Changes made by filtering send_to_editor will be lost if you update the image or associated post
* and you will slowly lose your grip on sanity if you don't know to keep an eye out for it.
* the_content applies to the content of a post after it is retrieved from the database and is "theme-safe".
* (i.e., Your changes will not be stored permanently or impact the HTML output in other themes.)
*
@mahemoff
mahemoff / names.txt
Created April 5, 2012 22:24
Reserved username list
###
A meta-compilation of:
https://raw.github.com/gist/1453705/d253733a56632a8d2c29321a75c18b627fa4dda8/reserved_usernames.rb
http://blog.postbit.com/reserved-username-list.html
http://www.quora.com/How-do-sites-prevent-vanity-URLs-from-colliding-with-future-features
(Took out some company-specific terms at the top of the first one (e.g. imulus, stacks), added one term so far - 'edits'.)
NOTE: Does not include profanities. You may or may not want to add a list of those.
(See https://www.google.com/search?q=profanity+list, but don't try to apply regexp's here because Scunthorpe - http://en.wikipedia.org/wiki/Scunthorpe_problem)
@romul
romul / delayed_tasks.markdown
Created March 28, 2011 09:50
Running rake tasks in background
  1. Add gem 'delayed_job', '2.1.4' to your Gemfile

  2. Run bundle install

  3. Run rails g migration create_delayed_jobs

  4. Edit the created migration to contain:

     class CreateDelayedJobs < ActiveRecord::Migration
       def self.up
         create_table :delayed_jobs, :force => true do |table|
           table.integer  :priority, :default => 0      # jobs can jump to the front of
    

table.integer :attempts, :default => 0 # retries, but still fail eventually