Skip to content

Instantly share code, notes, and snippets.

View martinandert's full-sized avatar

Martin Andert martinandert

View GitHub Profile
@jesster2k10
jesster2k10 / README.md
Last active April 25, 2024 00:54
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

@ClickerMonkey
ClickerMonkey / types.ts
Last active February 6, 2024 07:21
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@xdamman
xdamman / install_ffmpeg_ubuntu.sh
Created July 2, 2014 21:03
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@jameslockwood
jameslockwood / redux-thunk-poll.js
Last active August 24, 2023 20:38
thunk poller - easily poll redux thunk functions
// createPollingAction() returns a thunk which continually polls, once invoked.
// subsequent invocations will cancel the previous poll queue.
const createPoller = (interval, initialDelay) => {
let timeoutId = null;
let poller = () => {};
return fn => {
window.clearTimeout(timeoutId);
poller = () => {
timeoutId = window.setTimeout(poller, interval);
@renancouto
renancouto / exploit-urls.md
Last active February 1, 2023 09:36
A collection of weird URLs that I think are used to exploit security vulnerabilities on web apps
  • /manager/html (Apache Tomcat)
  • http://123.249.24.233/POST_ip_port.php
  • /tmUnblock.cgi
  • /HNAP1/
  • /phpMyAdmin/scripts/setup.php (PHPMyAdmin)
  • /pma/scripts/setup.php
  • /myadmin/scripts/setup.php
  • /MyAdmin/scripts/setup.php
  • /vyvy/vyv/vy.php
  • /cgi-sys/php5
'use strict';
var React = require('react-native');
var {
Bundler,
StyleSheet,
Text,
TouchableHighlight,
View,
ScrollView,
@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
@dylanjha
dylanjha / 0. sprockets_depend_on_config.rb
Last active May 11, 2020 15:11
Adds Sprockets Directive `depend_on_config`. I'm using this to load .yml locale translations on the server into the client in json
=begin
Useage:
#assets/locales/en.js.erb
```js
//= depend_on_config 'locales/es.yml'
```
=end