Skip to content

Instantly share code, notes, and snippets.

@joeytrapp
joeytrapp / phoenix_test_redirect_missing_req_headers.exs
Last active September 6, 2024 23:44
Demonstrate that manually set request headers are not present in redirect/navigate requests
Mix.install(
[
{:phoenix_playground, "~> 0.1.6"},
{:phoenix_test, "~> 0.3.2"}
],
config: [
phoenix_test: [endpoint: Demo.Endpoint],
phoenix_playground: [
{Demo.Endpoint,
[
@joeytrapp
joeytrapp / FileBtn.re
Created April 10, 2019 17:54
ReasonReact 0.7.0 ref example
[@react.component]
let make = (~className="", ~onSelect, ~children) => {
let fileInputRef: ReactDOMRe.Ref.currentDomRef =
React.useRef(None->Js.Nullable.fromOption);
let key = React.useRef(1);
let handleInputChange =
React.useCallback0(event => {
let files = ReactEvent.Form.target(event)##files;
class App extends React.Component {
constructor() {
super();
this.state = { showPicker: true };
}
componentDidUpdate() {
console.log(document.querySelectorAll(".pika-single"));
}
@joeytrapp
joeytrapp / package.json
Created September 19, 2014 20:42
Load and link local modules in vendor/ as items in node_modules/
{
"name": "name",
"version": "0.0.1",
"description": "desc",
"main": "index.js",
"scripts": {
"test": "make test",
"preinstall": "find vendor -type d -maxdepth 1 | tail -n 2 | cut -c8- | xargs -L 1 -I {} rm -f node_modules/{}",
"postinstall": "find vendor -type d -maxdepth 1 | tail -n 2 | cut -c8- | xargs -L 1 -I {} sh -c 'ln -s \"$(pwd)/vendor/{}\" node_modules/{}; cd vendor/{} && npm install'"
},
@joeytrapp
joeytrapp / index.html
Last active August 29, 2015 14:05
z-index demo
<!DOCTYPE html>
<html>
<head>
<title>z-index test</title>
<style>
body {
z-index: 100;
background: white;
}
div {
@joeytrapp
joeytrapp / application_controller.js
Last active August 29, 2015 14:05
Ember Notifications
App.ApplicationController = Em.Controller.extend({
notifictions: Blocks.Notifications.create(),
actions: {
notify: function() {
if (typeof obj === 'string') {
obj = { message: obj };
}
this.get('notifications').createNotification(obj);
},
@joeytrapp
joeytrapp / gist:65890927942b7725e60d
Created August 11, 2014 16:48
Example of pretender fixtures that can be run in the browser and queried against with jQuery.
// visit localhost:3000/test/demo.html
// run this snippet from chrome dev tools sources panel
agent = new Agent();
userIds = agent.makeIds('users', 2);
agent.group('users', function() {
this.fixture(userIds[1], { first: 'Joey', last: 'Trapp' });
this.fixture(userIds[2], { first: 'Lee', last: 'Forkenbrock' });
});
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
battle = (function() {
function completelyAccurateBattleCalculator() {
return Math.floor((Math.random()*10)+1);
}
function predictWinner(i) {
if (i >= 1 && i < 5) {
return 'goku';
} else if (i > 5 && i <= 10) {
return 'jl';
@joeytrapp
joeytrapp / SeedShell.php
Last active December 27, 2015 10:39
Very basic SeedShell, with default and dev files along with ability to specify file manually. Also has a firstOrCreate helper to make creating seed records idempotent.
<?php
class SeedShell extends AppShell {
public $seedFile = 'seed.php';
public $seedDevFile = 'seed_dev.php';
public function main() {
$this->includeFile($this->absolutePath($this->getFile()));
}