Skip to content

Instantly share code, notes, and snippets.

View jaidetree's full-sized avatar

jaide (formerly eccentric-j) jaidetree

View GitHub Profile
import { createApp, addLayer, init } from "libs/venuebook/app";
import { reducer, epic } from "app/planner/onboarding/store/use_cases";
createApp({
name: "onboarding",
// Route is not needed yet but will be required for micro-service frontend
route: "/signup/venue/onboarding/",
});
// Simpler View -> Store -> Render Architecture
@jaidetree
jaidetree / query.py
Last active October 3, 2018 20:37
What is the best way to format this multi-line Python code?
# What is the best way to format this multi-line Python code?
#############################################################
self.queryset = self.queryset.filter(
Q(
name__istartswith=self.query_params.get('name')
) | Q(
venues__name__istartwith=self.query_params.get('name')
)
)
@jaidetree
jaidetree / validator.js
Created August 28, 2018 00:22
An example of a functional-programming inspired validator
import { of } from "rxjs/observable";
import { filter, map } from "rxjs/operators";
import validate, * as v from "libs/validate";
const validateForm = validate([
v.field("name", "Full Name", [
v.isRequired,
"A full name is required.",
name => name.split(" ").length,
wordCount => wordCount < 2,
@jaidetree
jaidetree / gist:f315002f2e362fd5ee33d83318f37284
Created February 27, 2018 05:25
Open each humble bundle download button link in a new tab. Open the console on a humble bundle purchase page and paste this script.
function getURL (a) {
return a.href;
}
function openLink (url, i) {
window.open(url, `_book_${i}`);
window.confirm('Ready to continue?');
}
Array
(ns async-reddit
(:require [reddit :refer [get-reddit-posts]]
[clojure.core.async :as async]))
(defn get-post-link
[post]
(str "https://reddit.com" (:permalink post)))
(defn get-post-footer
[post]
#!/usr/bin/env node
const path = require('path');
const gulp = require('gulp');
const zip = require('gulp-zip');
const filter = require('gulp-filter');
// Resolve to absolute filenames relative to the direct the script is run in
function relative (filepath) {
return path.relative(process.cwd(), filepath);
this.box$ = Rx.Observable.fromEvent(content, 'mousedown')
// only take primary mouse button clicks
.filter(e => e.which === 1)
// only continue if the user is clicking on a drawn box or the drawing canvas
.filter(R.anyPass([
e => e.target.className.includes('box'),
e => e.target.className.includes('canvas__content'),
]))
// kill the previous stream when a passing event is emitted
.switchMap(start => Rx.Observable.of(start)
let data = [
{
label: 'Food',
value: 1,
},
{
label: 'Hors D\'Ouvers',
value: 2,
},
{
@jaidetree
jaidetree / promisify.js
Created October 25, 2016 18:17
Best attempt at a general wrapper around many types of callbacks.
/**
* Wraps the given callback in a promise
* @param {function} callback - Callback to call & wrap in a promise
* @param {...*} args - Arguments to send to the callback. Send the promise
* method to prefil arguments.
* @returns {promise} A promise resolved when callback is fired
* @example
* return promise(this.setState, data);
* return promise(setTimeout, promise, 500);
*/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>duuuuude</string>